你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)

[复制链接]
mmuuss586 发布时间:2019-1-25 16:30
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)
# s$ c+ D0 n4 {- i- p+ x& I  l, ~
待机模式唤醒后等同复位
基于ST官方NUCLEO-L053R8开发板
用PA0引脚唤醒(用杜邦线接高电平唤醒)
代码下载:见附件
standby mode without RTC:0.29uA VDD=3.0V
/**
' [+ w. O+ x6 W8 t4 ]/ o! A& n0 F+ r* @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
  J2 g1 ^/ ]  z% Y*/
. K. G! w0 z$ L7 s6 f1 Dint 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
) w0 E9 h1 R5 e/ E             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.
% y- p' E" \7 a$ w" _7 l       - Low Level Initialization
" y) |$ Q3 F3 V3 M! a0 |     */+ _& 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秒
6 t5 M7 ^6 d1 ~; `HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);        //点亮LED,延时3S,再灭LED
% v: o' N) T( N) B& P( |HAL_Delay(3000);
" d- C; O: [, G4 ^HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
* l2 O- m4 B+ o8 }  i  {! D  }
+ L9 ~. M1 u" ~2 Felse;
+ R' h- Y1 J9 z* V  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 */
: S% z9 B# R4 e  HAL_Delay(1000);% c4 @- J4 k' S1 g' }8 d

7 w- x: R4 ~- r2 W8 u8 l( r    /*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.
/ o  ~( b$ x0 @. C       - Disable all used wakeup sources,& v5 |4 u( G2 J. l
       - Clear all related wakeup flags,
1 t. [; r. V/ y% k       - Re-enable all used wakeup sources,
& u6 N; a  I/ }3 Z       - Enter the Standby mode.
6 }8 Z7 e; f6 M7 I/ a( |% }/ C     */
. S7 }1 H9 J- D  /*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
  
1 ?8 V( M( C8 G0 E+ Y  /*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);
9 S  C1 [; J( S/ u4 k  
( R2 M$ U& s$ z  /*Enter the Standby mode*/
8 B  N3 Z2 N- R% }! f  HAL_PWR_EnterSTANDBYMode();
: `& A7 E" ^& |' ~+ b  
8 Z) d, N& z( n$ o+ C& w/ @  while (1)
6 _+ G  M/ c1 Z9 F" F# Y- `  {% c' ^, b9 m9 Z: x3 ^
  }
$ [, r+ k3 o1 n' z( c/ I; n. F! Z$ \}
: b# g4 [% k6 H7 i6 `+ V/ R
1.png
2.png
3.jpg
/ y8 g; N5 _- [' q

PWR_STANDBY.rar

下载

4.04 MB, 下载次数: 28

收藏 1 评论16 发布时间:2019-1-25 16:30

举报

16个回答
generalcircuits 回答时间:2019-9-5 15:16:28
感谢分享,学习一下
mmuuss586 回答时间:2019-9-2 09:05:35
. m* p; d+ _$ C! ~" c! b: ~6 \" K1 p# U
谢楼上支持
mmuuss586 回答时间:2019-1-27 10:09:33
9 R$ p; f6 S/ y
谢楼上支持
mmuuss586 回答时间:2019-1-25 16:31:04
Kevin_G 回答时间:2019-1-26 16:23:27
参考参考
mmuuss586 回答时间:2019-2-3 20:13:56
:):):)
mmuuss586 回答时间:2019-6-18 12:46:51
# t* M9 a; V8 s7 v( Y
学习学习
mmuuss586 回答时间:2019-7-26 09:23:11
:D:D:D
mmuuss586 回答时间:2019-8-16 09:24:21
:D
datouren 回答时间:2019-9-2 08:43:01
参考下。。。。。。。
mmuuss586 回答时间:2019-9-10 12:36:28
感谢支持
mmuuss586 回答时间:2019-10-4 13:32:05
mmuuss586 回答时间:2019-10-4 13:32:27
:D
mmuuss586 回答时间:2019-10-7 21:31:33
:(
12下一页

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版