cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030 corrupting program on last minute write

Hendrik1
Visitor

I have a STM32G030K8 processor that needs to write some stuff to memory as soon as it detects that it will be losing power - always a bad time but I have to do this.

Most of the time it seems to be doing this just fine but once in a while the processor gets corrupted.

Here is the problem though, I have write protected the code space and the only pages not write protected are two pages at the end of memory where I want to write the data to. During stable operation I erase these pages, so that at last minute I just have to write the data.

The problem is that the actual program gets corrupted in the write protected pages.

Does write protection only affect external writing or also internal writing? In other words, is it a possibility that the write instructions leave the entire memory vulnerable for corruption even though I am not altering the write protection on the pages with program code in?

3 REPLIES 3

Enable Brown-out reset in the Option bytes.

JW

How would that affect the problem of the actual code getting corrupted. After code corruption with the final write the controller is unable to execute the program anymore.

I mean, enable Brown-out reset in the Option bytes, when you first program the mcu.

It remains to be enabled, and upon power going down, holds the mcu in reset, preventing the programming hardware to fail, when supply voltage falls below the threshold where it stops working correctly.

JW