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

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

[复制链接]
mmuuss586 发布时间:2019-1-25 16:30
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)
, q4 |! E9 l6 |8 R7 F  {
待机模式唤醒后等同复位
基于ST官方NUCLEO-L053R8开发板
用PA0引脚唤醒(用杜邦线接高电平唤醒)
代码下载:见附件
standby mode without RTC:0.29uA VDD=3.0V
/**
( R/ J# {0 q( e* @brief  Main program
* `9 D8 _# j& L5 \* @param  None) K1 F6 N+ Q+ f; ]/ W
* @retval None
. `* m3 m6 ]6 H*/
9 V* O: Q# g4 x2 Pint main(void)# b$ l2 F# O& e3 i6 d3 \8 u* u
{  2 b: c4 b5 e+ s6 A
  /* STM32L0xx HAL library initialization:
- O4 e" ?; G, K  r       - Configure the Flash prefetch, Flash preread and Buffer caches
6 j2 M/ |+ ]  k) l       - Systick timer is configured by default as source of time base, but user + S" d/ O8 q/ I$ ]0 W; R) A
             can eventually implement his proper time base source (a general purpose 3 L/ {; p9 }0 |% y3 A
             timer for example or other time source), keeping in mind that Time base
& A/ n+ |' J7 l( e7 I             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and $ l: R4 V/ d' b' K2 A; A
             handled in milliseconds basis.
4 _. T9 w2 p: T5 c9 }9 L: z# Q       - Low Level Initialization
$ X8 d( d4 R; Q6 F6 Z     */
- ]5 j) y3 V* e  HAL_Init();  H4 t$ ~+ N5 a! e$ l% d
8 z% q# o+ Q: Z7 p* `
  /* Configure LED2 */# \1 j/ Y' d+ }! W; `
  BSP_LED_Init(LED2);
$ W6 ?* C, B+ o) y* b
, x; F8 _8 w+ \' M* U  /* Configure the system clock to 2 MHz */
0 U- A7 a. \% s3 _8 [* M. f  SystemClock_Config();
- W2 Y3 d: G$ f' P: z$ `6 Y
; t, k3 G3 R; V0 D5 J8 @5 W/ I- g9 A$ R/ i" c* W
  /* Check and handle if the system was resumed from Standby mode */ 8 r; Q8 y; m7 E5 m' R5 i
  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
" G) v4 {* S. e* B+ D  {
, S; ^7 z, c& p% t& t4 ~4 A    /* Clear Standby flag */  r& k9 P$ v0 |) e. a; J* o
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
7 `, h' m4 j& l1 ^+ B2 J& z
3 m+ N/ ^# Q+ L$ T3 @2 V//如果是唤醒状态,则LED亮3秒
! D' m8 s) R. [& Z# ~% UHAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);        //点亮LED,延时3S,再灭LED
; _$ e% e- g' e' DHAL_Delay(3000);8 h& M6 x' r  s! [
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
% ]: i0 d2 L4 q7 p& {/ F  }
- O$ U, J+ I( p5 Jelse;1 {& k( \- Q$ k4 q. z
  
& x! s/ Y" p: X- G/* Configure the system Power */4 l) j. a( z0 j
  SystemPower_Config();. {  f0 P) J" w) q
  
1 |+ s) m. Y$ A. o# r  /* Insert 1 seconds delay */
$ V" {2 X3 N5 N5 B  HAL_Delay(1000);" _  e. S: u1 l1 D

: R: i( N' |9 J' M* g; o    /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry
5 C6 @- [! R2 r$ E* E: r     mainly  when using more than one wakeup source this is to not miss any wakeup event.8 J" m& R# c+ b( o. A) R: u$ v
       - Disable all used wakeup sources,
8 P) h$ b( I* k2 o( R/ ^7 s0 B       - Clear all related wakeup flags, ' z3 g/ z0 O3 P2 g" a1 r( O
       - Re-enable all used wakeup sources,
3 j9 V# B3 V! Y7 L       - Enter the Standby mode.
( d4 A8 N: U# T, Z; S     */9 y- j0 {' @/ }, g* t
  /*Disable all used wakeup sources: Pin1(PA.0)*/7 r9 j; B; L0 R$ U
  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
9 G2 [* y( c! |+ v. `1 s3 y; d  / f& L4 B7 p  F# V  O3 X
  /*Clear all related wakeup flags*/
* D# S3 }" w2 x, y  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
9 p5 }% G' |, z  p  
/ D7 D$ a: M& S: L' q  /*Re-enable all used wakeup sources: Pin1(PA.0)*/
3 j$ T+ o7 f* O  s. ~/ W6 W" |  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
3 n  S8 z8 ^0 X( h4 R  " a0 F2 n, Q0 X& d8 I
  /*Enter the Standby mode*/
' x" ]4 g( t' S  HAL_PWR_EnterSTANDBYMode();& D; g% K, ]$ r
  
" b) Q9 K9 z# Q8 q  while (1)1 k5 W% l. J. m8 s3 @
  {+ R  m0 f+ e0 p( L
  }, p; Y9 h; K: V7 Y. i+ m
}
5 p" R3 h  p( g) K) F: t0 k& }: p
1.png
2.png
3.jpg

1 n+ z' q( W+ ?4 F1 U

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

' t' C7 v+ Z6 Y9 I0 e' i; R: I. r谢楼上支持
mmuuss586 回答时间:2019-1-27 10:09:33

- n! V$ n% a. [; `谢楼上支持
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

- w; a& n( V! f2 q( k! u$ {: f( h学习学习
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 手机版