Tony, About disabling interrupts during EEPROM writes, see below: arhodes19044 wrote: > > Actually, that struct idea is just perfect. > > I definitely was planning on keeping an SRAM version of the > variables, then only save the requesite info when necessary. > > One of these will be a "first-run" flag which will allow > initialization of the EEPROM, then there are some setting and > calibration values to keep. Most of the time I will have time to > write then verify the data. Maybe once in a while the writes will > occur during a time-critical period, so those (what is it? 4ms to > write?). I can not turn off interrupts because there is a 1ms clock > tick interrupt. Other less important interrupts occur at a MAXIMUM > frequency of every 1.8ms. And usually those interrupts will be > every 45ms or so! > > Anyway, I can not disable interupts, but I can verify at the end. You might want to check the data sheet before you think this: " 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. > From the code I saw, I would not have thought that interrupting the > register loading process would be a problem, but maybe it uses that > TEMP register. I have not looked at the specific doc for the 128 > yet. About to, tho. > > Thanks for the ideas. > > -Tony [snip] DLC -- --------------------------------------- Dennis Clark TTT Enterprises ---------------------------------------
Message
Re: [AVR-Chat] Re: need variables to be stored in EEPROM
2005-04-25 by Dennis Clark
Attachments
- No local attachments were found for this message.