|
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)# o0 s( f. I( X 待机模式唤醒后等同复位 基于ST官方NUCLEO-L053R8开发板 用PA0引脚唤醒(用杜邦线接高电平唤醒) 代码下载:见附件 standby mode without RTC:0.29uA VDD=3.0V /**; r: L8 |0 t* Q& P; g, d( C * @brief Main program * @param None * @retval None */ int main(void)4 h/ _( P e+ ?( ]4 r { /* STM32L0xx HAL library initialization: - Configure the Flash prefetch, Flash preread and Buffer caches; N* z" w3 W" u' D - Systick timer is configured by default as source of time base, but user ) N% a9 P: H5 E: N can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base 3 |. `2 i4 A* [' I4 b/ e" U3 o, m, t duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis.2 H+ n( B! K; x! O% a' ~0 u - Low Level Initialization! {& @8 U1 u2 P4 k */8 j7 z7 j9 p: y, i. a% J% p5 M HAL_Init();2 V" W$ T# k+ N( o6 j /* Configure LED2 */ BSP_LED_Init(LED2);9 N$ `" t! N5 v: z! k9 N6 Q /* Configure the system clock to 2 MHz */2 x7 q8 [9 [0 E1 ` SystemClock_Config();, z6 s; }! d& r4 y8 A: u8 X& c& \" W$ [ % C- j+ i$ O& F0 u /* Check and handle if the system was resumed from Standby mode */ if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) { /* Clear Standby flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); / ^5 N( A" ]5 K8 S0 c8 l1 C6 d //如果是唤醒状态,则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);/ o% u; p9 x' u: r$ h: l" T } else;6 P$ T3 ]1 D9 H$ o ! S( t9 D: F0 t /* Configure the system Power */) Q& ]% E! J3 q) H9 Y SystemPower_Config(); ) @7 @2 r1 |$ j5 [- t7 Z/ y /* Insert 1 seconds delay */8 b+ z' u' W1 q HAL_Delay(1000); /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry) X/ l* l% \4 z9 ?1 ] mainly when using more than one wakeup source this is to not miss any wakeup event. - Disable all used wakeup sources,7 K4 h# @* a4 ~4 k( |4 r- @, J( y - Clear all related wakeup flags, ) o0 l3 N0 U) V ~+ ` - Re-enable all used wakeup sources, - Enter the Standby mode. */ /*Disable all used wakeup sources: Pin1(PA.0)*/ HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1); + u! _- `+ N9 J2 r/ j /*Clear all related wakeup flags*/6 U' ~- r9 ^# O __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); 6 w8 @+ \2 G; h' N" Y /*Re-enable all used wakeup sources: Pin1(PA.0)*/ HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);; G* r- _: K% X; P4 z ' d4 ]' x3 O% i$ V/ F; i% i* e: r+ S /*Enter the Standby mode*/ HAL_PWR_EnterSTANDBYMode();" c" `4 N& {$ w* Z " \- C3 Y+ v, ~4 }, e0 v while (1)4 R/ ~4 `3 V; c7 K* v+ Y4 V \* T {) O5 A/ K' V% c+ l" C }2 `7 F. p7 a' l' q! y' }0 `) { }/ R$ ]+ M8 O0 O. R; |" D% x) ]0 ^
|
PWR_STANDBY.rar
下载4.04 MB, 下载次数: 28
微信公众号
手机版
谢楼上支持
谢楼上支持
学习学习