AnsweredAssumed Answered

STM32F4xx Flash & CRC

Question asked by anderson.todd on Aug 21, 2015
Latest reply on Aug 28, 2015 by Clive One
We want to store some calculated values into flash, and from what I am seeing, to do that, you need to stay away from flash sector 0, because it holds the flash vector table. So, I am using sector 1 and sector 2 to store exactly the same calculated values. 

To do development work, I have 
 1. Created data similar to what will be stored.
 2. Enabled CRC clock.
 3. Set up a pointer to the data.
 4. Reset CRC.
 5. Using "calculate block" function, calculated the CRC-32 of the data.
 6. Unlocked flash.
 7. Initialized flash registers by clearing "pending flags."
 8. Specified start and end addresses of flash sectors #1 & #2.
 9. Erased the flash using "sector erase."
10. Programmed the flash 32-bits at a time using a for-loop (a little more than 200 values).
11. Programmed the calculated CRC value into flash.
12. Locked the flash.
13. Read back the flash contents into a separate "FlashData" buffer.
14. Calculated the CRC of the "FlashData"contents.
15. Compared the "FlashData" CRC with the CRC stored into flash. They were equal!

Some comments:
We are using Atollic TrueSTUDIO.
It did not have a CRC example in the library, so I did find one using web search.
That CRC example was almost complete - the only thing missing was the CRC-reset.

I did try to work with the EEPROM emulation code, but it did not work in my environment - at one point, the Discovery board hung, and about the only way out was to exit the IDE and power cycle the board. After awhile, I stopped trying to get it to work.

Any, all comments appreciated - there is more work to do before I put this into product code...

Todd Anderson