|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
如下是我的读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 *)0x57000058) //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 *)0x57000068) //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 *)0x57000078) //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 *)0x57000088) //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
请教各位大侠,问题出在哪里??热切等待达人的回复!! |
|