int main(void)
{
/* Clock configuration */
RCC_Configuration();
/* Enable PWR and BKP clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* GPIO configuration */
GPIO_Configuration();
/* Configure EXTI Line9 to generate an interrupt on falling edge */
EXTI_Configuration();
/* Configure RTC clock source and prescaler */
RTC_Configuration();
/* NVIC configuration */
NVIC_Configuration();
/* Configure the SysTick to generate an interrupt each 1 millisecond */
SysTick_Configuration();
/* Alarm in 3 second */
RTC_SetAlarm(RTC_GetCounter()+ 3); //3秒钟后把MCU从睡眠模式唤醒
RTC_WaitForLastTask();
PWR_EnterSLEEPMode(0x01, PWR_SLEEPEntry_WFI);
while(1)
{
}
}
程序在PWR_EnterSLEEPMode(0x01, PWR_SLEEPEntry_WFI);
以后,就没被唤醒。用的是RTC。
void PWR_EnterSLEEPMode(u32 SysCtrl_Set, u8 PWR_SLEEPEntry)
{
if (SysCtrl_Set)
*(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPONEXIT_Set; // Set SLEEPONEXIT
else
*(vu32 *) SCB_SysCtrl &= ~SysCtrl_SLEEPONEXIT_Set;// Reset SLEEPONEXIT
*(vu32 *) SCB_SysCtrl &= ~SysCtrl_SLEEPDEEP_Set; // Clear SLEEPDEEP bit
if(PWR_SLEEPEntry == PWR_SLEEPEntry_WFI) // Select SLEEP mode entry
__WFI(); // Request Wait For Interrupt
else
__WFE(); // Request Wait For Event
}这个是进入睡眠的代码。
求指导 哪里有问题么~~ |