NUCLEO-L053R8:低功耗STOP模式,外部中断唤醒(例程分享)/ K e# u% [3 X; L 基于ST官方NUCLEO-L053R8开发板 代码下载见附件 Stop mode without RTC:0.4uA VDD=3.0V int main(void) { /* STM32L0xx HAL library initialization:# e$ d; Y a/ C2 b$ P& u6 s, [ - Configure the Flash prefetch, Flash preread and Buffer caches8 }( T3 C! @7 c+ j - Systick timer is configured by default as source of time base, but user 3 ^: D- X! D3 Z can eventually implement his proper time base source (a general purpose ; M- h; N( j. _( I timer for example or other time source), keeping in mind that Time base 3 ^- K8 s; T. @$ Z" p/ V1 V duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Low Level Initialization7 \$ r1 q3 Z& z+ d9 A$ c+ z; ` */ HAL_Init(); /* Configure LED2 */: _) B( z7 x; S( \+ A7 T BSP_LED_Init(LED2); /* Configure the system clock @ 32 Mhz */2 e1 F7 l( [5 j: Q SystemClock_Config(); /* Configure the system Power */ SystemPower_Config(); 7 J: P' Q! c* f$ B/ h y3 Y) ^8 s while (1) {( H" o5 p0 M- m; m /* Insert 5 second delay */ BSP_LED_Init(LED2); //LED初始化 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED HAL_Delay(3000);1 K3 R. D3 F- c$ m3 T Q+ z. v HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);& G" a1 x8 q! e% @ HAL_Delay(3000);5 _6 e( V- P y8 [" d9 C2 `+ `! Z SystemPower_Config(); //关闭所有IO和时钟( O$ q4 _0 g1 W; c* l /* 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 */- Y1 N `+ h1 Z. J% V7 t6 U HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);5 J# j1 u. s% V: n" F! N; l: x ( w; j ^( J4 N8 I5 I) v% t /* 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) */ SystemClockConfig_STOP();9 i; K6 a& U4 T( Y+ Y8 V0 ^9 m' }9 _ }" {: _; l( |" g }+ m- z, j* ]; x+ P% Z9 k9 ~ / H }, K3 g/ f; [' B |
PWR_STOP.rar
下载4.01 MB, 下载次数: 45
感谢支持
谢版主支持
谢楼上支持
学习学习