|
RTC使用LSI(40KHz)
准备用RTC每200ms产生一次定时中断,让Led每200ms开关一次。以下流程有没有问题或bug?
RTC使用LSI(40KHz)
1)通过函数RTC_SetPrescaler(7999) 将RTC周期设定为200ms
2)通过函数RTC_ITConfig(RTC_IT_SEC, ENABLE) 使能RTC秒中断
3)在中断向量表中,提供/* 19, INTISR[ 3] RTC Global Interrupt*/ 对应的中断服务程序RTC_Global_Interrupt()
4)在中断服务程序中void RTC_Global_Interrupt( void )中: void RTC_Global_Interrupt( void ) { if( RTC_GetITStatus(RTC_IT_SEC) != RESET ) { RTC_ClearITPendingBit(RTC_IT_SEC);
RTC_WaitForLastTask();
/* Reset RTC Counter when Time is 23:59:59 */ if(RTC_GetCounter() == 0x00015180) { RTC_SetCounter(0x0);
RTC_WaitForLastTask(); }
//开关LED; } } |
|