--- In AVR-Chat@yahoogroups.com, Dennis Clark <dlc@f...> wrote: > > Tony, > 1. Wait until EEWE becomes zero. > 2. Write new EEPROM address to EEAR (optional). > 3. Write new EEPROM data to EEDR (optional). > 4. Write a logical one to the EEMWE bit in EECR. > 5. Within four clock cycles after setting EEMWE, write a logical one to > EEWE. > Caution: An interrupt between step 4 and step 5 will make the write > cycle fail, since the > EEPROM Master Write Enable will time-out. If an interrupt routine > accessing the > EEPROM is interrupting another EEPROM access, the EEAR or EEDR Register > will be > modified, causing the interrupted EEPROM access to fail. It is > recommended to have > the Global Interrupt Flag cleared during all the steps to avoid these > problems. > " > It is a good idea to disable interrupts before writing a byte to EEPROM. > DLC > -- > --------------------------------------- > Dennis Clark TTT Enterprises > --------------------------------------- OOOOPS. That last part, 4 clock cyles, is pretty critical timing. I COULD disable interrupts for just step 4 and 5. I can modify the code for the Libc eeprom code to suit that. This is a very brief suspension. of the interrupts. What I do not want to do is to disable interupts for the entire duration of a multi-byte eeprom write. That could be many many milliseconds. But if the interrupts are suspended briefly, but repetetively, then that is not really a problem. Do you think it is necessary to have interrupts suspended for all the steps? Is there a limit to the duration of data sitting on the eeprom data registers? Actually it does not seem as if all the steps between 2-5 would take that long. While step 1 is waiting, interupts could be enabled. I will check the atmega128 docs on eeprom reading and writing. I printed the pertinent info out, but did not yet read it since the I had such luck with the built-in funtions. Of course right now, I only have the millisecond timer interrupt occuring. In real life I would have an external interrupt triggering at a regualr, but probably slow (10's of ms) rate. I will see if I can find the C/ASM code for the eeprom so I can hand- tune the interrupts. -Tony
Message
Re: need variables to be stored in EEPROM
2005-04-26 by arhodes19044
Attachments
- No local attachments were found for this message.