Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: need variables to be stored in EEPROM

2005-04-26 by Dennis Clark

arhodes19044 wrote:
> 
> --- 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.

Yup.

> 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.

Those are the only timing critical steps, that is what I'd do.

> 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
>

DLC
-- 
---------------------------------------
Dennis Clark    TTT Enterprises
---------------------------------------

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.