STM32F103CBT6 Some Variable Written into Flash are Getting Lost

Hi,

I have a strange problem. I have a program where I receive some variables via Bluetooth and write them to Flash for later use. I’m on the Mbed platform, but I use custom low-level code to write to Flash. All of my variables are the same in the structure of reading and writing. They only differ in an address.

I can see that the Bluetooth section works, and all of the variables get stored in the RAM. However, when I restart the board and read the variables from the Flash, some of the variables are not set and are defaulted to 0. Stranger than that, when I change the starting address of Flash, sometimes I’m able to write some variables only for one time. It will work the first time, but the value sticks, and it resets back to this value every time I restart the board, no matter what I write on it later.

Do you have any idea how this might happen?

Thanks!

Hard to say without seeing any of the code. Can you upload a minimal project that reproduces the problem to Github?