Skip to main content
DavePfz
Senior
Oct 29, 2026 6:06 PM UTC
Question

Writing to backup registers causes problems with the wake-up timer.

Here’s the situation. The system is built on the STM32WB5MM with basic code written using FreeRTOS. All works well, so now I add the BLE HeartRate application. If I prevent my code from running using a while (1) [ osDelay(10); } loop, the STM BLE Toolbox on my Android phone works fine displaying data. However, if I allow my code to run, the Toolbox connects, but no data is displayed. Pursuing this in my code, I determined that the wake-up interrupts were not occurring as they should.

By moving where I stop my code, I have narrowed it down to the following sequence:

HAL_PWR_EnableBkUpAccess();

HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR19, Value);

HAL_PWR_DisableBkUpAccess();

If I simply comment out the last line allowing backup access to remain on. It also works. However, that leaves the backup registers vulnerable. (Note: I use this sequence frequently to protect data that must be retained through a power cycle. VBAT is provided by a coin cell. So, a general solution is preferable.)

This is the first I’ve worked with the wake-up timer. In researching this problem, I have not been able to determine that the “standard” code supporting the wake-up timers would pose any conflict like this.

Can anyone point me in any particular direction?