STM32Cube STM32L053配置RTC WAKEUP中断唤醒
Posted シ゛甜虾
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了STM32Cube STM32L053配置RTC WAKEUP中断唤醒相关的知识,希望对你有一定的参考价值。
芯片手册中提到的从停止模式唤醒说明
芯片手册中提到的从待机模式唤醒说明
配置
LL_RTC_InitTypeDef RTC_InitStruct = 0;
LL_RCC_EnableRTC();
NVIC_SetPriority(RTC_IRQn,0);
NVIC_EnableIRQ(RTC_IRQn);
RTC_InitStruct.HourFormat = LL_RTC_HOURFORMAT_24HOUR;
RTC_InitStruct.AsynchPrescaler = 127;
RTC_InitStruct.SynchPrescaler = 255;
LL_RTC_Init(RTC, &RTC_InitStruct);
LL_RTC_WAKEUP_SetClock(RTC, LL_RTC_WAKEUPCLOCK_CKSPRE);
LL_RTC_WAKEUP_SetAutoReload(RTC, 60);
中断唤醒清除中断
void RTC_IRQHandler(void)
/* USER CODE BEGIN RTC_IRQn 0 */
INTRTC = 1;
while(LL_RTC_IsActiveFlag_WUT(RTC))
LL_RTC_ClearFlag_WUT(RTC);
LL_RCC_MSI_Enable();
LL_RCC_LSI_Enable();
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_20);
/* USER CODE END RTC_IRQn 0 */
/* USER CODE BEGIN RTC_IRQn 1 */
/* USER CODE END RTC_IRQn 1 */
休眠函数
void stop(void)
/* 开启PWR时钟 */
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
/* 设置中断线 */
LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_20);
LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_20);
LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_20);
/* 设置RTC唤醒时间 */
LL_RTC_DisableWriteProtection(RTC);
LL_RTC_WAKEUP_Disable(RTC);
while(!LL_RTC_IsActiveFlag_WUTW(RTC));
LL_RTC_WAKEUP_SetAutoReload(RTC, 20);
LL_RTC_WAKEUP_SetClock(RTC, LL_RTC_WAKEUPCLOCK_CKSPRE);
LL_RTC_EnableIT_WUT(RTC);
LL_RTC_WAKEUP_Enable(RTC);
LL_RTC_EnableWriteProtection(RTC);
//power_off();
LL_PWR_EnableUltraLowPower();
LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_LOW_POWER);
LL_PWR_SetPowerMode(LL_PWR_MODE_STOP);
LL_LPM_EnableDeepSleep();
__WFI();
//power_on();
以上是关于STM32Cube STM32L053配置RTC WAKEUP中断唤醒的主要内容,如果未能解决你的问题,请参考以下文章
STM32Cube STM32L053配置RTC WAKEUP中断唤醒
STM32Cube STM32L053闹钟唤醒LL库和HAL库
STM32Cube STM32L053配置GPIO达到最低功耗详解含测量实际电流值