
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)4 s$ l5 ^$ F Y 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用PA0引脚唤醒(用杜邦线接高电平唤醒) 代码下载:见附件 standby mode without RTC:0.29uA VDD=3.0V /** * @brief Main program0 ^* t4 g. c% a7 q * @param None, _5 N, ` q( H+ Z& ~ * @retval None" [7 g9 R0 i7 r */ int main(void) { /* STM32L0xx HAL library initialization: j; R- S3 H0 m' E, d - 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 * @# z& V: Z0 A/ B 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 handled in milliseconds basis.4 V/ h+ @' P* M9 w. Z: s+ G - Low Level Initialization5 _: E: U$ {. a9 H2 e */ HAL_Init();" J' e# [; p) w3 q' V) X8 X /* Configure LED2 */# E$ a- H- C" D BSP_LED_Init(LED2);6 u9 p8 Y5 [+ e* p * t% M. F) E. C7 a /* Configure the system clock to 2 MHz */8 t( X! f$ V3 [. {- L( ~0 v SystemClock_Config(); 3 f* C8 g8 O4 |( T* ~; u /* Check and handle if the system was resumed from Standby mode */ ) s3 e7 d: @; u/ M2 c if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)8 r) C- G* ^) ]7 L( A% N! R8 Z { /* Clear Standby flag */: G* |$ W& h, H! i __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);5 |% l8 v) z' `- d. M2 K //如果是唤醒状态,则LED亮3秒6 W: P; x% J$ E" {- }0 c( K HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED6 Z: S7 \$ m3 L& Q* U3 E ]! V. O2 H2 u1 a3 M HAL_Delay(3000);' T0 ^/ v, S4 ]. L& ` HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);( R% Y6 S" l) ]& M& u; q, r }$ `2 G" i: Q" z* }% ~6 E, R else; " q1 w; u9 K+ z: I$ x+ m% ]( W6 L /* Configure the system Power */ SystemPower_Config(); /* Insert 1 seconds delay */8 ^: l; ?$ R! b HAL_Delay(1000); 9 n! [3 I b \/ x e7 Q2 F3 P /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry+ P7 u+ M0 }% V* k mainly when using more than one wakeup source this is to not miss any wakeup event. - Disable all used wakeup sources,5 x8 F& l7 v/ A# {5 @$ T; n1 H/ U' e - Clear all related wakeup flags, - Re-enable all used wakeup sources, - Enter the Standby mode. */" N3 ?. A# n; P% l$ T9 G) J /*Disable all used wakeup sources: Pin1(PA.0)*/* {# s4 V0 h6 ? HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);% P$ I. K) J! B- } /*Clear all related wakeup flags*/ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);7 z: }$ k1 `( o6 Q' ?7 x /*Re-enable all used wakeup sources: Pin1(PA.0)*/& U; i# e+ o" Q8 Y HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);. M. P" i$ G, [ /*Enter the Standby mode*/9 o5 O/ b( U' Q; d/ A4 b HAL_PWR_EnterSTANDBYMode();2 j- S5 O* k- p3 }1 [3 V while (1). O$ O: Z- e9 @6 @! m3 I X {) ^8 i; D- H4 t$ ~# E& U% C9 i* B } } ![]() ![]() ![]() |
PWR_STANDBY.rar
下载4.04 MB, 下载次数: 28
谢楼上支持
谢楼上支持
学习学习