这是我自己写的代码,但是调不通,每次都一睡不醒,所以希望大家帮助
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_PWR, ENABLE);
RCC_ConfigLse(RCC_LSE_ENABLE);
while(!RCC_GetFlagStatus(RCC_LSCTRL_FLAG_LSERD));
RCC_ConfigLSXSEL(RCC_RTCCLK_SRC_LSE);
RCC_EnableLsi(DISABLE);
RCC_EnableRtcClk(ENABLE);
RTC_WaitForSynchro();
RTC_InitType rtc;
rtc.RTC_AsynchPrediv = 127;
rtc.RTC_SynchPrediv = 255;
rtc.RTC_HourFormat = RTC_24HOUR_FORMAT;
RTC_Init(&rtc);
RTC_EnableWakeUp(DISABLE);
while(!RTC_GetFlagStatus(RTC_FLAG_WTWF));
RTC_ConfigWakeUpClock(RTC_WKUPCLK_CK_SPRE_16BITS);
RTC_SetWakeUpCounter(0);
RTC_EnableWakeUp(ENABLE);
RTC_ConfigInt(RTC_INT_WUT, ENABLE);
EXTI_InitType exti;
exti.EXTI_Line = EXTI_LINE9;
exti.EXTI_LineCmd = ENABLE;
exti.EXTI_Mode = EXTI_Mode_Event;
exti.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitPeripheral(&exti);
while(1){
GPIO_TogglePin(GPIOB, GPIO_PIN_1);
PWR_EnterSLEEPMode(PWR_SLEEPENTRY_WFE);
}
|