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

NUCLEO-L053R8:低功耗STOP模式,RTC唤醒(例程分享)  

[复制链接]
mmuuss586 发布时间:2019-1-25 13:39
NUCLEO-L053R8:低功耗STOP模式,RTC唤醒(例程分享)
基于ST官方NUCLEO-L053R8开发板
代码下载:见附件
Stop mode with RTC:1uA 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 to handle error handler */
  BSP_LED_Init(LED2);

  /* Configure the system clock @ 32 Mhz */
  SystemClock_Config();

  /* Configure the system Power */
  SystemPower_Config();

  while (1)
  {
    /* Insert 3 seconds delay */
    BSP_LED_Init(LED2);        //LED初始化
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);
HAL_Delay(3000);
SystemPowerNORTC_Config();        //关闭所有IO和时钟,不关闭RTC

    /* Disable Wakeup Counter */
    HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);

    /*## Setting the Wake up time ############################################*/
    /*  RTC Wakeup Interrupt Generation:
        Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI))
        Wakeup Time = Wakeup Time Base * WakeUpCounter
                    = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter
        ==> WakeUpCounter = Wakeup Time / Wakeup Time Base

        To configure the wake up timer to 4s the WakeUpCounter is set to 0x1FFF:
          RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16
          Wakeup Time Base = 16 /(~39.000KHz) = ~0,410 ms
          Wakeup Time = ~4s = 0,410ms  * WakeUpCounter
          ==> WakeUpCounter = ~4s/0,410ms = 9750 = 0x2616 */
    HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x2616, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

    /* Enter Stop Mode */
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

    /* Configures system clock after wake-up from STOP: enable HSI, PLL and select
    PLL as system clock source (HSI and PLL are disabled automatically in STOP mode) */
    SystemClockConfig_STOP();
  }
}

1.png
2.png
3.jpg


PWR_STOP_RTC.rar

下载

4.03 MB, 下载次数: 95

收藏 4 评论36 发布时间:2019-1-25 13:39

举报

36个回答
mmuuss586 回答时间:2019-1-25 16:03:23
wm20031015 回答时间:2020-6-18 16:22:56
楼主应该拿个万用表实测一下电流是多少,
mmuuss586 回答时间:2019-2-18 17:54:12

谢管理员支持
mmuuss586 回答时间:2019-1-25 13:39:43
Paderboy 回答时间:2019-1-25 13:50:50
多谢分享
mmuuss586 回答时间:2019-1-25 14:40:54

谢版主支持
一代睡神的崛起 回答时间:2019-1-25 14:56:40
谢谢分享
Kevin_G 回答时间:2019-1-26 09:19:05
看看
mmuuss586 回答时间:2019-1-26 10:30:21

谢楼上支持
mmuuss586 回答时间:2019-2-3 20:12:24
STMCU-管管 回答时间:2019-2-18 15:57:30
谢谢分享
wapeace 回答时间:2019-3-22 16:45:32
感谢分享
Kevin_G 回答时间:2019-3-22 19:03:20
赞一个
mmuuss586 回答时间:2019-3-23 08:33:36

谢楼上支持
qianleo 回答时间:2019-5-29 10:29:12
谢谢分享
123下一页

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版