|
NUCLEO-L053R8:低功耗待机模式standby/RTC唤醒(例程分享) 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用RTC唤醒,实际效果是LED一直在闪 代码下载:见附件 standby mode with RTC:0.85uA VDD=3.0V /** * @brief Main program; D( [8 [7 @% v * @param None * @retval None */ int main(void) { /* STM32L0xx HAL library initialization:; I0 j4 x7 i# h4 n; e# C# P - Configure the Flash prefetch, Flash preread and Buffer caches! Y1 D" \& U# g% j6 r4 S - Systick timer is configured by default as source of time base, but user 3 j5 E9 L7 O6 ]# E can eventually implement his proper time base source (a general purpose 9 W) C2 D. k, D! N timer for example or other time source), keeping in mind that Time base 0 y9 D2 t: N! q4 ~; k- t/ H duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and - J! ?% H' k1 ?( }" D. I handled in milliseconds basis. - Low Level Initialization5 {7 U; i- c4 r8 T4 u, c4 o- M! Z */- c4 ~+ q. A7 h. K& Z$ d HAL_Init(); /* Configure LED2 */ BSP_LED_Init(LED2); /* Configure the system clock to 2 MHz */ SystemClock_Config();+ q$ e' v: b: G$ |$ r, u 9 ^5 W; N+ V9 ^ /* Check and handle if the system was resumed from Standby mode */ if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)% G3 Q! m! P+ J ]- e8 \- Y( b {% X1 G2 M% h( I' v4 E: X& J /* Clear Standby flag */) b" A8 u. t3 q' y3 L( f __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);! |6 J. {+ Z! f& E. c! ]4 J3 G- h //如果是唤醒状态,则LED亮3秒 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED2 M/ m3 x3 f( ?' ?+ M HAL_Delay(3000); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);7 {. k* n; Z* V/ {" M$ K- d; w& p1 j }/ R7 f4 Z! q4 ]2 N$ k7 d* u else;, U. y3 C# h% F) g % X! x* H1 j' W! C /* Configure the system Power */ SystemPower_Config(); 7 i* {; ~8 j: b8 t/ i7 D. s1 K, j /* Insert 1 seconds delay */& }* h3 ]) w+ ] HAL_Delay(1000); /*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./ b% b1 d% Q' C - Disable all used wakeup sources, - Clear all related wakeup flags, 6 K8 y4 _& i$ e( u$ M: | - Re-enable all used wakeup sources, - Enter the Standby mode. */ /*Disable all used wakeup sources: Pin1(PA.0)*/ HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); /*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);+ Q8 W( k& F& p! N6 t6 C) B1 l /*Enter the Standby mode*/5 [ E1 g9 [4 u" p4 X HAL_PWR_EnterSTANDBYMode(); 9 _" ^7 ^" \. i while (1) { }0 E K$ E; Q# e& k: ?+ r* E6 O }
|
PWR_STANDBY_RTC.rar
下载4.02 MB, 下载次数: 66
微信公众号
手机版
谢楼上支持
谢楼上支持
学习学习