cancel
Showing results for 
Search instead for 
Did you mean: 

How to backup the registers'value of STM32L4 MCU if suddenly power outage?

atsen.1
Associate II

Any HW or SW solution?

1 ACCEPTED SOLUTION

Accepted Solutions
Danish1
Lead II

If you have backup-battery or supercapacitor connected to the VBat pin, then the RTC peripheral including its backup registers are retained. This gives you 32 registers, each of 32 bits, to store whatever you regard as important.

If that's not enough, you could write values to non-volatile storage, either in external EEPROM (or FRAM) or some of the FLASH in the stm32L4 (note the stm32 will freeze for a few milliseconds during flash-writing, and you will have to manage erasing of pages; ST have examples of EEPROM-emulation).

Unless your hardware can interrupt the cpu as power is dropping (but not so low that you don't have time to save the registers), you will need to update your stored values either as they change or periodically.

Hope this helps,

Danish

View solution in original post

1 REPLY 1
Danish1
Lead II

If you have backup-battery or supercapacitor connected to the VBat pin, then the RTC peripheral including its backup registers are retained. This gives you 32 registers, each of 32 bits, to store whatever you regard as important.

If that's not enough, you could write values to non-volatile storage, either in external EEPROM (or FRAM) or some of the FLASH in the stm32L4 (note the stm32 will freeze for a few milliseconds during flash-writing, and you will have to manage erasing of pages; ST have examples of EEPROM-emulation).

Unless your hardware can interrupt the cpu as power is dropping (but not so low that you don't have time to save the registers), you will need to update your stored values either as they change or periodically.

Hope this helps,

Danish