|
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享) 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用PA0引脚唤醒(用杜邦线接高电平唤醒) 代码下载:见附件 standby mode without RTC:0.29uA VDD=3.0V /** * @brief Main program * @param None) K1 F6 N+ Q+ f; ]/ W * @retval None */ int main(void)# b$ l2 F# O& e3 i6 d3 \8 u* u { 2 b: c4 b5 e+ s6 A /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches - Systick timer is configured by default as source of time base, but user + S" d/ O8 q/ I$ ]0 W; R) A can eventually implement his proper time base source (a general purpose 3 L/ {; p9 }0 |% y3 A 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 $ l: R4 V/ d' b' K2 A; A handled in milliseconds basis. - Low Level Initialization */ HAL_Init(); H4 t$ ~+ N5 a! e$ l% d 8 z% q# o+ Q: Z7 p* ` /* Configure LED2 */# \1 j/ Y' d+ }! W; ` BSP_LED_Init(LED2); /* Configure the system clock to 2 MHz */ SystemClock_Config(); 5 W/ I- g9 A$ R/ i" c* W /* Check and handle if the system was resumed from Standby mode */ 8 r; Q8 y; m7 E5 m' R5 i if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) { /* Clear Standby flag */ r& k9 P$ v0 |) e. a; J* o __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); //如果是唤醒状态,则LED亮3秒 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED HAL_Delay(3000);8 h& M6 x' r s! [ HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); } else;1 {& k( \- Q$ k4 q. z /* Configure the system Power */4 l) j. a( z0 j SystemPower_Config();. { f0 P) J" w) q /* Insert 1 seconds delay */ HAL_Delay(1000);" _ e. S: u1 l1 D /*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.8 J" m& R# c+ b( o. A) R: u$ v - Disable all used wakeup sources, - Clear all related wakeup flags, ' z3 g/ z0 O3 P2 g" a1 r( O - Re-enable all used wakeup sources, - Enter the Standby mode. */9 y- j0 {' @/ }, g* t /*Disable all used wakeup sources: Pin1(PA.0)*/7 r9 j; B; L0 R$ U HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); / f& L4 B7 p F# V O3 X /*Clear all related wakeup flags*/ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /*Re-enable all used wakeup sources: Pin1(PA.0)*/ HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); " a0 F2 n, Q0 X& d8 I /*Enter the Standby mode*/ HAL_PWR_EnterSTANDBYMode();& D; g% K, ]$ r while (1)1 k5 W% l. J. m8 s3 @ {+ R m0 f+ e0 p( L }, p; Y9 h; K: V7 Y. i+ m }5 p" R3 h p( g) K) F: t0 k& }: p
|
PWR_STANDBY.rar
下载4.04 MB, 下载次数: 28
微信公众号
手机版
谢楼上支持
谢楼上支持
学习学习