Skip to content

Commit a6a2ecf

Browse files
ccli8adbridge
authored andcommitted
Fix stuck in lp_ticker_init()
1 parent e50c7af commit a6a2ecf

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,14 @@ void lp_ticker_init(void)
9595
TIMER_EnableInt((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
9696
TIMER_EnableWakeup((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
9797

98-
// Schedule wakeup to match semantics of lp_ticker_get_compare_match()
99-
lp_ticker_set_interrupt(wakeup_tick);
98+
// NOTE: TIMER_Start() first and then lp_ticker_set_interrupt(); otherwise, we may get stuck in lp_ticker_read() because
99+
// timer is not running.
100100

101101
// Start timer
102102
TIMER_Start((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
103+
104+
// Schedule wakeup to match semantics of lp_ticker_get_compare_match()
105+
lp_ticker_set_interrupt(wakeup_tick);
103106
}
104107

105108
timestamp_t lp_ticker_read()

targets/TARGET_NUVOTON/TARGET_NUC472/lp_ticker.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,14 @@ void lp_ticker_init(void)
9494
TIMER_EnableInt((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
9595
TIMER_EnableWakeup((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
9696

97-
// Schedule wakeup to match semantics of lp_ticker_get_compare_match()
98-
lp_ticker_set_interrupt(wakeup_tick);
97+
// NOTE: TIMER_Start() first and then lp_ticker_set_interrupt(); otherwise, we may get stuck in lp_ticker_read() because
98+
// timer is not running.
9999

100100
// Start timer
101101
TIMER_Start((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
102+
103+
// Schedule wakeup to match semantics of lp_ticker_get_compare_match()
104+
lp_ticker_set_interrupt(wakeup_tick);
102105
}
103106

104107
timestamp_t lp_ticker_read()

0 commit comments

Comments
 (0)