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

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

[复制链接]
mmuuss586 发布时间:2019-1-25 17:03
NUCLEO-L053R8:低功耗待机模式standby/RTC唤醒(例程分享)0 I) y5 m, ^1 x
待机模式唤醒后等同复位
基于ST官方NUCLEO-L053R8开发板
用RTC唤醒,实际效果是LED一直在闪
代码下载:见附件
standby mode with RTC:0.85uA VDD=3.0V
/**
! Z" q( R# p& e( w9 V* @brief  Main program
( s( w) ^; l8 y8 I7 z) q* @param  None+ b# N, u0 _! q! z; l2 J4 e1 U
* @retval None3 F: u* c% m+ a0 o  M& r  \9 Q
*/
$ d1 o7 a/ X9 ]% }/ g" Cint main(void)
8 q; m0 A" _/ Q, F5 P% V+ D6 _$ y{  
6 [# X  d, e' c+ F4 f! N) e( ^  /* STM32L0xx HAL library initialization:6 A8 s' y" P+ Z2 H
       - Configure the Flash prefetch, Flash preread and Buffer caches, x5 e9 ~' T" ?9 `
       - Systick timer is configured by default as source of time base, but user
# D* `: I; R# I& G# W, P3 H             can eventually implement his proper time base source (a general purpose
( b0 V9 H" u* R# h: z% S1 h" D; f             timer for example or other time source), keeping in mind that Time base
0 {  R$ n5 }1 g6 }2 }# s, L/ D             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 0 F9 _' k& ]- f
             handled in milliseconds basis.6 P0 Y2 b+ ^, M3 E
       - Low Level Initialization7 q! c7 j5 L, i. n4 j  ^  Z6 Y
     */. P' G: {# E1 W' ?, Z4 ]
  HAL_Init();' Y! X$ x( k) u$ r  Y( v+ {
  /* Configure LED2 */
9 M! F4 T* h8 Q' |! R& X! b  BSP_LED_Init(LED2);& H/ D( r2 t! I- l
  /* Configure the system clock to 2 MHz */; [: @# L% n; h
  SystemClock_Config();  }+ g% S& C  C; G1 c

0 E0 ^8 T2 U4 F0 H9 s6 F  /* Check and handle if the system was resumed from Standby mode */
0 d2 m& F- `, [' M! e" C+ R  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
- @% D! M' p9 J2 x, i  {7 u& u$ h, s0 u! p6 \6 V9 |
    /* Clear Standby flag */
! U0 R2 F; K2 _) ^    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);8 |, I  z5 X5 _7 g1 g# j
//如果是唤醒状态,则LED亮3秒
0 S# v5 t* x9 {9 z0 a2 @HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);        //点亮LED,延时3S,再灭LED
4 V. \: u; X; KHAL_Delay(3000);' c! a) D; D) b; N
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
4 d8 v7 q+ b! U( u/ ^: o  }" z. U# p9 @9 _& F' O2 Z
else;
0 B9 J, K8 `9 I7 f8 [* Q    M) c1 ?; R9 P7 Z8 B6 b
/* Configure the system Power */$ D/ ^" a( V5 h3 Q, [+ m; g4 }
  SystemPower_Config();% g7 D& ?$ l/ g- n0 I3 s
  
# |8 X" O, Z- O- [% i+ u  /* Insert 1 seconds delay */6 V* d& U7 F$ ^+ v7 S
  HAL_Delay(1000);% N/ l9 `# O: t; `6 k
    /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry
9 m1 k8 `2 X1 p# R; j     mainly  when using more than one wakeup source this is to not miss any wakeup event.
0 M1 y# L3 ~$ a/ d) T# W3 l& o       - Disable all used wakeup sources,
5 F& q6 A- e( H0 F; n' s/ U& v9 }       - Clear all related wakeup flags, ' h% j% ]2 F1 Y4 `
       - Re-enable all used wakeup sources,2 B7 V0 u& x  e' x0 b( {
       - Enter the Standby mode.6 W" u) g( t: W" T0 D5 w
     */4 Q$ x: S2 U! m
  /*Disable all used wakeup sources: Pin1(PA.0)*/
* V( S; N& a: }1 x  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
9 m9 R/ a; C$ j& V' q" @% j  , {2 @2 L: S( E  }- l
  /*Clear all related wakeup flags*/
+ ?$ r! I! \6 }2 ]& U- x. ?  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
7 c7 b( ?7 y7 E/ }6 ~+ C  . ~* n' F" D0 d* K) k6 v7 Q
  /*Re-enable all used wakeup sources: Pin1(PA.0)*/6 w( y  X, _1 b3 B$ a* a, W
  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
0 {/ v2 l- P+ O  _4 c% P: t' G& I  
1 r0 v1 ^, _- A6 {8 w  T# u  /*Enter the Standby mode*/; ~- C* m5 R- B* u4 O& Q$ T
  HAL_PWR_EnterSTANDBYMode();
3 X: X" M* y# N! H' q) b6 F! g3 H  # ?0 z& G2 o* O2 l( e; R
  while (1)4 ?$ l& n' v2 {' @8 W0 K
  {( s0 J$ R% f9 G* |
  }) b; K! V$ L" v, z# _) a4 C
}
1.png
2.png
3.jpg
/ @3 R2 L) c0 i7 F

PWR_STANDBY_RTC.rar

下载

4.02 MB, 下载次数: 66

赞 收藏 1 评论19 发布时间:2019-1-25 17:03

举报

19个回答
generalcircuits 回答时间:2019-8-1 15:44:48
支持一下,原创不容易,楼主这么辛苦
justmei 回答时间:2019-3-16 21:52:45
你这个是pin唤醒不是RTC唤醒。。
mmuuss586 回答时间:2019-8-4 13:31:19

; ]# h. H1 I$ ~8 @; f谢楼上支持
mmuuss586 回答时间:2019-1-25 17:04:20
Kevin_G 回答时间:2019-1-26 09:19:24
还可以
mmuuss586 回答时间:2019-1-26 10:30:48
谢楼上支持
mmuuss586 回答时间:2019-2-3 20:14:14
mmuuss586 回答时间:2019-3-18 09:46:33
5 B1 m2 P+ B) o6 g
谢楼上支持
mmuuss586 回答时间:2019-6-18 12:47:09

* X3 U) V3 K2 j6 w' r学习学习
mmuuss586 回答时间:2019-7-26 09:23:27
:D:D:D
mmuuss586 回答时间:2019-8-1 09:28:25
:D
mmuuss586 回答时间:2019-8-1 09:28:42
:D:D:D
mmuuss586 回答时间:2019-8-16 09:25:56
:D:D:D
mmuuss586 回答时间:2019-10-4 13:33:01
12下一页
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版