Skip to content

Commit 34b54c9

Browse files
FRASTMfpistm
authored andcommitted
timer RTC setting Alarm with more than 32-bit subseconds
When the SubSecond parameter variable is bigger than 32bits, setting the Alarm is still possible calling the RTC_StartAlarm64 function Signed-off-by: F. Ramu <[email protected]>
1 parent 192c123 commit 34b54c9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/BSP/timer_if.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
237237
TIMER_IF_DBG_PRINTF("Start timer: time=%d, alarm=%d\n\r", GetTimerTicks(), timeout);
238238

239239
/* Program ALARM B on timeout ticks converted in ms (one more for uncertainty, mask is 31 */
240-
RTC_StartAlarm(RTC_ALARM_B, 0, 0, 0, 0, (timeout * 1000 / MS_TO_TICK + 1), RTC_HOURFORMAT12_PM, 31UL);
240+
uint64_t subSeconds64 = ((uint64_t)((uint64_t)timeout * (uint64_t)(1000))) / MS_TO_TICK + 1;
241+
RTC_StartAlarm64(RTC_ALARM_B, 0, 0, 0, 0, subSeconds64, RTC_HOURFORMAT12_PM, 31UL);
241242

242243
/* USER CODE BEGIN TIMER_IF_StartTimer_Last */
243244

0 commit comments

Comments
 (0)