Flash erase error on STM32L151CB-A
I am trying to store configuration data in flash on the STM32L151CB-A using the HAL libraries. I reserved the last page in flash for this. However, I see that already at the beginning of main the OPTVERR bit is set. (FLASH->SR: 0x80C) I never programmed the options bytes myself but got the STML151CB-A preprogrammed (within the RAK811 LoRa chip).
When reading the option bytes I see:
0x1ff800000: SPRMOD and RDP: 0x0xff5500aa which looks ok.
0x1ff800004: USER : 0x000000000 looks strange to me. However, the OPTVERRUSER bit is not set!
The FLASH->OBR register reads 0x7800aa
The reference manual says that the error bits are cleared by writing 1. What does this mean?
Do I have to set the corresponding bit? I tried to write 0x800 to FLASH-SR but this has no effect.
What are the factory settings of the options bytes ?
I tried the same program on the STM32F103C8T6 where erasing and writing the flash works fine.
Thanks for your help
Uli
