Glitch in RTC high-resolution/wake-up timer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Glitch in RTC high-resolution/wake-up timer

Jump to solution
659 Views
yo_ku_
Contributor II

I am developing LPC540xxx project that uses the RTC high-resolution/wake-up timer (1kHz) as a tick.

This program often shows an abnormal value in the wake-up register. I found a description of another 1Hz RTC counter register having a glitch. There is no description about glitches in the 1kHz register, but I put the same deglitch code in RTC_GetWakeupCount() of the fsl_rtc driver as in RTC_GetSecondsTimerCount(), and it seems to work.


It seems that RTC_GetWakeupCount() needs to be modified.

0 Kudos
Reply
1 Solution
635 Views
yo_ku_
Contributor II

Hi ,XiangJun Rong

My "glitch" is not a glitch in the clock waveform. It is that I get an abnormal value when I access an out-of-sync register on the bus.
The code is as follows, It gets the register value twice, just like RTC_GetSecondsTimerCount().

 

static inline uint16_t RTC_GetWakeupCount(RTC_Type *base)
{
uint32_t a, b;

/* Follow the RF document to read the RTC default seconds timer (1HZ) counter value. */
do
{
a = base->WAKE;
b = base->WAKE;
} while (a != b);

return (uint16_t)((b & RTC_WAKE_VAL_MASK) >> RTC_WAKE_VAL_SHIFT);
}

 

B.R. 

 

View solution in original post

0 Kudos
Reply
3 Replies
653 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Yosuke,

As far as I know that the 1KHz RTC high resolution RTC counter driving clock  is an internal clock signal, there is not any external pad, how did you  deglitch the 1kHz signal?

Can you share the code of RTC_GetWakeupCount()  api function so that we can have a review?

Thanks

BR

XiangJun Rong

0 Kudos
Reply
636 Views
yo_ku_
Contributor II

Hi ,XiangJun Rong

My "glitch" is not a glitch in the clock waveform. It is that I get an abnormal value when I access an out-of-sync register on the bus.
The code is as follows, It gets the register value twice, just like RTC_GetSecondsTimerCount().

 

static inline uint16_t RTC_GetWakeupCount(RTC_Type *base)
{
uint32_t a, b;

/* Follow the RF document to read the RTC default seconds timer (1HZ) counter value. */
do
{
a = base->WAKE;
b = base->WAKE;
} while (a != b);

return (uint16_t)((b & RTC_WAKE_VAL_MASK) >> RTC_WAKE_VAL_SHIFT);
}

 

B.R. 

 

0 Kudos
Reply
619 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Yosuke,

As you know that reading the base->WAKE; register is faster than counting the base->WAKE; register, so it is difficult to meet the condition while (a != b);

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply