请选择 进入手机版 | 继续访问电脑版
搜索
查看: 4233|回复: 4

[求助] STM32G0 休眠和唤醒问题

[复制链接]

该用户从未签到

3

主题

4

帖子

0

蝴蝶豆

新手上路

最后登录
2019-1-23
发表于 2019-1-23 11:10:47 | 显示全部楼层 |阅读模式
///////////////////////////////////////////////////////////
在Standby模式休眠后,等RTC时间到后会复位一次。但进入STOP1模式时,RTC无法唤醒系统
////////////////////////////////////////////////////////////
void RCT_Init(void) {
    /* Enable RTC APB clock  */
    LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_RTC);
    LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);

    LL_PWR_EnableBkUpAccess();
    /* Enable LSE only if disabled.*/
    if (LL_RCC_LSE_IsReady() == 0) {
        LL_RCC_ForceBackupDomainReset();
        LL_RCC_ReleaseBackupDomainReset();
        LL_RCC_LSE_Enable();

        while (LL_RCC_LSE_IsReady() != 1) {

        }
        LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSE);
    }
    /* Peripheral clock enable */
    LL_RCC_EnableRTC();

    /////////////////////////////////////////////////
    /* ######## ENABLE WUT #################################################*/
    /* Disable RTC registers write protection */
    LL_RTC_DisableWriteProtection(RTC);
    /* Set prescaler according to source clock */
    LL_RTC_SetAsynchPrescaler(RTC, RTC_ASYNCH_PREDIV);
    LL_RTC_SetSynchPrescaler(RTC, RTC_SYNCH_PREDIV);
    /* Disable wake up timer to modify it */
    LL_RTC_WAKEUP_Disable(RTC);
    /* Wait until it is allow to modify wake up reload value */
    while (LL_RTC_IsActiveFlag_WUTW(RTC) != 1) {

    }
    /* Setting the Wakeup time to RTC_WUT_TIME s
         If LL_RTC_WAKEUPCLOCK_CKSPRE is selected, the frequency is 1Hz,
         this allows to get a wakeup time equal to RTC_WUT_TIME s
         if the counter is RTC_WUT_TIME */
    LL_RTC_WAKEUP_SetAutoReload(RTC, 1);
    LL_RTC_WAKEUP_SetClock(RTC, LL_RTC_WAKEUPCLOCK_CKSPRE);
    /* Enable RTC registers write protection */
    LL_RTC_EnableWriteProtection(RTC);
    /* Disable RTC registers write protection */
    LL_RTC_DisableWriteProtection(RTC); //禁用RTC寄存器写入保护
    /* Enable wake up counter and wake up interrupt */
    /* Note: Periodic wakeup interrupt should be enabled to exit the device
       from low-power modes.*/
    LL_RTC_EnableIT_WUT(RTC); //启用唤醒计数器和唤醒中断(没看见这个中断入口函数)
    LL_RTC_WAKEUP_Enable(RTC); //唤醒使能
    /* Enable RTC registers write protection */
    LL_RTC_EnableWriteProtection(RTC);
    /* Reset Internal Wake up flag */
    LL_RTC_ClearFlag_WUT(RTC);
    /* ######## ENTER IN STANDBY MODE ######################################*/

    /////////////////////////////////////////////////

}

void EnterStandbyMode(void) {


    /* Set Standby mode */
    LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);

    /* Set SLEEPDEEP bit of Cortex System Control Register */
    LL_LPM_EnableDeepSleep();

    /* This option is used to ensure that store operations are completed */


    /* Request Wait For Interrupt */
    __WFI();
}

void EnterSTOP1Mode(void) {


    /* Set STOP1 mode */
    LL_PWR_SetPowerMode(LL_PWR_MODE_STOP1);

    /* Set SLEEPDEEP bit of Cortex System Control Register */
    LL_LPM_EnableDeepSleep();

    /* This option is used to ensure that store operations are completed */


    /* Request Wait For Interrupt */
    __WFI();
}



回复

使用道具 举报

该用户从未签到

8

主题

980

帖子

45

蝴蝶豆

金牌会员

最后登录
2021-11-5
发表于 2019-1-23 12:00:10 | 显示全部楼层
没有看到你定时多久唤醒
回复 支持 反对

使用道具 举报

该用户从未签到

3

主题

4

帖子

0

蝴蝶豆

新手上路

最后登录
2019-1-23
 楼主| 发表于 2019-1-23 14:07:01 | 显示全部楼层
    /* Setting the Wakeup time to RTC_WUT_TIME s
          If LL_RTC_WAKEUPCLOCK_CKSPRE is selected, the frequency is 1Hz,
          this allows to get a wakeup time equal to RTC_WUT_TIME s
          if the counter is RTC_WUT_TIME */
     LL_RTC_WAKEUP_SetAutoReload(RTC, 1);
     LL_RTC_WAKEUP_SetClock(RTC, LL_RTC_WAKEUPCLOCK_CKSPRE);
一秒唤醒一次
回复 支持 反对

使用道具 举报

该用户从未签到

3

主题

4

帖子

0

蝴蝶豆

新手上路

最后登录
2019-1-23
 楼主| 发表于 2019-1-23 14:07:23 | 显示全部楼层
chifen 发表于 2019-1-23 12:00
没有看到你定时多久唤醒

/* Setting the Wakeup time to RTC_WUT_TIME s
           If LL_RTC_WAKEUPCLOCK_CKSPRE is selected, the frequency is 1Hz,
           this allows to get a wakeup time equal to RTC_WUT_TIME s
           if the counter is RTC_WUT_TIME */
      LL_RTC_WAKEUP_SetAutoReload(RTC, 1);
      LL_RTC_WAKEUP_SetClock(RTC, LL_RTC_WAKEUPCLOCK_CKSPRE);
一秒唤醒一次
回复 支持 反对

使用道具 举报

该用户从未签到

0

主题

4

帖子

0

蝴蝶豆

初级会员

最后登录
2021-3-30
发表于 2021-3-30 11:05:40 | 显示全部楼层
c401b953 发表于 2019-1-23 14:07
/* Setting the Wakeup time to RTC_WUT_TIME s
           If LL_RTC_WAKEUPCLOCK_CKSPRE is selected,  ...

请问下 你的问题解决了没?   我也遇到这个问题了,发现是进入stop1模式后  RTC时钟停了,目前没找到原因
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|论坛-意法半导体STM32/STM8技术社区

GMT+8, 2024-4-18 14:30 , Processed in 1.177661 second(s), 37 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表