NUCLEO-L053R8:低功耗STOP模式,外部中断唤醒(例程分享) 基于ST官方NUCLEO-L053R8开发板 代码下载见附件 Stop mode without RTC:0.4uA VDD=3.0V int main(void) {, f4 r2 w1 H2 w8 f /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches( v9 H% O2 J7 x5 n% F - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose ( M+ A1 ?- m6 T# h* R- l timer for example or other time source), keeping in mind that Time base 9 w, Z. y, R; B% B, ` duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization6 w2 }8 N3 | `+ V% t */ HAL_Init(); /* Configure LED2 */; M: x9 s* w* h5 \# m BSP_LED_Init(LED2);9 z ^% `) M( t6 ^: A. O# t( w /* Configure the system clock @ 32 Mhz */- J# w# `: B7 q( C& n K& y SystemClock_Config();: e- N! _- S# e8 d, l2 V; N /* Configure the system Power */ SystemPower_Config();/ M% x$ [! r# x/ V 0 A+ i6 L* a" z$ Q; y6 V$ g while (1) {7 F( w4 [0 o3 a0 y0 F& @1 X6 s, k /* Insert 5 second delay */ BSP_LED_Init(LED2); //LED初始化 & l* G, F* Z2 ^ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED HAL_Delay(3000);+ Z) l2 S( a, S8 |# `$ |$ g HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); HAL_Delay(3000);& s6 l' i; m3 ] SystemPower_Config(); //关闭所有IO和时钟2 `* Z& N( L$ J+ v/ p' o) O. F /* Key button (EXTI_Line13) will be used to wakeup the system from STOP mode */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /* Enter Stop Mode */2 R; p, Y h9 E* }7 X% e3 i HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); 0 n2 {+ X4 ?8 x2 T6 C /* Configures system clock after wake-up from STOP: enable HSE, PLL and select PLL as system clock source (HSE and PLL are disabled in STOP mode) */8 k7 f0 x' y$ ] SystemClockConfig_STOP();7 j @* G1 e9 i5 i }- s9 m5 Y- j: p }3 e, z: ^5 K5 M% Q . ]# u+ ]& S! M. M5 @ |
PWR_STOP.rar
下载4.01 MB, 下载次数: 45
感谢支持
谢版主支持
谢楼上支持
学习学习