2011-03-25 11:58 AM
I am new to all of this. I got the board from a classmate.
I am trying to store accelerometer data in the flash during an experiment. Then, retrieve it when I plug the board into the computer via the USB. I am struggling to completely understand the Flash Programming Manual and the Flash examples in Atollic.
1. What line(s) of code will write a specific number value from the accelerometer to the flash?
2. How do I have it write to the next slot (page?), since the code runs in a loop?
3. How would I retrieve the data?
Thank you
#flash2011-03-25 12:12 PM
Reading out via USB will be a challenge since that's connected to the ST-LINK device, not the STM32VL device.
The minimum granularity for writing is 16-bits, on even addresses. The memory needs to be erased to write to it. void Flash_WriteTest(u32 FlashAddr, u16 FlashWord) { FLASH_Status FLASHStatus; printf(''FLSH WriteTest %08X -> %08X %04X\n'', FlashAddr, *((DWORD *)FlashAddr), FlashWord); FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FLASHStatus = FLASH_ProgramHalfWord(FlashAddr, FlashWord); if (FLASHStatus != FLASH_COMPLETE) printf(''FLSH : ?? WriteTest %d\r\n'',FLASHStatus); printf(''FLSH WriteTest %08X %04X\n'',*((DWORD *)FlashAddr), FlashWord); }