Electronic – CRC generator polynomial for data flash memory storage

crcflashmicrocontroller

I have been facing a problem how to implement embedded software configuration parameters management system. It means how to implement a software module which will be responsible for storage of for example PI controller gains or some compare levels of protections into the external flash memory and retrieving them from the external flash memory. One of the questions regarding this problem is what generator polynomial I should use for CRC calculation. The parameters will be without exception 16 bits values. Is the CRC16 polynomial i.e. \$x^{16} + x^{15} + x^{2} + 1\$ good choice for that? Thanks for any ideas.

Best Answer

The size/type of the data and the size of the CRC word really have nothing at all to do with each other. When calculating the CRC, you serialize the data (turn it into a stream of bits or bytes) anyway.

A larger CRC is better at detecting a larger class of errors, especially multibit errors. But of course, it requires more memory to store larger CRCs. Considerations like this should be driving your decision.

You also need to think about when and how the data changes, and what you need to go through in order to update the CRC when that happens. In an embedded system, you also need to think about what happens if any of the steps in the process get interrupted — for example, by an unexpected loss of power.

If you can add more details about your specific application to your question, I can write a more specific answer.