cancel
Showing results for 
Search instead for 
Did you mean: 

UTIL_TIMER_Create with RTC in mixed binary & bcd mode

SLevi.1
Senior

My BLE project on stm32wba65 makes use of "UTIL_TIMER_Create" to set a callback. This works ok when the RTC is configured just as free running binary. If I set the rtc mode to mixed binary & bcd, the callback never gets fired. I'm using an LSE to drive the rtc.

Why is this?

I'm trying to base a project off the BLE_Heartrate example. I need the calendar time & date so I can timestamp data. I synch the time over the BLE from a PC.

I suppose I could just use the ms ticks since boot, but how does this survive a reset (but not power outage)? Is the binary counter derived from the rtc sufficiently large enough to hold a date for a year or more?

Any examples using binary RTC and external time synch would be most welcome.

1 REPLY 1
_Joe_
ST Employee

Hi,
On STM32WBA, it is possible to use both the RTC calendar and the BLE UTIL_Timer by separating the alarms:

  • Alarm A is reserved for the timer server (UTIL_Timer / BLE stack).
  • Alarm B is used for the calendar functions.

This requires adapting MX_RTC_Init() and TIMER_IF_StartTimer() so that Alarm B is configured and used for calendar operations, while Alarm A remains fully masked (AlarmMask = RTC_ALARMMASK_ALL) for the timer server.
In mixed mode (calendar enabled), you must initialize a valid weekday for the alarm, otherwise the current assert in the RTC code will trigger.

If needed, I am attaching 2 files containing the changes with which we can achieve this.

BR, Joé