您尚未登录。

楼主 # 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; 
}

离线

页脚

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

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