您尚未登录。

楼主 # 2022-11-03 13:37:21

Frankie.Yao
会员
注册时间: 2021-10-19
已发帖子: 3
积分: 8

V3S RTC problem

哪位大神帮看看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; 
}

离线

#1 2023-12-12 13:23:50

memory
会员
注册时间: 2021-08-11
已发帖子: 442
积分: 418

Re: V3S RTC problem

RTC那个我改了半天驱动,也查了资料,估计是V3s的一个bug,开机后强制把晶振切到了24M分频出来的32000Hz。

现在我能想到的办法,每N秒钟把系统时间写入RTC

离线

#2 2023-12-12 17:02:38

memory
会员
注册时间: 2021-08-11
已发帖子: 442
积分: 418

Re: V3S RTC problem

找了半天,原来是 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;
        }
    }

离线

#3 2023-12-13 17:43:34

伍零壹
会员
注册时间: 2019-12-16
已发帖子: 158
积分: 36

Re: V3S RTC problem

2033这个和你RTC时钟不准 应该没关系吧!你这RTC是主时钟分频得到的还是外置了32768的时钟?如果是外置时钟,有可能是你晶振的匹配电容有问题。

离线

#4 2023-12-14 09:12:41

musich
会员
注册时间: 2018-04-17
已发帖子: 249
积分: 281

Re: V3S RTC problem

接近300uA的耗电, 这个RTC意义不大,

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn