Re: Saving data in CPU on-chip EEPROM



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

.



Relevant Pages

  • Re: Saving data in CPU on-chip EEPROM
    ... >Use Gray Code for the counters. ... increment taking place in that domain, ... The conversion back and forth is relatively easy, ...
    (comp.arch.embedded)
  • Re: Algorithms directly working on Gray code variables
    ... >> Gray counters is a regular topic on comp.arch.fpga, ... > redundant counters in gray code. ... - eg if you write counters to a rolling array, ...
    (comp.arch.embedded)
  • Re: Counter Glitches Question
    ... Where you run into problems is where signals get generated in one clock ... Gray code counters won't be of any help here. ... through the FPGA and goes into a DLL. ...
    (comp.lang.vhdl)
  • Re: How To program for an Accurate sub-second clock
    ... > Set the timer with elapse period much less then a second and increment ... > counters only when seconds value changnes. ... This is too inaccurate to work with. ...
    (microsoft.public.pocketpc.developer)
  • [PATCH] Light weight event counters V3
    ... The remaining counters in page_state after the zoned VM counter patch has ... We use a simple increment of per cpu variables. ...
    (Linux-Kernel)