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

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

[复制链接]
mmuuss586 发布时间:2019-1-25 16:30
NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)6 x. q) X- r1 V9 u! T. H
待机模式唤醒后等同复位
基于ST官方NUCLEO-L053R8开发板
用PA0引脚唤醒(用杜邦线接高电平唤醒)
代码下载:见附件
standby mode without RTC:0.29uA VDD=3.0V
/**' Z5 w0 B  I( h5 b( r
* @brief  Main program2 ?8 t- ~6 t6 I) h; w
* @param  None/ C; z8 I- k0 p7 q
* @retval None
, v) X; t: S3 R: H*/; T4 C" T  L& T- v  v
int main(void)
, M/ ]* ~! d5 Q* Z+ o7 G' V{  
6 B  J* N( l$ O) Z3 T/ o' u- }  /* STM32L0xx HAL library initialization:5 H0 j5 i' u! R; y) @
       - Configure the Flash prefetch, Flash preread and Buffer caches
! s$ Q( d) X+ R       - Systick timer is configured by default as source of time base, but user
( ?$ ]5 a; u; `* h' q             can eventually implement his proper time base source (a general purpose # Y' d  j! U: p# X) h
             timer for example or other time source), keeping in mind that Time base
! p9 K6 D% ?* r             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 6 \( V% O. f* C% D: \  g, o
             handled in milliseconds basis.
( L" W* F" ]* U  `1 X& L$ ], L& H       - Low Level Initialization
4 I% b* L/ _- t+ C* b! X6 r     */7 R/ W! p8 y( {7 J8 E: q- q  j
  HAL_Init();
$ G5 h! l! ~5 W6 N7 z  W. X: I" t
  /* Configure LED2 *// y" n( _" W) T& M) k# ]/ Z8 p
  BSP_LED_Init(LED2);
. a( r" w7 T3 h4 z
" c+ \% N+ p4 V' Q  /* Configure the system clock to 2 MHz */7 Y; x' E: M: p( i6 p% O+ _+ Z
  SystemClock_Config();3 t2 B2 n; |: o& h

, E2 |3 N' s0 }
5 ^% l* J; L) P2 ~0 D  /* Check and handle if the system was resumed from Standby mode */ , H% ?+ d5 S( D3 K0 N8 g, z
  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)9 `: @9 L! v. O: E. k; Y. B1 ], ]6 H# K
  {
8 e' j) O% f" t7 a8 w1 W  a: |    /* Clear Standby flag */
: j0 G, n1 ?' o# E. N    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
3 t4 T  N8 {$ F0 H
! T0 i2 k2 p0 L! e; A& M% ^( f//如果是唤醒状态,则LED亮3秒
: A/ e/ s7 E" R* g; _HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);        //点亮LED,延时3S,再灭LED4 K- ^; Y" U" k2 ^
HAL_Delay(3000);: X% u9 y+ t5 k6 n! C2 `$ c
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);3 k  L4 z6 c; X! O+ |5 ]
  }8 n. \. s! B! [3 Z) V/ z* B6 b
else;/ S5 ]1 b# c( U1 z0 c4 T
  , M% R- E. N% ?: g/ S
/* Configure the system Power */
) r( R/ T& a! a$ e! E* x2 p  SystemPower_Config();
. L9 Q' e" i1 V5 X  - |5 Z# \7 F" V% x/ N
  /* Insert 1 seconds delay */
0 K4 B  {8 i6 D/ O) l# o6 S  HAL_Delay(1000);9 M# h& G; S& ]3 k7 _

3 ]8 x% q, s6 C8 Z    /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry
  E1 X* s6 o3 f: g     mainly  when using more than one wakeup source this is to not miss any wakeup event.5 W; a% h# |: Y: B6 }* |
       - Disable all used wakeup sources,( P% p4 z+ Q: N1 X  B" a) {
       - Clear all related wakeup flags, 8 l7 J4 q* n$ \9 w. v# o1 e
       - Re-enable all used wakeup sources,
+ V0 q6 `: D& H- L9 b1 w! J7 h       - Enter the Standby mode.# o4 h' H! M0 G$ j
     */! W- o0 I, t, T9 ^# Y$ D% ]" S
  /*Disable all used wakeup sources: Pin1(PA.0)*/0 z' t& n% F0 B+ Q0 g2 E
  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
# W" A3 a* d1 j9 j/ L" n0 p  
6 I: m  [( y# |* o% c( q4 K4 o  /*Clear all related wakeup flags*/
3 p9 G& s" T# @* C  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);" q( X) y- y+ ~# M
  
) i" `: I7 ^- e+ S  /*Re-enable all used wakeup sources: Pin1(PA.0)*/& D9 j  n  \4 a
  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);! N* V& H4 I, i( i' C- z
  
  J5 `% ^) _& f  /*Enter the Standby mode*/, h: L# _" I& K' Y6 w7 W' i4 I
  HAL_PWR_EnterSTANDBYMode();; g: B  d! t7 A3 B# V
  5 h! }+ E" ^0 r
  while (1)
$ t* z3 m& M/ E  {
+ Q7 S/ b! Y" W' s  }
2 q/ R7 ~8 o7 `; p6 _. U}
/ Y; v8 B; M0 j3 e3 F1 \
1.png
2.png
3.jpg

. A* |4 W. M0 A

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

) x8 I! Y$ k4 N- V) d- p( w谢楼上支持
mmuuss586 回答时间:2019-1-27 10:09:33

1 g, L+ @, T/ @' X谢楼上支持
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: y+ E, ~& n. g2 P
学习学习
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 手机版