打印
[STM32F0]

STM32F051C8T6进入休眠反复重启,且休眠无法唤醒

[复制链接]
1558|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
owenli520|  楼主 | 2017-7-11 16:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM32F051C8T6进入休眠反复重启,且休眠无法唤醒,代码如下,直接从官方例程拷贝过来用的
        RTC_InitTypeDef   RTC_InitStructure;
        RTC_AlarmTypeDef  RTC_AlarmStructure;
        RTC_TimeTypeDef   RTC_TimeStructure;

        /* Enable the PWR clock */
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

        /* Allow access to Backup Domain */
        PWR_BackupAccessCmd(ENABLE);

        /* Check if the StandBy flag is set */
        if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)
        {      
                /* Clear StandBy flag */
                PWR_ClearFlag(PWR_FLAG_SB);

                /* Check if the StandBy flag is cleared */
                if (PWR_GetFlagStatus(PWR_FLAG_SB) != RESET)
                {
                        while(1);
                }

                RTC_WaitForSynchro();

                /* No need to configure the RTC as the RTC config(clock source, enable,
                prescaler,...) are kept after wake-up from STANDBY */
        }
        else
        {         
                /* RTC Configuration ******************************************************/
                /* Reset Backup Domain */
                RCC_BackupResetCmd(ENABLE);
                RCC_BackupResetCmd(DISABLE);

                /* Enable the LSI OSC */
                RCC_LSICmd(ENABLE);
                /* Wait till LSI is ready */
                while (RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
                {}

                /* Select the RTC Clock Source */
                RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

                /* Enable the RTC Clock */
                RCC_RTCCLKCmd(ENABLE);

                /* Wait for RTC APB registers synchronisation */
                RTC_WaitForSynchro();

                RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
                RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
                RTC_InitStructure.RTC_SynchPrediv = 0x0138;

                RTC_Init(&RTC_InitStructure);

                /* Set the alarm X+5s */
                RTC_AlarmStructure.RTC_AlarmTime.RTC_H12     = RTC_H12_AM;
                RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours   = 0x01;
                RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = 0x00;
                RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = 0x3;
                RTC_AlarmStructure.RTC_AlarmDateWeekDay = 0x31;
                RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
                RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay;
                RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_A, &RTC_AlarmStructure);

                /* Enable RTC Alarm A Interrupt */
                RTC_ITConfig(RTC_IT_ALRA, ENABLE);

                /* Enable the alarm */
                RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
        }

        /* Set the time to 01h 00mn 00s AM */
        RTC_TimeStructure.RTC_H12     = RTC_H12_AM;
        RTC_TimeStructure.RTC_Hours   = 0x01;
        RTC_TimeStructure.RTC_Minutes = 0x00;
        RTC_TimeStructure.RTC_Seconds = 0x00;  

        RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);


        /* Clear Wakeup flag */
        PWR_ClearFlag(PWR_FLAG_WU);      

        RTC_ClearFlag(RTC_FLAG_ALRAF);

        /* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
        PWR_EnterSTANDBYMode();
沙发
owenli520|  楼主 | 2017-7-11 16:38 | 只看该作者
请高手看一下是哪里配置有问题

使用特权

评论回复
板凳
wozaihuayu| | 2017-7-12 10:49 | 只看该作者
主程序中是否开了独立看门狗?

使用特权

评论回复
地板
owenli520|  楼主 | 2017-7-12 11:40 | 只看该作者
wozaihuayu 发表于 2017-7-12 10:49
主程序中是否开了独立看门狗?

没开看门狗

使用特权

评论回复
5
think9do| | 2017-8-30 10:45 | 只看该作者
休眠无法唤醒的问题,有一种可能,就是你的分频设置太大了,导致唤醒时间太长了。
修改为
SynchPrediv = 0x10;
AsynchPrediv = 0x7F;

使用特权

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

本版积分规则

7

主题

57

帖子

0

粉丝