NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)6 x. q) X- r1 V9 u! T. H 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用PA0引脚唤醒(用杜邦线接高电平唤醒) 代码下载:见附件 standby mode without RTC:0.29uA VDD=3.0V /**' Z5 w0 B I( h5 b( r * @brief Main program2 ?8 t- ~6 t6 I) h; w * @param None/ C; z8 I- k0 p7 q * @retval None */; T4 C" T L& T- v v int main(void) { /* STM32L0xx HAL library initialization:5 H0 j5 i' u! R; y) @ - 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 # Y' d j! U: p# X) h 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 6 \( V% O. f* C% D: \ g, o handled in milliseconds basis. - Low Level Initialization */7 R/ W! p8 y( {7 J8 E: q- q j HAL_Init(); 7 z W. X: I" t /* Configure LED2 *// y" n( _" W) T& M) k# ]/ Z8 p BSP_LED_Init(LED2); /* Configure the system clock to 2 MHz */7 Y; x' E: M: p( i6 p% O+ _+ Z SystemClock_Config();3 t2 B2 n; |: o& h /* Check and handle if the system was resumed from Standby mode */ , H% ?+ d5 S( D3 K0 N8 g, z if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)9 `: @9 L! v. O: E. k; Y. B1 ], ]6 H# K { /* Clear Standby flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); //如果是唤醒状态,则LED亮3秒 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED4 K- ^; Y" U" k2 ^ HAL_Delay(3000);: X% u9 y+ t5 k6 n! C2 `$ c HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);3 k L4 z6 c; X! O+ |5 ] }8 n. \. s! B! [3 Z) V/ z* B6 b else;/ S5 ]1 b# c( U1 z0 c4 T , M% R- E. N% ?: g/ S /* Configure the system Power */ SystemPower_Config(); - |5 Z# \7 F" V% x/ N /* Insert 1 seconds delay */ HAL_Delay(1000);9 M# h& G; S& ]3 k7 _ /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry mainly when using more than one wakeup source this is to not miss any wakeup event.5 W; a% h# |: Y: B6 }* | - Disable all used wakeup sources,( P% p4 z+ Q: N1 X B" a) { - Clear all related wakeup flags, 8 l7 J4 q* n$ \9 w. v# o1 e - Re-enable all used wakeup sources, - Enter the Standby mode.# o4 h' H! M0 G$ j */! W- o0 I, t, T9 ^# Y$ D% ]" S /*Disable all used wakeup sources: Pin1(PA.0)*/0 z' t& n% F0 B+ Q0 g2 E HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); /*Clear all related wakeup flags*/ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);" q( X) y- y+ ~# M /*Re-enable all used wakeup sources: Pin1(PA.0)*/& D9 j n \4 a HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);! N* V& H4 I, i( i' C- z /*Enter the Standby mode*/, h: L# _" I& K' Y6 w7 W' i4 I HAL_PWR_EnterSTANDBYMode();; g: B d! t7 A3 B# V 5 h! }+ E" ^0 r while (1) { } }/ Y; v8 B; M0 j3 e3 F1 \ |
PWR_STANDBY.rar
下载4.04 MB, 下载次数: 28
谢楼上支持
谢楼上支持
学习学习