打印
[STM32L0]

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

[复制链接]
1300|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
本帖最后由 mmuuss586 于 2019-1-25 17:04 编辑

NUCLEO-L053R8:低功耗待机模式standby/RTC唤醒(例程分享)
待机模式唤醒后等同复位
基于ST官方NUCLEO-L053R8开发板
用RTC唤醒,实际效果是LED一直在闪
代码下载:见附件
standby mode with RTC:0.85uA 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)
  {
  }
}


PWR_STANDBY_RTC.rar

4.02 MB

沙发
mmuuss586|  楼主 | 2019-1-25 17:05 | 只看该作者

使用特权

评论回复
板凳
stm32jy| | 2019-1-25 19:10 | 只看该作者
不错,赞一个

使用特权

评论回复
地板
mmuuss586|  楼主 | 2019-1-25 20:58 | 只看该作者
谢楼上支持

使用特权

评论回复
5
mmuuss586|  楼主 | 2019-2-3 20:05 | 只看该作者

使用特权

评论回复
6
mcuyuan| | 2019-2-3 20:59 | 只看该作者
感谢楼主分享

使用特权

评论回复
7
mmuuss586|  楼主 | 2019-2-4 10:25 | 只看该作者
谢楼上支持

使用特权

评论回复
8
磨砂| | 2019-3-1 12:45 | 只看该作者
非常感谢楼主分享

使用特权

评论回复
9
mmuuss586|  楼主 | 2019-3-1 13:03 | 只看该作者
谢楼上支持;

使用特权

评论回复
10
mmuuss586|  楼主 | 2019-10-20 14:42 | 只看该作者

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:欢迎进入21IC论坛 游名科技:提供直流无刷电机驱动整体解决方案

696

主题

32675

帖子

440

粉丝