avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Reading eeprom without using routines in eeprom.h, causes


From: Michael
Subject: [avr-gcc-list] Reading eeprom without using routines in eeprom.h, causes reset.
Date: Wed, 3 Oct 2007 11:31:17 +1000

Hi, when I was new to the avr-gcc (and still fairly new to C), I read the eeprom like this:

 

unsigned char eeread(unsigned char address)

{

            while(EECR & _BV(EEWE));

            EEAR = address;

            EECR |= _BV(EERE);

            return EEDR;

}

 

Not the ideal way of doing it, but it worked fine. I moved my code over from my debian system to winavr, which had a later version of the compiler.

 

The above code now causes the device to reset. I have experienced this on an Atmega128, and an Atmega8.

 

I can get things working again simply by using the eeprom.h routines in avr-libc, but I believe the above code should still work!

I currently have the latest version of winavr, I don’t remember which compiler version I was running under debian.

 

Can anybody shed any light on this? Why would the above code cause a reset when it used to work?

 

 

Regards, Michael.

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]