cancel
Showing results for 
Search instead for 
Did you mean: 

Want to detect the number of times a switch value is used through stm32

zhaowhong
Associate III

Hi 

Because power-off protection is required, the times or variables need to be stored in flash。
Is my solution reasonable?

Create a space inside the flash to define variables, and read the data after powering on the computer. Then there is a problem with data accumulation , inside the my program the define variables be accumulated, because the data is stored inside the flash. Does the change of data require special processing? HAL_FLASH_Unlock()
How to define variables inside flash, please give a program example。

Thank you

 

10 REPLIES 10

@zhaowhong wrote:

How can we let the CPU know when the power is off? 


Have a feed from the power input to a GPIO; when the power fails the GPIO goes low (or whatever)