Skip to content

Commit 1566395

Browse files
Merge pull request #5347 from 0xc0170/nxp_fix_lptimer
MCUXpresso: Fix LPTimer issue when using multiple timeout objects
2 parents 2a80231 + bc5c945 commit 1566395

File tree

1 file changed

+10
-0
lines changed
  • targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api

1 file changed

+10
-0
lines changed

targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/api/lp_ticker.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
139139

140140
/* Checking if LPTRM can handle this sleep */
141141
delta_ticks = USEC_TO_COUNT(delta_us, CLOCK_GetFreq(kCLOCK_Er32kClk));
142+
if (delta_ticks == 0) {
143+
/* The requested delay is less than the minimum resolution of this counter */
144+
delta_ticks = 1;
145+
}
146+
142147
if (delta_ticks > MAX_LPTMR_SLEEP) {
143148
/* Using RTC if wait time is over 16b (2s @32kHz) */
144149
uint32_t delta_sec;
@@ -154,6 +159,11 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
154159
/* Set aditional, subsecond, sleep time */
155160
if (delta_us) {
156161
lptmr_schedule = USEC_TO_COUNT(delta_us, CLOCK_GetFreq(kCLOCK_Er32kClk));
162+
if (lptmr_schedule == 0) {
163+
/* The requested delay is less than the minimum resolution of this counter */
164+
lptmr_schedule = 1;
165+
}
166+
157167
}
158168
} else {
159169
/* Below RTC resolution using LPTMR */

0 commit comments

Comments
 (0)