Re: Saving data in CPU on-chip EEPROM
- From: Anton Erasmus <nobody@xxxxxxxxxxxxxxxx>
- Date: Fri, 17 Jun 2005 00:32:52 +0200
On Thu, 16 Jun 2005 19:41:25 GMT, Jonathan Kirwan
<jkirwan@xxxxxxxxxxxxxx> wrote:
>On Thu, 16 Jun 2005 12:30:37 +0200, Anton Erasmus
><nobody@xxxxxxxxxxxxxxxx> wrote:
>
>><snip>
>>Use Gray Code for the counters. Only one bit changes between succesive
>>counts, which of course means only one byte changes. Make sure that if
>>there is a power failure, you have enough power to at least complete
>>any write you are busy with. That way if power fails, you either have
>>incremented the counter, or you have missed only one count.
>>I have used this method on an AVR that counts operation cycles on a
>>unit. Of over 300 units that has been operating over the last 4 years,
>>I have had no corrupt counters.
>
>I'm interested in the exact details of this. It is easy for me to
>imagine how this might be done, using a routine to read a gray code
>from non-volatile memory and convert it into multi-byte binary form in
>RAM, where it is incremented., and then converted this result back to
>gray code before writing back to non-volatile memory.
>
>But I don't know of a direct method to simply read out the current
>gray code value and more directly figure out which byte may have
>changed. It seems to me that the conversion to binary, with an
>increment taking place in that domain, is necessary.
>
>The conversion back and forth is relatively easy, but one of the
>conversions involves a loop and I'm wondering if there is a method
>that does not involve a loop and could be used to operate in an
>expression form.
Yes, what you have described is essentailly what I use. To ensure that
I do not write too many times to the same location, I use multiple 16
bit counters which are all initialized to 0. I then increment the
first counter until it has reached the maximum. I then start
incrementing the second etc. To get the total count I add the value of
all the counters.
For the gray conversion I have not found a method that does not imply
a loop. One can probably use some sort of lookup table based
algorithm if the loop construct is a problem.
Regards
Anton Erasmus
.
- References:
- Saving data in CPU on-chip EEPROM
- From: yossi_sr
- Re: Saving data in CPU on-chip EEPROM
- From: Anton Erasmus
- Re: Saving data in CPU on-chip EEPROM
- From: Jonathan Kirwan
- Saving data in CPU on-chip EEPROM
- Prev by Date: Re: Saving data in CPU on-chip EEPROM
- Next by Date: Re: RS485 is bidirectional does it mean it is fullduplex?
- Previous by thread: Re: Saving data in CPU on-chip EEPROM
- Next by thread: Re: Saving data in CPU on-chip EEPROM
- Index(es):
Relevant Pages
|
|