Skip to content

Commit 01ff7ba

Browse files
jdascenziocarlescufi
authored andcommitted
driver: timer: stm32_lptim: fix deadlock when waiting ARROK flag
If ticks is K_TICKS_FOREVER the register autoreload isn't set. So, on the next call to the z_clock_set_timeout function the wait for the flag ARROK will be infinite. Signed-off-by: Julien D'Ascenzio <[email protected]>
1 parent ea7140b commit 01ff7ba

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/timer/stm32_lptim_timer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,6 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
183183
return;
184184
}
185185

186-
/* ARROK bit validates previous write operation to ARR register */
187-
while (LL_LPTIM_IsActiveFlag_ARROK(LPTIM1) == 0) {
188-
}
189-
LL_LPTIM_ClearFlag_ARROK(LPTIM1);
190-
191186
if (ticks == K_TICKS_FOREVER) {
192187
/* disable LPTIM */
193188
LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_LPTIM1);
@@ -242,6 +237,12 @@ void z_clock_set_timeout(s32_t ticks, bool idle)
242237
NVIC_SetPendingIRQ(LPTIM1_IRQn);
243238
lptim_fired = 1;
244239
}
240+
241+
/* ARROK bit validates previous write operation to ARR register */
242+
while (LL_LPTIM_IsActiveFlag_ARROK(LPTIM1) == 0) {
243+
}
244+
LL_LPTIM_ClearFlag_ARROK(LPTIM1);
245+
245246
/* run timer and wait for the reload match */
246247
LL_LPTIM_SetAutoReload(LPTIM1, next_arr);
247248

0 commit comments

Comments
 (0)