先贴上中断部分的程序: void RTC_IRQHandler(void) { vu32 Time_temp; if (RTC_GetITStatus(RTC_IT_SEC) != RESET) { /* Clear the RTC Second interrupt */ RTC_ClearITPendingBit(RTC_IT_SEC);
/* Enable time update */ TimeDisplay = 1;
/* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); /* Reset RTC Counter when Time is 23:59:59 */ Time_temp=RTC_GetCounter(); if (Time_temp >= 0x00015180) //这部分原来是判断计数器是否等于0x00015180(即86400),如果等于的话,将计数器清零,现在这个是我改的 { Time_temp=Time_temp%0x00015180; RTC_SetCounter(Time_temp); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); } } }
void RTC_IRQHandler(void) { vu32 Time_temp; if (RTC_GetITStatus(RTC_IT_SEC) != RESET) { /* Clear the RTC Second interrupt */ RTC_ClearITPendingBit(RTC_IT_SEC);
/* Enable time update */ TimeDisplay = 1;
/* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); /* Reset RTC Counter when Time is 23:59:59 */ Time_temp=RTC_GetCounter(); if (Time_temp >= 0x00015180) { Time_temp=Time_temp%0x00015180; RTC_WaitForLastTask(); //刚加的 RTC_WaitForSynchro(); //刚加的 RTC_WaitForLastTask(); //刚加的 RTC_SetCounter(Time_temp); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); } } }