学习完待机唤醒实验后,看到RTC wakeup也能唤醒待机模式,然后关于唤醒步骤数据手册中如下介绍:
Enable the RTC wakeup interrupt in the RTC_CR register
Configure the RTC to generate the RTC wakeup event
a)Disable the RTC Wakeup interrupt (WUTIE bit in the RTC_CR register)
b) Clear the RTC Wakeup (WUTF) flag
c) Clear the PWR Wakeup (WUF) flag
d) Enable the RTC Wakeup interrupt
e) Re-enter the low power mode
我感觉是安着以上步骤配置的,但是唤醒不了,请原子哥或论坛里大神帮我看一下是哪里出问题了。
void My_RTC_Init(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);//使能时钟
PWR_BackupAccessCmd(ENABLE); //后背区域使能
if(RTC_ReadBackupRegister(RTC_BKP_DR0)!=0x5049) //
{
RCC_LSICmd(ENABLE);//开启LSI时钟
while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
{
}
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); //RTC时钟选择LSI
RCC_RTCCLKCmd(ENABLE); //使能RTC时钟
RTC_WriteBackupRegister(RTC_BKP_DR0,0x5049);
}
}
void RTC_Set_WakeUp(void)
{
RTC_WakeUpCmd(DISABLE);//禁止wakeup
RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);//16分频
RTC_SetWakeUpCounter(1999);//转载值设定
RTC_ClearITPendingBit(RTC_IT_WUT); //清楚标志位
RTC_ITConfig(RTC_IT_WUT,ENABLE);//使能中断
RTC_WakeUpCmd( ENABLE);
}
void my_enterstandby(void){
RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE,ENABLE);//复位IO
RTC_ITConfig(RTC_IT_WUT,DISABLE);//关闭中断
RTC_ClearITPendingBit(RTC_IT_TS|RTC_IT_WUT|RTC_IT_ALRB|RTC_IT_ALRA);
PWR_ClearFlag(PWR_FLAG_WU);
RTC_WakeUpCmd( ENABLE);//使能wakeup中断
PWR_ClearFlag(PWR_FLAG_WU);
PWR_EnterSTANDBYMode();//进入待机模式
}
一周热门 更多>