cancel
Showing results for 
Search instead for 
Did you mean: 

How to erase rtc backup register with cube programmer

isikli
Associate III

Could I erase rtc backup registers with STM32CubeProgrammer ?

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
waclawek.jan
Super User

... and, to be able to write into PWR registers, you have to set RCC_APB1ENR.PWREN first... :)

JW

View solution in original post

6 REPLIES 6
Peter BENSCH
ST Employee

Yes, it is possible, but not via the standard mass erase in STM32CubeProgrammer.

For STM32L010/L07x/L08x you have two practical options:

  1. Directly in STM32CubeProgrammer
    • Connect in Hotplug/Halt mode
    • Open Registers → RTC
    • Manually write 0x00000000 (or any value) to BKP0R, BKP1R, etc., then Apply.
  2. Via firmware (backup‑domain reset)

Program and run the following HAL code once; this clears all RTC backup registers:

__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_BACKUPRESET_FORCE();
__HAL_RCC_BACKUPRESET_RELEASE();
HAL_PWR_DisableBkUpAccess();

Only if both VDD and VBAT are completely removed will the backup registers be lost automatically.

Does that answer your question?

Regards
/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

I try your suggestion via cubeprogrammer but I can't delete rtc bkp register. Please, check my video.

waclawek.jan
Super User

I don't use CubeProgrammer, but I believe you still need to enable the backup-domain access by setting PWR_CR.DBP before trying to overwrite the backup registers.

JW

I try that PWR_CR.DBP register set firstly, still I can't delete. I guess I can't write to register via cubeprogrammer.

waclawek.jan
Super User

... and, to be able to write into PWR registers, you have to set RCC_APB1ENR.PWREN first... :)

JW

Thank you, That is worked.