OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 8492|回复: 8

STM32L151,待机模式下,分别单独使用PWR_WakeUpPin_1和RTC闹钟唤醒均能唤醒,可两种唤醒方式同时使用时却均唤醒不了,麻烦大家

[复制链接]

6

主题

14

帖子

0

精华

初级会员

Rank: 2

积分
102
金钱
102
注册时间
2017-4-19
在线时间
37 小时
发表于 2017-8-17 13:35:26 | 显示全部楼层 |阅读模式
8金钱
void Sys_Standby(void)
{  
        printf("\r\n 进入待机 ");

//        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);        //使能PWR外设时钟
        PWR_WakeUpPinCmd(PWR_WakeUpPin_1, ENABLE);  //使能唤醒管脚功能
        PWR_WakeUpPinCmd(PWR_WakeUpPin_2, ENABLE);
        PWR_EnterSTANDBYMode();          //进入待命(STANDBY)模式                  
}


void Rtc_Init(void)
{
        RTC_InitTypeDef RTC_InitStructure;
        RTC_TimeTypeDef  RTC_TimeStruct;

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

        /* Allow access to RTC */
        PWR_RTCAccessCmd(ENABLE);

        /* Reset RTC Domain */
        RCC_RTCResetCmd(ENABLE);
        RCC_RTCResetCmd(DISABLE);

        // xw
        /* Enable the LSI OSC */
        RCC_LSICmd(ENABLE);
        /* Wait till LSI is ready */  
        while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);
//        RtcWkup_Gpio_Init();        //        
        /* Select the RTC Clock Source */
        RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

        /* Configure the RTC data register and RTC prescaler */
        RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
        RTC_InitStructure.RTC_SynchPrediv  = 0xFF;
        RTC_InitStructure.RTC_HourFormat   = RTC_HourFormat_24;
        RTC_Init(&RTC_InitStructure);

        /* Set the time to 00h 00mn 00s AM */
        RTC_TimeStruct.RTC_H12     = RTC_H12_AM;
        RTC_TimeStruct.RTC_Hours   = 0x00;
        RTC_TimeStruct.RTC_Minutes = 0x00;
        RTC_TimeStruct.RTC_Seconds = 0x00;  
        RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
        /* Enable the RTC Clock */
        RCC_RTCCLKCmd(ENABLE);

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

        Rtc_AlarmConfig();
}



// 当用来唤醒时, 便不会进入中断函数
void RTC_Alarm_IRQHandler(void)
{
  /* Check on the AlarmA falg and on the number of interrupts per Second (60*8) */
  if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
  {
        /* Clear RTC AlarmA Flags */
    RTC_ClearITPendingBit(RTC_IT_ALRA);

//        printf("\r\n 一场游戏一场梦 ");
        RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
        RtcAlarmTime_Set();
//        Rtc_AlarmConfig();
  }
  /* Clear the EXTIL line 17 */
  EXTI_ClearITPendingBit(EXTI_Line17);
}


void Rtc_AlarmConfig(void)
{
        EXTI_InitTypeDef EXTI_InitStructure;
        //  RTC_AlarmTypeDef RTC_AlarmStructure;
        NVIC_InitTypeDef NVIC_InitStructure;


        /* EXTI configuration */
        EXTI_ClearITPendingBit(EXTI_Line17);
        EXTI_InitStructure.EXTI_Line = EXTI_Line17;
        EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
        EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
        EXTI_InitStructure.EXTI_LineCmd = ENABLE;
        EXTI_Init(&EXTI_InitStructure);

        /* Enable the RTC Alarm Interrupt */
        NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       
        /* Set the alarmA Masks */
        // xw
        //  RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay|RTC_AlarmMask_Hours|RTC_AlarmMask_Minutes;
        //  RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All;
        //  RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds += 10;
        //  RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
        RtcAlarmTime_Set();

        /* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */
        RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5);

//        RTC_OutputConfig(RTC_Output_AlarmA, RTC_OutputPolarity_High);
       
        /* Enable AlarmA interrupt */
        RTC_ITConfig(RTC_IT_ALRA, ENABLE);

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



// 设置RTC 报警时间间隔
void RtcAlarmTime_Set(void)
{
        RTC_AlarmTypeDef RTC_AlarmStructure;


        // xw
        RTC_GetTime(RTC_Format_BIN, &(RTC_AlarmStructure.RTC_AlarmTime));
//        printf("rtc %d, %d, %d", RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours, RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes, RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds);
        RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = (RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds+5)%60;
        /* Set the alarmA Masks */
          RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay|RTC_AlarmMask_Hours|RTC_AlarmMask_Minutes;
          RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
        RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

19

主题

86

帖子

0

精华

高级会员

Rank: 4

积分
796
金钱
796
注册时间
2013-9-29
在线时间
179 小时
发表于 2019-4-9 15:50:10 | 显示全部楼层
楼主解决了吗?我用的F429,也遇到了同样的情况。
回复

使用道具 举报

0

主题

5

帖子

0

精华

新手上路

积分
21
金钱
21
注册时间
2019-7-23
在线时间
5 小时
发表于 2019-9-17 15:58:13 | 显示全部楼层
PWR_WakeUpPin_1是哪个GPIO口
回复

使用道具 举报

1

主题

10

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
215
金钱
215
注册时间
2016-5-19
在线时间
26 小时
发表于 2019-9-25 00:11:35 来自手机 | 显示全部楼层
zkyzhh 发表于 2019-4-9 15:50
楼主解决了吗?我用的F429,也遇到了同样的情况。

大佬可以交流下吗,我在用F429,闹钟唤醒不了待机模式,求大佬加q770470604
回复

使用道具 举报

6

主题

49

帖子

0

精华

初级会员

Rank: 2

积分
169
金钱
169
注册时间
2012-11-8
在线时间
19 小时
发表于 2019-10-23 15:17:03 | 显示全部楼层
搞定没?
回复

使用道具 举报

0

主题

4

帖子

0

精华

初级会员

Rank: 2

积分
170
金钱
170
注册时间
2020-7-6
在线时间
19 小时
发表于 2020-7-11 10:03:34 | 显示全部楼层
qq59878236 发表于 2019-9-17 15:58
PWR_WakeUpPin_1是哪个GPIO口

端口是PA0,
回复

使用道具 举报

0

主题

1

帖子

0

精华

新手入门

积分
7
金钱
7
注册时间
2020-5-31
在线时间
1 小时
发表于 2020-11-18 14:30:39 | 显示全部楼层
我也遇到PWR_WakeUpPin_1和RTC_WakeUp只能使用一个,单独使用任何一个都没有问题,但是使用RTC前必须屏蔽掉PWR_WakeUpPin_1使能,不然单独RTC也用不了
回复

使用道具 举报

2

主题

20

帖子

0

精华

初级会员

Rank: 2

积分
76
金钱
76
注册时间
2020-10-6
在线时间
10 小时
发表于 2020-12-1 11:14:21 | 显示全部楼层
感谢!看到楼主帖子,我终于搞通了低功耗。不过待机模式好像是不进入闹钟中断服务函数的,stop模式才回进入闹钟中断
回复

使用道具 举报

11

主题

2154

帖子

0

精华

论坛元老

Rank: 8Rank: 8

积分
4947
金钱
4947
注册时间
2015-1-10
在线时间
620 小时
发表于 2020-12-1 13:44:42 | 显示全部楼层
standby模式唤醒就是复位,我用L1的PA0、wakeup、alarm都可以唤醒stop,你们是不是配置有问题
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-23 11:54

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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