在调试外部RTC时,由于外部的时钟芯片没有数据,或者在读取外部时钟时,没有取到正确的数据,例如读到的年、月、日、时、分、秒皆为0,这些数值为非法的数据,因此产生启动异常!启动信息为:
NOR Flash Man. ID is 0x890089
Intel Flash Found With 32 Bits Bus Width
NOR Flash Dev. ID is 0x180018
Total FlashSize = 2x16 = 32MBytes
autoboot delay time is 1 seconds.
IP address for bootloader is 192.168.0.11
kernel run address is 0xa00b8000
kernel boot command line is "root=/dev/mtdblock2 init=/linuxrc console=ttyS0,115200 devfs=mount display=shp240"
1 seconds delay for autoboot press any key to abort...
Start boot kernel...
set boot params : "root=/dev/mtdblock2 init=/linuxrc console=ttyS0,115200 devfs=mount display=shp240"
******************************************************
******************************************************
******************************************************
******************************************************
******************************************************
OEMInitDebugSerial using UART1
Windows CE Kernel for ARM (Thumb Enabled) Built on Feb 8 2007 at 23:36:51
ProcessorType=0411 Revision=7
sp_abt=ffff5000 sp_irq=ffff2800 sp_undef=ffffc800 OEMAddressTable = 96cb97d4
XSCDBG:Trace initialized: CFG:98990c1c Buffer: 9898f668, 14f0
Sp=ffffc7cc
:::test_rtc.wYear..... 2000,0,0,0,0,0,0 .
:::init_rtc == FALSE..... 2000,0,0,0,0,0,0 .
Data Abort: Thread=9a5e5000 Proc=98997ed0 'filesys.exe'
AKY=00000003 PC=96cf62c4(NK.EXE+0x0003e2c4) RA=96cf62a4(NK.EXE+0x0003e2a4) BVA=42000004 FSR=000004f6
因此,在程序里面要做进一步的处理,避免启动异常。
可以在:::init_rtc == FALSE.....代码附近加上条件初始化RTC,避免产生错误。代码如下:
if ((hex_rtc.wMonth < 1) || (hex_rtc.wMonth > 12) || (hex_rtc.wDay < 1) ||
(hex_rtc.wDay > 31) || (hex_rtc.wHour > 23) || (hex_rtc.wMinute > 59) ||
(hex_rtc.wSecond > 59) || (hex_rtc.wMilliseconds > 999))
{
XSC1_SetRealTime(&defst);
return TRUE;
}
其中defst可以自定义为SYSTEMTIME的结构体变量。例如可以定义为:
static SYSTEMTIME defst = {1980,1,2,1,23,59,00,0};
此时,在保存编译程序,将系统目标代码下载到目标板,复位启动正常!