哪位大神帮看看V3S RTC这程序是否正确?为保时钟差这么大?(32768-32000)/32768->2.34%
/*
* This RTC count flow on sun8iw8 platform.
* 32.768KHz--- --- [32768 count] ---
* \/ \___[seconds reg]
* /\ /
* 32KHz --- --- [32000 count] ---
*
* We can calculate how much seconds missing, call sunxi_rtc_fixup.
*/
void sunxi_rtc_fixup(unsigned long long*org_time, unsigned long long *time)
{
unsigned long long delta;
unsigned long long t1, t2;
bool out;
if (!time)
return;
if (!org_time)
{
t1 = (unsigned long long)(V3S_RTC->GP_DATA[6]&(~0x80000000)) << 32; /*readl( base + SUNXI_GPDATA_REG(6))*/
t1 |= (unsigned long)V3S_RTC->GP_DATA[7]; /*readl( base + SUNXI_GPDATA_REG(7))*/
}
else
{
t1 = *org_time;
}
t2 = *time;
out = V3S_RTC->LOSC_CTRL & SUN6I_LOSC_CTRL_EXT_OSC; //if used external 32768Hz oscillator
delta = (t2 > t1) ? (t2 - t1) : (t1 - t2);
delta = (delta * (OSC_ORG - OSC_32K)) / OSC_ORG;
if (out)
*time -= delta;
else
*time += delta;
}
离线
RTC那个我改了半天驱动,也查了资料,估计是V3s的一个bug,开机后强制把晶振切到了24M分频出来的32000Hz。
现在我能想到的办法,每N秒钟把系统时间写入RTC
离线
找了半天,原来是 linux3.4里面的 rtc-sunxi.c 驱动,居然硬件上面还有 2033年千年虫,额滴神
/*
* Sorry, sunxi hardware max time is 2033 year.
*/
if( rtc_valid_tm(tm) || (tm->tm_year + 1900) > 2033) {
dev_err(dev, "Alarm time is invalid, tm->tm_year:%d\n", tm->tm_year);
if ((tm->tm_year + 1900) > 2033) {
printk(KERN_WARNING "The process is \"%s\" (pid %i)\n", current->comm, current->pid);
tm->tm_year = 132;
}
}
离线
2033这个和你RTC时钟不准 应该没关系吧!你这RTC是主时钟分频得到的还是外置了32768的时钟?如果是外置时钟,有可能是你晶振的匹配电容有问题。
离线
接近300uA的耗电, 这个RTC意义不大,
离线