初始化函数,发现改函数在main中的位置也会影响走时与否
void RTC_Init(void)
{
RTC0KEY = 0xA5; // Unlock the RTC interface
RTC0KEY = 0xF1;
RTC0ADR = 0x06; // Point to RTC0CN
RTC0DAT = 0x80; // Enable the RTC
while ((RTC0ADR & 0x80) == 0x80); // Poll on the BUSY bit
RTC0ADR = 0x07; // Point to RTC0XCN
RTC0DAT = 0xc0;//RTC0DAT = 0x40; // Set the RTC for crystal mode, AGCEN// disabled, and BIASX2 disabled
while ((RTC0ADR & 0x80) == 0x80); // Poll on the BUSY bit
do// Wait until the clock is valid
{
RTC0ADR |= 0x80;
while ((RTC0ADR & 0x80) == 0x80);
}
while((RTC0DAT & 0x10) == 0x00);
}