Skip to content

Commit a9c44a4

Browse files
committed
BSP timer_if start alarm with a timeout expressed in tick unit
The timeout is a nb of tick counter (1/256Hz) in mix mode and must be converted in ms to match the RTC_StartAlarm API (1 tick is 3.9ms)
1 parent bb2ad1e commit a9c44a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/BSP/timer_if.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
260260

261261
TIMER_IF_DBG_PRINTF("Start timer: time=%d, alarm=%d\n\r", GetTimerTicks(), timeout);
262262

263-
/* Program ALARM B on subsecond, mask is 32 (and fixed to RTC_ALARMMASK_ALL for calendar) */
264-
RTC_StartAlarm(RTC_ALARM_B, 0, 0, 0, 0, UINT32_MAX - timeout, RTC_HOURFORMAT12_PM, 31UL);
263+
/* Program ALARM B on timeout ticks converted in ms (one more for uncertainty, mask is 31 */
264+
RTC_StartAlarm(RTC_ALARM_B, 0, 0, 0, 0, (timeout * 1000 / MS_TO_TICK + 1), RTC_HOURFORMAT12_PM, 31UL);
265265

266266
/* USER CODE BEGIN TIMER_IF_StartTimer_Last */
267267

0 commit comments

Comments
 (0)