系统先进入停止模式,然后用RTC Wakeup唤醒,RTC时钟为LSE,每4秒产生一个中断。目前的问题是,可以进入停止模式,可是无法进入中断,无法唤醒。 main函数部分: int main(void) { /* Initialization */ RTC_Config(); while (1) { RTC_WakeUpCmd(ENABLE);//Enable wakeup counter PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);//Enter Stop mode RTC_WakeUpCmd(DISABLE);//Disable wakeup counter /*After wakeup form Stop reconfigure the system clock*/ RCC_HSEConfig(RCC_HSE_ON);//Enable HSE while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET) {} RCC_PLLCmd(ENABLE); while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) {} RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); while(RCC_GetSYSCLKSource() != 0x0C) {} } } RTC部分 void RTC_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; /* Enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); /* Allow access to RTC */ PWR_RTCAccessCmd(ENABLE); PWR_RTCAccessCmd(DISABLE); /* Enable the LSE OSC */ RCC_LSEConfig(RCC_LSE_ON); /* Wait till LSE is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { } /* Select the RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); /* Enable the RTC Clock */ RCC_RTCCLKCmd(ENABLE); /* Wait for RTC APB registers synchronisation */ RTC_WaitForSynchro(); /*EXTI configuration*/ EXTI_ClearITPendingBit(EXTI_Line20); EXTI_InitStructure.EXTI_Line = EXTI_Line20; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable the RTC Wakeup Interrupt */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* RTC Wakeup Interrupt Generation: Clock Source: RTCDiv_16, Wakeup Time Base: 4s */ RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16); RTC_SetWakeUpCounter(0x1FFF); /* Enable the Wakeup Interrupt */ EXTI_ClearFlag(RTC_FLAG_WUTF); RTC_ITConfig(RTC_IT_WUT, ENABLE); RTC_WakeUpCmd(ENABLE); } 中断部分: void RTC_WKUP_IRQHandler(void) { if(RTC_GetITStatus(RTC_IT_WUT) != RESET) { OLED_Display1(2, "WAKE UP !!!"); RTC_ClearITPendingBit(RTC_IT_WUT); EXTI_ClearITPendingBit(EXTI_Line20); } } 希望哪位大牛能来帮我解答一下,不胜感谢!!! |
RE:STM32L152 RTC唤醒STOP mode问题
RE:STM32L152 RTC唤醒STOP mode问题
RE:STM32L152 RTC唤醒STOP mode问题
我的RTC定时运行时间还不准,运行时间比正常时间快很多,3-4秒就要快1秒钟。
不知道你硬件2个晶振使用多大的?或者晶振怎么配置的?
闹钟唤醒:void RTC_Alarm_IRQHandler(void)
秒唤醒:void RTC_IRQHandler(void)
你查一下是不是入口错误。