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

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

[复制链接]
mmuuss586 发布时间:2019-1-25 16:30
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
2 A' o4 ]7 H0 Q2 U9 L* @param  None
6 u' I8 @+ n! t3 V6 C4 Y; }* @retval None
5 g2 d- @' O2 T& W2 y*/
+ O- h/ `" }) v' ~9 ]- y8 q4 D& aint main(void)4 h/ _( P  e+ ?( ]4 r
{  
- P( P: O  y0 t: _  `0 a. O  /* STM32L0xx HAL library initialization:
! C; z7 o# |3 k3 {' h# e4 B       - 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
& u9 A: v; M, ]; p, T             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
7 Q: F$ N2 i0 K4 J! E4 \" e             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

8 O" O+ N6 ]0 r+ V4 ]& h  /* Configure LED2 */
  O: f/ C5 w8 A  p2 J8 M, g( `  BSP_LED_Init(LED2);9 N$ `" t! N5 v: z! k9 N6 Q

7 _2 }: {# Z& K  /* 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$ [

/ |, \# z+ q# X4 S. ^7 s; H% C- j+ i$ O& F0 u
  /* Check and handle if the system was resumed from Standby mode */
! R; K8 e. A; v' j' X' E  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
- ]4 X9 Y, U  N2 t  {
; p' w! w9 X& h! L7 K* w- e    /* Clear Standby flag */
+ f& l* T( P) E6 d$ d) Q! G( B2 ]5 }    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
  p$ E( _  Q' ?( R- f; @9 G. ]/ ^5 N( A" ]5 K8 S0 c8 l1 C6 d
//如果是唤醒状态,则LED亮3秒
5 o' F- x3 s" z4 KHAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);        //点亮LED,延时3S,再灭LED
) f- Q, m3 S+ I& QHAL_Delay(3000);
) L. p/ z3 D+ T7 B5 \) Q; v8 f; B  {HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);/ o% u; p9 x' u: r$ h: l" T
  }
) j7 Z. e! G8 c7 yelse;6 P$ T3 ]1 D9 H$ o
  ! S( t9 D: F0 t
/* Configure the system Power */) Q& ]% E! J3 q) H9 Y
  SystemPower_Config();
0 ~  z4 @8 F: M3 A9 F" {' L  ) @7 @2 r1 |$ j5 [- t7 Z/ y
  /* Insert 1 seconds delay */8 b+ z' u' W1 q
  HAL_Delay(1000);
$ O, X% T( m. V1 i
  j- g4 O, ~) [7 P* T0 y    /*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.
* _3 E4 B0 F3 F  l' e; t! g       - 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,
8 {( X# @8 P) a) }       - Enter the Standby mode.
' g! ~, i+ }. p* ~. G% u     */
8 L% \8 F: ]3 U7 Q) B9 g  /*Disable all used wakeup sources: Pin1(PA.0)*/
2 J0 G1 u/ J  [; A) W' C  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
* p2 C6 W9 j+ {' `$ U  + u! _- `+ N9 J2 r/ j
  /*Clear all related wakeup flags*/6 U' ~- r9 ^# O
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
. _3 S' l) O* Y  i# H  6 w8 @+ \2 G; h' N" Y
  /*Re-enable all used wakeup sources: Pin1(PA.0)*/
$ l5 k( U& P) K& Z5 v  A+ K8 x  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*/
9 a! f4 G& l9 J5 I& i! f  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 ^
1.png
2.png
3.jpg

9 `4 `: {2 L8 C4 S

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
) n% {  W1 ?6 |9 B6 V7 P; n7 F
谢楼上支持
mmuuss586 回答时间:2019-1-27 10:09:33

4 S$ D# P! L9 }6 d- N" z( ]+ K谢楼上支持
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

- X% {( z$ V; \3 y4 j' N7 g: n学习学习
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管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版