你好!
我现在在用TI的LM4F230H5QR(以前旧的型号),这个IC内部自带RTC,我现在用外部晶振32.768KHz,我不用M4的休眠功能,只是想用它的RTC功能,而RTC的配置如下:
void Rtc_Init(void)
{
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE); //使能RTC模块
HibernateClockSelect(HIBERNATE_CLOCK_SEL_RAW); // 时钟选择32.768KHz
HibernateRTCEnable(); // 启动RTC
}
而RTC的读取如下:
void AppRtcTask(void *parg)
{
struct tm *current_timer_point = ¤t_timer;
U8 err;
time_t timer_seconds,backupt_seconds;
while(1)
{
timer_seconds = HibernateRTCGet(); // 读取RTC的秒
current_timer_point = localtime(&timer_seconds); // get the timer_seconds --->year,month,second
current_timer = *current_timer_point;
OSTimeDly(100); // delay 200ms;
}
}
我目前的问题是:经过试验,RTC运行10分钟的时候,大概快了8秒(同电脑的时间比较),我用的晶振用示波器看了,时钟没问题,而且,我也有换过其它品牌的晶振,问题依旧。
我想是不是时钟源设定不对?但是我也有尝试时钟源设定为:HibernateClockSelect(HIBERNATE_CLOCK_SEL_DIV128);但是仍旧快了。