|
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享) 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用PA0引脚唤醒(用杜邦线接高电平唤醒) 代码下载:见附件 standby mode without RTC:0.29uA VDD=3.0V /** * @brief Main program9 B) r7 j. y/ W( A) f+ k4 o) |5 Q * @param None- _3 I+ G" G( i/ C3 E+ d- s * @retval None */ int main(void)2 ~1 ? ]# j8 A+ i3 t5 W0 Y { ' l, V" }1 E& v1 D( ] /* STM32L0xx HAL library initialization:, m% `8 F/ u+ y" e0 O$ b( A - Configure the Flash prefetch, Flash preread and Buffer caches ?2 L5 a% x2 n) ^2 C* t( U( @ - Systick timer is configured by default as source of time base, but user 2 h5 e, l5 _( t, E9 b can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base A6 P" ]+ D9 o6 V% e' o5 S duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and & u" H0 {. Y( N handled in milliseconds basis. - Low Level Initialization */+ _& p8 A% g% b. z. V' A0 d HAL_Init();" o7 M U9 ?6 t- z* K. P # T5 k, c/ z5 p4 O /* Configure LED2 */8 ~6 a" Y5 {2 q' M, a BSP_LED_Init(LED2);: B: o) h( ?% h, z . C4 O6 U l; y( E! y, G /* Configure the system clock to 2 MHz */ n' k0 c/ a/ h& |8 S9 g SystemClock_Config();9 Z$ ?. r% z" d1 c1 ~% z: s " c$ m P3 \ W 5 Z }4 o u; _/ k( W# u; x /* Check and handle if the system was resumed from Standby mode */ 6 N( l7 e" h! {- I5 S if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)/ ~1 ]+ ]( {8 O4 [4 S6 A {7 e9 U1 _' h# I7 X, b /* Clear Standby flag */) n: X; z+ j( p& I4 M; F; c* D4 f0 Y __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);! d3 N- [1 y4 l `1 [) b, j + S2 W0 t2 R! M+ \ o //如果是唤醒状态,则LED亮3秒 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED HAL_Delay(3000); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); } else; 1 x9 t4 f7 {1 i /* Configure the system Power */! l6 k ?9 y+ S& H SystemPower_Config();# C+ I% I L* t; T* ^- x$ D" V ' G& h8 K# j0 c0 o o /* Insert 1 seconds delay */ HAL_Delay(1000);% c4 @- J4 k' S1 g' }8 d /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry5 G: |8 _8 {& Y9 m8 [2 Z mainly when using more than one wakeup source this is to not miss any wakeup event. - Disable all used wakeup sources,& v5 |4 u( G2 J. l - Clear all related wakeup flags, - Re-enable all used wakeup sources, - Enter the Standby mode. */ /*Disable all used wakeup sources: Pin1(PA.0)*/; p8 a) q0 [) H& n, O HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);& T; G. \, w' @ h. M ( k5 Z) u/ w9 m' F/ t3 a /*Clear all related wakeup flags*/0 `. x! q M5 Y4 V' _ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);5 J! F v9 [9 o! |* A) I: x: g1 q6 e /*Re-enable all used wakeup sources: Pin1(PA.0)*/* N& d1 Y: \' ~6 a2 L2 Z. I2 T+ c HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); /*Enter the Standby mode*/ HAL_PWR_EnterSTANDBYMode(); while (1) {% c' ^, b9 m9 Z: x3 ^ } }: b# g4 [% k6 H7 i6 `+ V/ R
|
PWR_STANDBY.rar
下载4.04 MB, 下载次数: 28
微信公众号
手机版
谢楼上支持
谢楼上支持
学习学习