2021-01-28 06:07 AM
Hi all,
I have a STM32G474 and data in backup registers (eg. LL_RTC_BKP_DR0) are cleared after reset or power cycle (3.3 V battery is present!).
Code is generated by CubeMX with LL drivers. I enabled RTC and disabled all tampers.
In the main code, I can write to the registers (and readback or check via debugger/SFR view).
However, if I restart the debugger, press the reset button (with or without debugger connected) or switch of VCC (with VBAT present from a CR2032 battery), backup registers are all 0.
As I understand it, this could be caused by a RTC domain reset or a tamper event. I have neither, as far as I can tell. What could be wrong? Is there an example for this?
Regards, Martin
2021-01-28 06:16 AM
> As I understand it, this could be caused by a RTC domain reset [....] I have neither,
But you've said:
> Code is generated by CubeMX with LL drivers.
So, isn't there a RTC domain reset in the generated code?
In debugger, try to place a data breakpoint on the respective register in RCC through which the RTC domain is reset.
JW
2021-01-28 07:51 AM
Nice idea... tried to put an SWV trace on the BKP_DR0 register (0x40002500), but this does not work. Setting a data trace comparator to an SRAM variable works though.
However, you have a good point. I stepped through the init and the generated SystemClock_config contains
LL_PWR_EnableBkUpAccess();
LL_RCC_ForceBackupDomainReset();
LL_RCC_ReleaseBackupDomainReset();
So here is the backup domain reset as you suspected.
Why would they do this? It's the whole point of the backup domain of preserving data... How can I turn this off? I have not found a setting for this in the code generator.
Of course I can delete the reset from the generated code, but each time I regenerate it via CubeMX, this gets overwritten.
Thanks! Martin
2021-01-28 08:00 AM
It seems I am not the only one falling into this trap:
A google search on "LL_RCC_ForceBackupDomainReset" finds other occurences.
It seems this is a CubeMX bug? Should I report this (where)?
2021-01-29 12:19 AM
Hi @Community member ,
This issue has been already detected and reported internally for fix. I'll keep you posted with the updates.
Sorry for the inconvenience.
Linked here the same problem with a workaround preposition. It may work for you.
Thanks for you patience.
Khouloud.
2021-01-30 04:12 AM
Thanks for the clarification! Let's hope this is fixed soon.
- Martin