s5pv210 RTC寄存器

在研究s5pv210 RTC模块时,发现官方手册中BCDDAYWEEK和BCDDAY寄存器地址有误。实际操作中需要将两者地址互换才能正确设置日期。通过调整宏定义,解决了设置日期时显示不正确的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

近期在学习s5pv210 RTC的模块,遇到一个很古怪的问题:

设置时间day寄存器时,读出来的数据总是不对,经过一番调试后,发现官方手册里面的寄存器需要把星期和日的寄存器地址调换一下,就可以完美解决(不知道是自己手册的版本的问题)。


手册上面显示BCDDAYWEEK寄存器地址为:0xE280007C

BCDDAY寄存器地址为:0xE2800080


实际使用时需要写成:

BCDDAYWEEK寄存器地址为:0xE2800080

BCDDAY寄存器地址为: 0xE280007C


整体寄存器图片:




我使用的手册版本是:



我的代码如下:

(1)、修改前宏定义

#define RTC_BAST 0xE2800000
#define INTP (RTC_BAST + 0x30)
#define RTCCON (RTC_BAST + 0x40)
#define TICCNT (RTC_BAST + 0x44)
#define RTCALM (RTC_BAST + 0x50)
#define ALMSEC (RTC_BAST + 0x54)
#define ALMMIN (RTC_BAST + 0x58)
#define ALMHOUR (RTC_BAST + 0x5C)
#define ALMDAY (RTC_BAST + 0x60)
#define ALMMON (RTC_BAST + 0x64)
#define ALMYEAR (RTC_BAST + 0x68)
#define BCDSEC (RTC_BAST + 0x70)
#define BCDMIN (RTC_BAST + 0x74)
#define BCDHOUR (RTC_BAST + 0x78)
#define BCDDAYWEEK (RTC_BAST + 0x7C)
#define BCDDAY (RTC_BAST + 0x80)
#define BCDMON (RTC_BAST + 0x84)
#define BCDYEAR (RTC_BAST + 0x88)
#define CURTICCNT (RTC_BAST + 0x90)

#define rINTP (*(volatile unsigned int *)INTP)
#define rRTCCON (*(volatile unsigned int *)RTCCON)
#define rTICCNT (*(volatile unsigned int *)TICCNT)
#define rRTCALM (*(volatile unsigned int *)RTCALM)
#define rALMSEC (*(volatile unsigned int *)ALMSEC)
#define rALMMIN (*(volatile unsigned int *)ALMMIN)
#define rALMHOUR (*(volatile unsigned int *)ALMHOUR)
#define rALMDAY (*(volatile unsigned int *)ALMDAY)
#define rALMMON (*(volatile unsigned int *)ALMMON)
#define rALMYEAR (*(volatile unsigned int *)ALMYEAR)
#define rBCDSEC (*(volatile unsigned int *)BCDSEC)
#define rBCDMIN (*(volatile unsigned int *)BCDMIN)
#define rBCDHOUR (*(volatile unsigned int *)BCDHOUR)
#define rBCDDAYWEEK (*(volatile unsigned int *)BCDDAYWEEK)
#define rBCDDAY (*(volatile unsigned int *)BCDDAY)
#define rBCDMON (*(volatile unsigned int *)BCDMON)
#define rBCDYEAR (*(volatile unsigned int *)BCDYEAR)
#define rCURTICCNT  (*(volatile unsigned int *)CURTICCNT)


struct rtc_time
{
unsigned int year;
unsigned int month;
unsigned int day; //几号
unsigned int hour;
unsigned int minute;
unsigned int second;
unsigned int week; //星期
};

------------------------------------------------------------------------------------------------------

测试写入读出函数:

//RTC修改时间
printf("------RTC------\n");
struct rtc_time tRead;
struct rtc_time tWrite =
{
.year = 2017,
.month = 4,
.day = 11,
.hour = 0,
.minute = 16,
.second = 50,
.week = 2,

};

rtc_set_time(&tWrite);
//delay_x(10000);
rtc_get_time(&tRead);
printf("the rWrite time  is: %d:%d:%d:%d:%d:%d:%d\n", tRead.year, tRead.month, tRead.day, tRead.hour, tRead.minute, tRead.second, tRead.week);

------------------------------------------------------------------------------------------------------------------

得到打印结果:

      ------RTC------
                                      the rWrite time  is: 2017:4:1:0:16:50:2

--------------------------------------------------------------------------------------------------------------------

打印结果day不是11变成了。


(2)、将宏定义中BCDDAYWEEKBCDDAY的地址互换后

#define RTC_BAST 0xE2800000
#define INTP (RTC_BAST + 0x30)
#define RTCCON (RTC_BAST + 0x40)
#define TICCNT (RTC_BAST + 0x44)
#define RTCALM (RTC_BAST + 0x50)
#define ALMSEC (RTC_BAST + 0x54)
#define ALMMIN (RTC_BAST + 0x58)
#define ALMHOUR (RTC_BAST + 0x5C)
#define ALMDAY (RTC_BAST + 0x60)
#define ALMMON (RTC_BAST + 0x64)
#define ALMYEAR (RTC_BAST + 0x68)
#define BCDSEC (RTC_BAST + 0x70)
#define BCDMIN (RTC_BAST + 0x74)
#define BCDHOUR (RTC_BAST + 0x78)
#define BCDDAYWEEK (RTC_BAST + 0x80)
#define BCDDAY (RTC_BAST + 0x7C)
#define BCDMON (RTC_BAST + 0x84)
#define BCDYEAR (RTC_BAST + 0x88)
#define CURTICCNT (RTC_BAST + 0x90)

--------------------------------------------------------------------------------------

打印结果如下:

------RTC------
               the rWrite time  is: 2017:4:11:0:16:50:2


从打印结果来看,设置day等于11成功了。


总结:参照s5pv210数据手册来设置RTC时,需要注意BCDDAYWEEK和BCDDAY这两个寄存器的地址需要互换。
                                                       

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值