mirror of https://github.com/ARMmbed/mbed-os.git
K64F lp ticker driver - calculation bug fix.
Delta calculation from lp_ticker_set_interrupt() function: delta_us = timestamp > now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us); Lets assume that timestam == now_us. Expected delta value should be 0 and in this current version is 0xFFFFFFFF. The following condition: timestamp > now_us should have the following form: timestamp >= now_us Additionally modified us ticker driver to provide the same logic.pull/6201/head
parent
ac196f1ea2
commit
eb4a7bcc40
|
@ -83,10 +83,15 @@ void us_ticker_clear_interrupt(void)
|
||||||
|
|
||||||
void us_ticker_set_interrupt(timestamp_t timestamp)
|
void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
{
|
{
|
||||||
|
uint32_t now_us, delta_us;
|
||||||
|
|
||||||
|
now_us = us_ticker_read();
|
||||||
|
delta_us = timestamp >= now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us);
|
||||||
|
|
||||||
uint32_t delta = timestamp - us_ticker_read();
|
uint32_t delta = timestamp - us_ticker_read();
|
||||||
PIT_StopTimer(PIT, kPIT_Chnl_3);
|
PIT_StopTimer(PIT, kPIT_Chnl_3);
|
||||||
PIT_StopTimer(PIT, kPIT_Chnl_2);
|
PIT_StopTimer(PIT, kPIT_Chnl_2);
|
||||||
PIT_SetTimerPeriod(PIT, kPIT_Chnl_3, (uint32_t)delta);
|
PIT_SetTimerPeriod(PIT, kPIT_Chnl_3, (uint32_t)delta_us);
|
||||||
PIT_EnableInterrupts(PIT, kPIT_Chnl_3, kPIT_TimerInterruptEnable);
|
PIT_EnableInterrupts(PIT, kPIT_Chnl_3, kPIT_TimerInterruptEnable);
|
||||||
PIT_StartTimer(PIT, kPIT_Chnl_3);
|
PIT_StartTimer(PIT, kPIT_Chnl_3);
|
||||||
PIT_StartTimer(PIT, kPIT_Chnl_2);
|
PIT_StartTimer(PIT, kPIT_Chnl_2);
|
||||||
|
|
|
@ -135,7 +135,7 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
|
||||||
|
|
||||||
lptmr_schedule = 0;
|
lptmr_schedule = 0;
|
||||||
now_us = lp_ticker_read();
|
now_us = lp_ticker_read();
|
||||||
delta_us = timestamp > now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us);
|
delta_us = timestamp >= now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us);
|
||||||
|
|
||||||
/* Checking if LPTRM can handle this sleep */
|
/* Checking if LPTRM can handle this sleep */
|
||||||
delta_ticks = USEC_TO_COUNT(delta_us, CLOCK_GetFreq(kCLOCK_Er32kClk));
|
delta_ticks = USEC_TO_COUNT(delta_us, CLOCK_GetFreq(kCLOCK_Er32kClk));
|
||||||
|
|
Loading…
Reference in New Issue