I recently posted some thoughts about handling non-volatile RAM - dealing with the recognition of memory that had not been initialized. I was very pleased to hear from a reader, Bert Böhne in the Netherlands, who has some experience in this matter:
“In a current project we do the same. We have some non-volatile memory for settings. After each set of data we also defined one byte for a crc. When we write a set of data, we calculate the crc and write it to the memory. Each time when read a set of data we also calculate the crc. Then we check if the calculated crc is the same as crc which is read back. When the board comes from the fabric the memory data is 0×00 on each address. The calculation of the crc will then return 0×00. This would cause a match of calculated and read back crc. To overcome this, we added an offset to the crc calculation. By doing this we now that we already wrote a set of data, and that the data is correct.”
This is a very simple and elegant solution to the problem. My approach of using a signature enabled the state of the RAM to be determined very quickly [by interrogating a 32 bit value], without having to do an checksum or CRC calculation. I am just wondering whether in this case they can just check that the CRC is non-zero to see that the RAM is not initialized?