在线时间445 小时
UID2011467
注册时间2013-5-17
NXP金币0
该用户从未签到
金牌会员
 
- 积分
- 5781
- 最后登录
- 1970-1-1
|
客户问题介绍:
· 芯片型号:MK60DN512ZVMD10
· 描述:在程序中,连续不断的读取RTC_TSR寄存器值,并将结果传给上位机,但发现连续读出的值出现前后不匹配的问题,从理论上分析,RTC_TSR寄存器内的值应该逐渐递增的,但从打印的输出结果看,存在个别前后不一致的现象(如图1所示),所以怀疑这是不是芯片的Bug呢?
#include
#include
#include "cmd_rtcdebug.h"
#include "common.h"
extern "C"
{
#include "wdog.h"
}
extern "C"
int cmd_rtcdebug(const char *args)
{
uint32_t lowestValue;
uint32_t lastFailValue = 0;
uint32_t failCountInRow = 0;
int wdCount = 0;
lowestValue = RTC_TSR;
printf("press any key to exit\r\n");
while(1)
{
uint32_t nextValue = RTC_TSR;
if (uart_kbhit())
{
break;
}
if (nextValue < lowestValue)
{
if (lastFailValue != nextValue)
{
printf("RTC fail: lowest value: %u, next value: %u\r\n", lowestValue, nextValue);
}
lastFailValue = nextValue;
failCountInRow++;
}
else if (nextValue == lowestValue)
{
if (failCountInRow)
{
printf("RTC fails in row: %u\r\n", failCountInRow);
failCountInRow = 0;
}
}
else if (nextValue > lowestValue)
{
if (failCountInRow)
{
printf("RTC fails in row: %u\r\n", failCountInRow);
failCountInRow = 0;
}
if (wdCount > 300)
{
wdog_refresh();
wdCount = 0;
}
wdCount++;
printf("RTC_TSR: %u\r\n", nextValue);
lowestValue = nextValue;
}
}
return 0;
}
| 针对第一个猜测,在查阅Errata文档后,大致可以排除;至于第二个猜测,我应对的方法是在每次读取RTC_TSR寄存器之前,添加一个延时函数,经过一段时间的测试后,发现出错的频率虽然没有原来那么多,但还是会出现,看来这是个治标不本的方法啊,只能另想方法啊。
各位网友有没有好的想法,欢迎来讨论!
|
|