首页 论坛 原厂专区 ST MCU NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)

发帖 回复

[原创] NUCLEO-L053R8:低功耗待机模式standby/PA0唤醒(例程分享)
2878 查看
35 回复
 楼主 | 发布于 2019-01-25 | 只看楼主
分享到:

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

待机模式唤醒后等同复位

基于ST官方NUCLEO-L053R8开发板

用PA0引脚唤醒(用杜邦线接高电平唤醒)

代码下载:见附件

standby mode without RTC:0.29uA VDD=3.0V

/**
* @brief  Main program
* @param  None
* @retval None
*/
int main(void)
{  
  /* STM32L0xx HAL library initialization:
       - Configure the Flash prefetch, Flash preread and Buffer caches
       - Systick timer is configured by default as source of time base, but user 
             can eventually implement his proper time base source (a general purpose 
             timer for example or other time source), keeping in mind that Time base 
             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
             handled in milliseconds basis.
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure LED2 */
  BSP_LED_Init(LED2);

  /* Configure the system clock to 2 MHz */
  SystemClock_Config();


  /* Check and handle if the system was resumed from Standby mode */ 
  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
  {
    /* Clear Standby flag */
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);

//如果是唤醒状态,则LED亮3秒
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); //点亮LED,延时3S,再灭LED
HAL_Delay(3000);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
  }
else;
  
/* Configure the system Power */
  SystemPower_Config();
  
  /* Insert 1 seconds delay */
  HAL_Delay(1000);

    /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry
     mainly  when using more than one wakeup source this is to not miss any wakeup event.
       - Disable all used wakeup sources,
       - Clear all related wakeup flags, 
       - Re-enable all used wakeup sources,
       - Enter the Standby mode.
     */
  /*Disable all used wakeup sources: Pin1(PA.0)*/
  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
  
  /*Clear all related wakeup flags*/
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
  
  /*Re-enable all used wakeup sources: Pin1(PA.0)*/
  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
  
  /*Enter the Standby mode*/
  HAL_PWR_EnterSTANDBYMode();
  
  while (1)
  {
  }
}


本帖有更多资源,需 登录 才可以下载,没有帐号?立即 注册

(0 ) (0 )
回复 举报

回复于 2019-02-09 11#

谢谢分享
(0 )
评论 (0) 举报

回复于 2019-02-18 12#

感谢分享

!!
(0 )
评论 (0) 举报

回复于 2019-02-28 13#

感谢分享!
(0 )
评论 (0) 举报

回复于 2019-02-28 14#

感谢分享!!!
(0 )
评论 (0) 举报

回复于 2019-03-03 15#

谢谢 分享!!!
(0 )
评论 (0) 举报

回复于 2019-03-06 16#

感谢大神分享!!为方便相互学习交流,新开微信公众号“硬件开发工程师之家,期待大家一起在专业方面资源共享!
(0 )
评论 (0) 举报

回复于 2019-03-11 17#

多谢分享!!!
(0 )
评论 (0) 举报

回复于 2019-03-17 18#

支持下,谢谢分享!
(0 )
评论 (0) 举报

回复于 2019-04-19 19#

(0 )
评论 (0) 举报

回复于 2019-04-21 20#

支持下,谢谢分享~
(0 )
评论 (0) 举报
发表回复
0/3000





举报

请选择举报类别

  • 广告垃圾
  • 违规内容
  • 恶意灌水
  • 重复发帖

全部板块

返回顶部