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

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

[复制链接]
mmuuss586 发布时间:2019-1-25 16:30
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)# j/ I8 M" z$ S* Q- Y" G! `3 M
待机模式唤醒后等同复位
基于ST官方NUCLEO-L053R8开发板
用PA0引脚唤醒(用杜邦线接高电平唤醒)
代码下载:见附件
standby mode without RTC:0.29uA VDD=3.0V
/**! o/ |; f( n( ~" U4 L% k6 j; I
* @brief  Main program  q; A, A: G: E$ {1 r
* @param  None
: E, e* b4 Q- p+ Z* m0 q) d* @retval None
; @5 x; K4 J6 O3 v$ A! \- @*/  X7 ?0 m! z& n' s$ b- l3 W
int main(void)1 ?0 x! M: X8 l! P  x/ ]5 W, |
{  
5 m8 Q' J& j$ J+ ~8 q. \  /* STM32L0xx HAL library initialization:
# E/ {* k& H; v+ r       - Configure the Flash prefetch, Flash preread and Buffer caches
% Z% j& @3 {% b/ _. c; S       - Systick timer is configured by default as source of time base, but user ( E; b+ h/ g2 A. z
             can eventually implement his proper time base source (a general purpose / Y- ^8 e: F; k: d8 T# m" R$ D
             timer for example or other time source), keeping in mind that Time base / e# m. o" m3 h! b
             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and & f" o, L7 f7 o, e
             handled in milliseconds basis.( H6 e4 Z4 X9 F/ T8 c; U& K
       - Low Level Initialization# h/ Y6 H& o" l9 I  }2 K/ Y/ D. U8 S  Q
     */* u2 {4 b0 K/ m% d1 i
  HAL_Init();
% |' @+ _- j9 c6 r
0 r$ G, Y! z/ Q; O! e+ I: {4 n  /* Configure LED2 */  I8 u, Q. I( s/ P& v9 h6 E. x( f
  BSP_LED_Init(LED2);
- b: W$ ^0 p- C3 m: V2 E( F0 v2 o  c1 [8 y+ A$ ?$ @- T2 W9 F/ W2 a0 r
  /* Configure the system clock to 2 MHz */7 S( S, F3 w. w5 y7 F
  SystemClock_Config();
# S+ t" J: P: r1 d5 a4 d5 H/ P* p% s! i. T. ~' g3 |7 e9 k

+ S+ l) c, B4 y* n  /* Check and handle if the system was resumed from Standby mode */ $ c! Y! C+ S; l8 L* ~6 `, J% w
  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)$ \2 T. U7 A# W. q- t
  {
" z: q6 G8 q  t6 {; p/ n2 c: q    /* Clear Standby flag */
1 }4 U' r% w% y9 y) w    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);8 A$ O$ s3 N4 T. K* I! T/ N% b9 o9 b: p

7 ^+ U9 }6 V, {& L//如果是唤醒状态,则LED亮3秒
% I' ?5 {' [9 F* t. l& @HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);        //点亮LED,延时3S,再灭LED
9 N* [/ A1 S% K! p1 w: MHAL_Delay(3000);
. a! [6 p2 g$ gHAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
4 w/ m& g1 T. ~$ d$ l& b  }7 p* G& q, X) w5 @% C$ p- t
else;
; j  b) C" G$ f$ n# R( `3 k/ h2 W  ' s' P& a, T' B9 r9 |
/* Configure the system Power */
3 C  |3 S% k' E6 T: ~5 r* b+ j: D  SystemPower_Config();
" |$ p6 C& }7 R& N  
/ z1 _# f0 a! _2 y6 b# k1 y  /* Insert 1 seconds delay */7 }( e  f! A0 o/ ^* @5 l) t5 t
  HAL_Delay(1000);$ j( T4 J! R% @. [1 ]3 f3 p# ^
% R( {- K- e3 l" Q- V" y+ d( ~, s
    /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry3 S# k3 _( n9 h4 O; i8 D
     mainly  when using more than one wakeup source this is to not miss any wakeup event.. c5 p; d- Q% Q, v
       - Disable all used wakeup sources,0 t4 g3 \; x6 l& I+ u
       - Clear all related wakeup flags, 0 v" g( b0 }+ w; }4 \( {; T7 A
       - Re-enable all used wakeup sources,
* L  T7 z1 l- p2 |, Q! f  Q       - Enter the Standby mode.
  U' W# D7 Y/ E# Y7 P     */% d" n# X0 S5 E3 \! o* t  \
  /*Disable all used wakeup sources: Pin1(PA.0)*/: I/ e7 H$ M; L3 R) @% m
  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);* I7 C1 Y) V6 o& T) t
  
3 b4 A4 J+ d" q2 c- _  /*Clear all related wakeup flags*/
& |7 Y. W# v4 w5 @, I, n- s  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);3 m9 l: g* @# ~
  2 U9 j% Y5 J+ j2 O
  /*Re-enable all used wakeup sources: Pin1(PA.0)*/
% |6 p7 r9 s2 m& \  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
, F, ]2 @+ D) Y. H4 L5 b  7 V5 S5 e1 t% C* [! r% z$ Z
  /*Enter the Standby mode*/
  F; N4 T4 O4 t+ \  HAL_PWR_EnterSTANDBYMode();
# R; Z, V, I4 k4 `6 U; Y. o  1 ]8 j6 B  \5 d3 @$ R( m- d( ?
  while (1)8 C& k& j( m6 W( Q& X! R" \% B
  {6 F( o( [1 c' Z4 u4 ^! q
  }' {  H3 D8 j1 H( F
}

& u7 y  N4 I7 z/ I1 s
1.png
2.png
3.jpg
, _; m8 Y$ t' x7 Z) f( W% V9 F

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
5 j, y6 ?& u! e0 p( S
谢楼上支持
mmuuss586 回答时间:2019-1-27 10:09:33
. I! F, T& o; b/ g  d# _% |; J
谢楼上支持
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

0 B. ^$ Y) f( e  Q学习学习
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管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版