|
NUCLEO-L053R8:低功耗STOP模式,外部中断唤醒(例程分享) 基于ST官方NUCLEO-L053R8开发板 代码下载见附件 Stop mode without RTC:0.4uA VDD=3.0V int main(void) {: Y6 P f. B4 R, b/ O( V /* STM32L0xx HAL library initialization:; O, E( m* y3 I, ~; L; w - 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 % R9 `- ], ~# @! E$ q m timer for example or other time source), keeping in mind that Time base - z/ \# i& S( t duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and ( U6 p" `- G% c1 m handled in milliseconds basis. - Low Level Initialization, D! A/ J G* l4 p */6 G0 S3 R) w. x* r' ~ HAL_Init();( n7 O9 `3 E4 Y/ E& _ 2 o. k" Q: H4 ^0 d5 A& x8 o" A /* Configure LED2 */5 C% N( D+ \# b4 w' ^8 B- j- @3 X BSP_LED_Init(LED2); W! n+ P' m. }1 f8 g( u! c3 _ /* Configure the system clock @ 32 Mhz */) O2 b+ E b3 O C7 v SystemClock_Config(); /* Configure the system Power */. M: `$ x6 e$ k# E6 [ SystemPower_Config(); + s/ N2 K8 f" |) ~6 U8 Z while (1) { /* Insert 5 second delay */ BSP_LED_Init(LED2); //LED初始化 3 R3 q1 R) R3 L! p1 r* c HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED HAL_Delay(3000);4 Q8 d% j, ]! e9 } HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);+ O# Y; F% w/ |- z) _/ E/ o HAL_Delay(3000);5 M$ k/ k; @) n+ k x3 H SystemPower_Config(); //关闭所有IO和时钟 /* Key button (EXTI_Line13) will be used to wakeup the system from STOP mode */( K$ A/ u+ [$ ~3 d/ \6 v BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); ; f, T& x9 g& L/ U2 c' x6 a( ? /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); /* Configures system clock after wake-up from STOP: enable HSE, PLL and select: n; k- w; i) g" u1 s7 _) W! [2 L" v PLL as system clock source (HSE and PLL are disabled in STOP mode) */ SystemClockConfig_STOP(); } }
3 q: h* ~0 ~$ } O% T |
PWR_STOP.rar
下载4.01 MB, 下载次数: 45
微信公众号
手机版
感谢支持
谢版主支持
谢楼上支持
学习学习