2022-02-01 08:49 AM
Hello
I've managed to get the 'FLASH_EraseProgram' example program for the Nucleo-F413ZH that comes with 'STM32Cube_FW_F4_V1.25.0' working on a Nucleo-F413ZH board.
It erases sectors 2 to 15 and fills them with data - i.e. 0x78563412 that shows up repeatedly as '12 34 56 78 12 34 56 78 12 34 56 78...' in all the sectors.
However, when I try to use 'HAL_FLASH_Program()' to add a single 32 bit number to the first 4 bytes of sector 15 (starting at address 0x08160000), it does not show up correctly. For example:
// Value Expecting Shows up in
// to be added in memory memory as
0x00000000 00 00 00 00 00 00 00 00
0x00000001 01 00 00 00 00 00 00 00
0x00000011 11 00 00 00 10 00 00 00
0x00000111 11 01 00 00 10 00 00 00
0x00001111 11 11 00 00 10 10 00 00
0x00011111 11 11 01 00 10 10 00 00
0x00111111 11 11 11 00 10 10 10 00
0x01111111 11 11 11 01 10 10 10 00
0x11111111 11 11 11 11 10 10 10 10
34 22 00 00 00 02 00 00 00
Considering that the padding works okay can anyone suggest what I'm doing incorrectly, please?
I'm using a Nucleo-F413ZH, MDK-ARM version 5, ARM version 5 and a ST-LINK V2 debugger.
The code (main.c and main.h) are attached.
Thanks.
Ron
2022-02-01 09:12 AM
You don't get multiple bites of the apple. You can write each flash line ONCE after ERASURE
2022-02-01 09:42 AM
Or better is say you can only reprogram bits with HIGH state to zero, then after progr 0x78563412
you can only AND with this value.example
0x00011111 11 11 01 00 10 10 00 00
12 34 56 78 & = 10 10 00 00
2022-02-02 12:48 AM
Thanks, @Community member . That makes everything clear
2022-02-02 12:50 AM
Thanks, @MM..1 . Good to know what is happening