mirror of https://github.com/ARMmbed/mbed-os.git
[NANO130] Fix LP_TICKER and RTC sometimes test fail issue
parent
a96bea8631
commit
ac9f59fda5
|
@ -31,7 +31,6 @@
|
||||||
#define TMR2_CLK_PER_SEC (__LXT)
|
#define TMR2_CLK_PER_SEC (__LXT)
|
||||||
#define TMR2_CLK_PER_TMR2_INT ((uint32_t) ((uint64_t) US_PER_TMR2_INT * TMR2_CLK_PER_SEC / US_PER_SEC))
|
#define TMR2_CLK_PER_TMR2_INT ((uint32_t) ((uint64_t) US_PER_TMR2_INT * TMR2_CLK_PER_SEC / US_PER_SEC))
|
||||||
#define TMR3_CLK_PER_SEC (__LXT)
|
#define TMR3_CLK_PER_SEC (__LXT)
|
||||||
#define LXT_DELAY (42000000 / __LXT)
|
|
||||||
|
|
||||||
void TMR2_IRQHandler(void);
|
void TMR2_IRQHandler(void);
|
||||||
void TMR3_IRQHandler(void);
|
void TMR3_IRQHandler(void);
|
||||||
|
@ -99,8 +98,8 @@ void lp_ticker_init(void)
|
||||||
// NOTE: TIMER_Start() first and then lp_ticker_set_interrupt(); otherwise, we may get stuck in lp_ticker_read() because
|
// NOTE: TIMER_Start() first and then lp_ticker_set_interrupt(); otherwise, we may get stuck in lp_ticker_read() because
|
||||||
// timer is not running.
|
// timer is not running.
|
||||||
|
|
||||||
// wait previous CTL action is finish
|
// Wait 3 cycles of engine clock to ensure previous CTL write action is finish
|
||||||
nu_nop(LXT_DELAY);
|
nu_nop(SystemCoreClock / __LXT * 3);
|
||||||
// Start timer
|
// Start timer
|
||||||
TIMER_Start((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
|
TIMER_Start((TIMER_T *) NU_MODBASE(timer2_modinit.modname));
|
||||||
|
|
||||||
|
@ -220,8 +219,8 @@ static void lp_ticker_arm_cd(void)
|
||||||
uint32_t ctl_timer3 = timer3_base->CTL;
|
uint32_t ctl_timer3 = timer3_base->CTL;
|
||||||
ctl_timer3 &= ~TIMER_CTL_MODE_SEL_Msk;
|
ctl_timer3 &= ~TIMER_CTL_MODE_SEL_Msk;
|
||||||
ctl_timer3 |= TIMER_ONESHOT_MODE;
|
ctl_timer3 |= TIMER_ONESHOT_MODE;
|
||||||
// wait previous CTL action is finish
|
// Wait 3 cycles of engine clock to ensure previous CTL write action is finish
|
||||||
nu_nop(LXT_DELAY);
|
nu_nop(SystemCoreClock / __LXT * 3);
|
||||||
timer3_base->CTL = ctl_timer3;
|
timer3_base->CTL = ctl_timer3;
|
||||||
timer3_base->PRECNT = prescale_timer3;
|
timer3_base->PRECNT = prescale_timer3;
|
||||||
|
|
||||||
|
@ -231,8 +230,8 @@ static void lp_ticker_arm_cd(void)
|
||||||
|
|
||||||
TIMER_EnableInt(timer3_base);
|
TIMER_EnableInt(timer3_base);
|
||||||
TIMER_EnableWakeup((TIMER_T *) NU_MODBASE(timer3_modinit.modname));
|
TIMER_EnableWakeup((TIMER_T *) NU_MODBASE(timer3_modinit.modname));
|
||||||
// wait previous CTL action is finish
|
// Wait 3 cycles of engine clock to ensure previous CTL write action is finish
|
||||||
nu_nop(LXT_DELAY);
|
nu_nop(SystemCoreClock / __LXT * 3);
|
||||||
TIMER_Start(timer3_base);
|
TIMER_Start(timer3_base);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "nu_miscutil.h"
|
#include "nu_miscutil.h"
|
||||||
|
|
||||||
#define YEAR0 1900
|
#define YEAR0 1900
|
||||||
#define LXT_DELAY (42000000 / __LXT)
|
|
||||||
|
|
||||||
static int rtc_inited = 0;
|
static int rtc_inited = 0;
|
||||||
|
|
||||||
|
@ -114,8 +113,8 @@ void rtc_write(time_t t)
|
||||||
rtc_datetime.u32TimeScale = RTC_CLOCK_24;
|
rtc_datetime.u32TimeScale = RTC_CLOCK_24;
|
||||||
|
|
||||||
RTC_SetDateAndTime(&rtc_datetime);
|
RTC_SetDateAndTime(&rtc_datetime);
|
||||||
// wait this RTC write is active
|
// Wait 3 cycles of engine clock to ensure this RTC write is active
|
||||||
nu_nop(LXT_DELAY);
|
nu_nop(SystemCoreClock / __LXT * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue