NUCLEO-L053R8:低功耗待机模式standby/RTC唤醒(例程分享) 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用RTC唤醒,实际效果是LED一直在闪 代码下载:见附件 standby mode with RTC:0.85uA VDD=3.0V /**9 u* g$ l7 a* M# y; i * @brief Main program * @param None * @retval None */ int main(void) { 7 p8 q: ~5 T9 V# B% C) g( | /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose 1 ~: J% Q/ y5 B- O7 P3 l- k4 G: q. K timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and ) |9 X( B+ V3 {$ m5 L# U handled in milliseconds basis.8 i5 b* T' ?8 J3 D# b w5 H1 Q7 x- W/ w - Low Level Initialization& k+ K8 X1 g& v% P */, \5 J" _- W$ b HAL_Init(); /* Configure LED2 */ BSP_LED_Init(LED2);7 K; B4 O% G' u' t /* Configure the system clock to 2 MHz */ SystemClock_Config(); /* Check and handle if the system was resumed from Standby mode */ if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) {) a! U' d' b. D' O( Z /* Clear Standby flag */, L) g# d! C3 x2 m __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);5 U1 m) `3 F$ m9 c8 X //如果是唤醒状态,则LED亮3秒 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED HAL_Delay(3000);% ]! O4 }: y* a! f2 z3 T$ X HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); } else;7 \; E) v4 u9 M! u- d3 y# d 2 z" h4 T- S1 R4 t, w# p7 V /* Configure the system Power */3 s8 h3 f% E! v5 R; k% Q SystemPower_Config(); /* Insert 1 seconds delay */ HAL_Delay(1000);9 m8 S2 a+ P D& l" A9 u2 z- i /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry mainly when using more than one wakeup source this is to not miss any wakeup event. - Disable all used wakeup sources, - Clear all related wakeup flags, ; G3 ^" H" F1 m) y5 y( _ - Re-enable all used wakeup sources, - Enter the Standby mode.& J! q4 g g0 _8 r- e7 ] */ /*Disable all used wakeup sources: Pin1(PA.0)*/& }( g U4 t' b HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); /*Clear all related wakeup flags*/ C& K7 w7 M! ~" N: z" c( g" V __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /*Re-enable all used wakeup sources: Pin1(PA.0)*/ HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);. k. ]! ], q( {7 Y; `! S. u /*Enter the Standby mode*/: M8 d6 o4 n4 P* u0 W( I. S HAL_PWR_EnterSTANDBYMode(); / L: |% q5 o- U/ `" Q+ R- m while (1) { }& v6 G* t) _- K4 t2 J4 x! X- P } |
PWR_STANDBY_RTC.rar
下载4.02 MB, 下载次数: 66
谢楼上支持
谢楼上支持
学习学习