Glitch in RTC high-resolution/wake-up timer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Glitch in RTC high-resolution/wake-up timer

跳至解决方案
1,142 次查看
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 项奖励
回复
1 解答
1,118 次查看
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 项奖励
回复
3 回复数
1,136 次查看
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 项奖励
回复
1,119 次查看
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 项奖励
回复
1,102 次查看
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 项奖励
回复