请教:在S3C2410上运行读RTC程序出错
如下是我的读RTC c程序,交叉编译成功但在板子上运行时出错:
#include "2410addr.h"
char *day[8] = {" ","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
void main(void)
{
int year,tmp;
int year,tmp,key;
int month,date,weekday,hour,min,sec;
rRTCCON = 0x01; //No reset, Merge BCD counters, 1/32768, RTC Control enable
if(rBCDYEAR==0x99)
year = 0x1999;
else
year = 0x2000 + rBCDYEAR;
month = rBCDMON;
weekday = rBCDDAY;
date = rBCDDATE;
hour = rBCDHOUR;
min = rBCDMIN;
sec = rBCDSEC;
printf("%2x : %2x : %2x %10s, %2x/%2x/%4x\n",hour,min,sec,day[weekday],month,date,year);
// printf("%2x : %2x : %2x %9s, %2x/%2x/%4x rBCDDATE = %x, weekday= %x\n",hour,min,sec,day[weekday],month,date,year,rBCDDATE,weekday);
rRTCCON = 0x0; //No reset, Merge BCD counters, 1/32768, RTC Control disable(for power consumption)
}
头文件定义如下:
#ifdef __BIG_ENDIAN
#define rRTCCON (*(volatile unsigned char *)0x57000043) //RTC control
#define rTICNT (*(volatile unsigned char *)0x57000047) //Tick time count
#define rRTCALM (*(volatile unsigned char *)0x57000053) //RTC alarm control
#define rALMSEC (*(volatile unsigned char *)0x57000057) //Alarm second
#define rALMMIN (*(volatile unsigned char *)0x5700005b) //Alarm minute
#define rALMHOUR (*(volatile unsigned char *)0x5700005f) //Alarm Hour
#define rALMDATE (*(volatile unsigned char *)0x57000063) //Alarm day <-- May 06, 2002 SOP
#define rALMMON (*(volatile unsigned char *)0x57000067) //Alarm month
#define rALMYEAR (*(volatile unsigned char *)0x5700006b) //Alarm year
#define rRTCRST (*(volatile unsigned char *)0x5700006f) //RTC round reset
#define rBCDSEC (*(volatile unsigned char *)0x57000073) //BCD second
#define rBCDMIN (*(volatile unsigned char *)0x57000077) //BCD minute
#define rBCDHOUR (*(volatile unsigned char *)0x5700007b) //BCD hour
#define rBCDDATE (*(volatile unsigned char *)0x5700007f) //BCD day <-- May 06, 2002 SOP
#define rBCDDAY (*(volatile unsigned char *)0x57000083) //BCD date <-- May 06, 2002 SOP
#define rBCDMON (*(volatile unsigned char *)0x57000087) //BCD month
#define rBCDYEAR (*(volatile unsigned char *)0x5700008b) //BCD year
#else //Little Endian
#define rRTCCON (*(volatile unsigned char *)0x57000040) //RTC control
#define rTICNT (*(volatile unsigned char *)0x57000044) //Tick time count
#define rRTCALM (*(volatile unsigned char *)0x57000050) //RTC alarm control
#define rALMSEC (*(volatile unsigned char *)0x57000054) //Alarm second
#define rALMMIN (*(volatile unsigned char *)0x5700005 //Alarm minute
#define rALMHOUR (*(volatile unsigned char *)0x5700005c) //Alarm Hour
#define rALMDATE (*(volatile unsigned char *)0x57000060) //Alarm day <-- May 06, 2002 SOP
#define rALMMON (*(volatile unsigned char *)0x57000064) //Alarm month
#define rALMYEAR (*(volatile unsigned char *)0x5700006 //Alarm year
#define rRTCRST (*(volatile unsigned char *)0x5700006c) //RTC round reset
#define rBCDSEC (*(volatile unsigned char *)0x57000070) //BCD second
#define rBCDMIN (*(volatile unsigned char *)0x57000074) //BCD minute
#define rBCDHOUR (*(volatile unsigned char *)0x5700007 //BCD hour
#define rBCDDATE (*(volatile unsigned char *)0x5700007c) //BCD day <-- May 06, 2002 SOP
#define rBCDDAY (*(volatile unsigned char *)0x57000080) //BCD date <-- May 06, 2002 SOP
#define rBCDMON (*(volatile unsigned char *)0x57000084) //BCD month
#define rBCDYEAR (*(volatile unsigned char *)0x5700008 //BCD year
#endif //RTC
在开发板运行时报如下错误:
pc : [<000083c0>] lr : [<40039d90>] Not tainted
sp : bffffe60 ip : bffffea4 fp : bffffea0
r10: 400dc26c r9 : 000083a0 r8 : 00000001
r7 : 4001fe94 r6 : 0000825c r5 : bffffec4 r4 : 00000648
r3 : 57000040 r2 : 00000001 r1 : 00000001 r0 : 00000001
Flags: nZCv IRQs on FIQs on Mode USER_32 Segment user
Control: C000317F Table: 33DC8000 DAC: 00000015
Segmentation fault
请教各位大侠,问题出在哪里??热切等待达人的回复!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在用户空间不能直接操作寄存器,你需要相应的驱动。
谢谢leonevictor,我RTC驱动已加载了,在LINUX下可以用#cat /proc/driver/rtc读出系统时间,并能用hwclock修改,但我想在C下修改和读出RTC时间而不是在LINUX的SHELL下用命令读出和修改RTC时间,请问我那段C应怎样做??
谢谢leonevictor,我RTC驱动已加载了,在LINUX下可以用#cat /proc/driver/rtc读出系统时间,并能用hwclock修改,但我想在C下修改和读出RTC时间而不是在LINUX的SHELL下用命令读出和修改RTC时间,请问我那段C应怎样做??
看驱动程序提供出来的函数接口。