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

2007-10-04 Thread Parthasaradhi Nayani
Hello,
I tested the code on mega8 using winavr release 20070525. No problems were 
encountered.

NPS

Michael [EMAIL PROTECTED] wrote:  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.
   
  
  ___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


   
-
Shape Yahoo! in your own image.  Join our Network Research Panel today!___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


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

2007-10-02 Thread Eric Weddington


 -Original Message-
 From:
 [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 org] On Behalf Of Michael
 Sent: Tuesday, October 02, 2007 7:31 PM
 To: avr-gcc-list@nongnu.org
 Subject: [avr-gcc-list] Reading eeprom without using routines
 in eeprom.h,causes reset.

 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;

 }



Did you know that avr-libc has an EEPROM API?:
http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html

It's been there for quite some time.

Eric Weddington




___
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list