Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CRC 8 to verify data consistency in EEPROM and strategies to minimize the number of writes to EEPROM?

Not open for further replies.


Full Member level 4
Oct 9, 2010
Reaction score
Trophy points
Activity points
I want to use I2C EEPROM to store information such as engine hours and pneumatic valve actuation counts,
In connection with this, they have to solve two questions

1. Data Consistency Verification
The EEPROM used has a page size of 16 bytes. The data has 14 bytes, leave one in reserve and put CRC8 on the last one
When I look at the wiki, I see 9 different polynomials used for different versions of CRC8. It doesn't matter which one I use for the given purpose, but if I can choose, can one be marked as the most suitable for the given purpose?
When I was doing great work with CRC many years ago. I used the crc utility, which was able to enter the parameters of the ordered CRC and was able to generate the source code in C for the CRC calculation, it was able to calculate and verify the CRC. It was a Win32 console application. Now I can't find it on the internet. Can you advise?

2. Microchip states eeprom lifetime 1M writes, ST 4M . In any case, I don't want to do that, the EEPROM lasts for 10 years and then I don't care.
My mind
The MCU is powered by 24V voltage to control the valves.
The MCU monitors the voltage at 24V, if it drops below 18V it considers it a power loss, turns off all valves and writes the states of the counters into the EEPROM with an overview, it should be able to do this within 10ms, after which the capacitors in the 24V/5V converter and the LDO should provide energy for the MCU 3.3V
The states of the counters will be written to the EEPROM on a jumper in two pages, and if the CRC does not match, the older version of the writing will always be.
Any better idea?


CRC: there are plenty of code examples available. Usually the microcontroller manufacturer provides this. Check their web site.

simple live expectance calculations.
let's say 20 years for 1 million writes:
So you have 20 x 365 x 24 hours = 180k hours
Thus you may do more than 5 writes per hour, or one write 11 minutes.
If you want to do a write every 1 minute you need 11 "sequential" bytes.

your way:
let´s say your application is controlled by a timer that is 2 x ON and 2 x OFF per day.
So 2 writes per day. or 500k days or 1300 years.

Only you can know what makes more sense. Maybe your application is switched ON/OFF every minute or once a year...

Also only you know what microcontroller, what power supply, what EEPROM you want to use. If you need detailed help: tell us.

My recommendation: Use a hardware comparator to check power supply voltage, also use comparator to immediately switch OFF power consuming devices (valves...). Also use it as interrupt input to your microcontroller.

The MCU is powered by 24V voltage to control the valves.
I´ve never seen 24V powered MCU to directly control valves.
I rather expect the PCB/application is powerd by 24V, then the microcontroller is powered by 3.3V via regulator and the valves are controlled via 3.3V level signals and MOSFETS or other power switches. Either high side or low side...

If you need help with this, please provide a draft or schematic.


You can always do wear leveling to enhance application lifetime (and if not using all the
flash add unused portions of that for use as well) :

Regards, Dana.

Yes, 24V is the supply voltage of the machine. From it, a DC/DC converter produces 5V for the sensors, from it, using an LDO, 3.3V for the MCU
The service life of an air valve is typically 1M cycle, then it must be replaced and the valve will reach this number in 3 to 8 years.
This is the reason why we want to record the cycles of each valve
Unfortunately, it is not as simple as you state with the lifetime of the eeprom.
1 million entries applies to a temperature of 25 C, decreases with increasing temperature, but also with radiation, etc. I have sw from the memory manufacturer to calculate the lifetime under the given conditions and with 1000 records per day, the lifetime is under 5 years. I use CRC, records cannot be split into multiple bytes, only pages, and that has other disadvantages.
FRAMs would be a good idea, but the price and, above all, the lack of manufacturers are a problem.(not an industry standard)


records cannot be split into multiple bytes

This is impossible. You can´t do with one EEPROM byte. So you have to use multiple bytes.

Why CRC?
Yes, I know: to validate the content.
But then you need to decide what to do in the case of "not valid":
* stop the machine?
* start with zero?
* replace the valves?
* ?

I´d go for an error proof solution:
(avoid to write 1000 data per day to the EEPROM)

How often do you expect the system to boot (power down ...)?
You could use one grey coded 2-byte-pair as livetime counter per valve.
Write only the byte that changes. So when going 0 to 65535 ech byte is written 32768 times.
Well within it´s life expectancy.
If you have a 0..15 counter in RAM and write only every 16´th event to the EEPROM you count up to 1 M valve cycles.
With every valve replacement use another EEPROM byte pair.

But all this is not new. There exist several strategies. No need to reinvent the wheel.


Just Google "wear level calculations eeprom" & "wear level calculations FLASH",
you can get a significant multiplier in endurance.

Regards, Dana.

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to