STM32之RTC鬧鐘喚醒停機(jī)模式
1,停機(jī)模式下秒中斷不能用;
2,每次鬧鐘中斷后,要重新賦值,否則不會(huì)再進(jìn)中斷;
3,網(wǎng)上很多關(guān)于鬧鐘叫醒休眠模式的例程,后來發(fā)現(xiàn),使能的都是秒中斷,不是鬧鐘中斷,根本不行;
4,發(fā)現(xiàn)鬧鐘中斷使能后,如果使能了秒中斷,則秒中斷標(biāo)志會(huì)置位:
void RTCAlarm_IRQHandler()//RTC_IRQHandler(void)
{
feed_dog();
if(RTC_GetITStatus(RTC_IT_SEC)!= RESET)
{
// g_bRTCAlarm = 1;
feed_dog();
RTC_ClearITPendingBit(RTC_IT_SEC);
RTC_WaitForLastTask();
}
if(RTC_GetITStatus(RTC_IT_ALR) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line17);
if(PWR_GetFlagStatus(PWR_FLAG_WU) != RESET)
{
PWR_ClearFlag(PWR_FLAG_WU);
}
RTC_WaitForLastTask();
RTC_ClearITPendingBit(RTC_IT_ALR);
RTC_WaitForLastTask();
}
}
//void RTC_IRQHandler()//RTC_IRQHandler(void)
//{
// if(RTC_GetITStatus(RTC_IT_SEC) != RESET)
// {
//
//// g_bRTCAlarm = 1;
// feed_dog();
//
// RTC_ClearITPendingBit(RTC_IT_SEC);
//
// RTC_WaitForLastTask();
// }
//}
如果打開下面函數(shù):
// NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPrio rity = 1;
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
// NVIC_Init(&NVIC_InitStructure);
則秒中斷就會(huì)進(jìn)來;
還有,通過上面這個(gè)NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;我才剛認(rèn)識(shí)到他就是傳遞中斷向量地址的。
評(píng)論