打印
[STM32F2]

STM32f207休眠模式无法RTC唤醒。

[复制链接]
3044|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zhangyu198530|  楼主 | 2014-9-16 19:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM32f207RTC不进入待机模式可以进入WAKEUP中断,但是进入休眠模式唤醒不了。不知道怎么回事。
沙发
zhangyu198530|  楼主 | 2014-9-16 20:09 | 只看该作者
void RTCWUP_init(void)
{       
    RTC_InitTypeDef   RTC_InitStructure;
    RTC_TimeTypeDef   RTC_TimeStructure;
    RTC_DateTypeDef   RTC_DateStructure;
    NVIC_InitTypeDef NVIC_InitStructure;
    EXTI_InitTypeDef EXTI_InitStructure;

        __IO uint32_t AsynchPrediv = 0, SynchPrediv = 0;

        //STM_EVAL_PBInit(BUTTON_WAKEUP , BUTTON_MODE_GPIO);
        /* Enable the PWR APB1 Clock Interface */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); //使能功耗控制功能
   /* Allow access to BKP Domain */ //使能BKP控制域
  PWR_BackupAccessCmd(ENABLE);

  /* Configure one bit for preemption priority */  //设置中断优先权
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  /* Enable the RTC Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* EXTI configuration *******************************************************/
  EXTI_ClearITPendingBit(EXTI_Line22);
  EXTI_InitStructure.EXTI_Line = EXTI_Line22;
  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 LSE OSC */
  RCC_LSEConfig(RCC_LSE_ON);

  /* Wait till LSE is ready */  
  while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
  {
  }

  /* Select the RTC Clock Source */
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
  
  SynchPrediv = 0xFF;
  AsynchPrediv = 0x7F;

   /* Enable the RTC Clock */
  RCC_RTCCLKCmd(ENABLE);
  /* Wait for RTC APB registers synchronisation */
  RTC_WaitForSynchro();

  /* Write to the first RTC Backup Data Register */
  RTC_WriteBackupRegister(RTC_BKP_DR0, 0x32F2);
    /* Set the Time */
  RTC_TimeStructure.RTC_Hours   = 0x08;
  RTC_TimeStructure.RTC_Minutes = 0x00;
  RTC_TimeStructure.RTC_Seconds = 0x00;

  /* Set the Date */
  RTC_DateStructure.RTC_Month = RTC_Month_March;
  RTC_DateStructure.RTC_Date = 0x18;  
  RTC_DateStructure.RTC_Year = 0x11;
  RTC_DateStructure.RTC_WeekDay = RTC_Weekday_Friday;

  /* Calendar Configuration */
  RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv;
  RTC_InitStructure.RTC_SynchPrediv =  SynchPrediv;
  RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
  RTC_Init(&RTC_InitStructure);
  
  /* Set Current Time and Date */
  RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);  
  RTC_SetDate(RTC_Format_BCD, &RTC_DateStructure);

  /* Configure the RTC Wakeup Clock source and Counter (Wakeup event each 1 second) */
  RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);
  RTC_SetWakeUpCounter(0x005);
  
  /* Enable the Wakeup Interrupt */
  RTC_ITConfig(RTC_IT_WUT, ENABLE);

  /* Enable Wakeup Counter */
  RTC_WakeUpCmd(ENABLE);
}

使用特权

评论回复
板凳
zhangyu198530|  楼主 | 2014-9-16 20:09 | 只看该作者
void RTC_WKUP_IRQHandler(void)          
{
  if(RTC_GetITStatus(RTC_IT_WUT) != RESET)        //判断是否为唤醒中断
  {
   //TimeDisplay = 1;                               //显示信息
    RTC_ClearITPendingBit(RTC_IT_WUT);//清唤醒标志位
    EXTI_ClearITPendingBit(EXTI_Line22);//清除中断标志位
  }
  //GPIO_SetBits(GPIOE,GPIO_Pin_13);
  Sleep(0x01);
}

使用特权

评论回复
地板
zhangyu198530|  楼主 | 2014-9-16 20:10 | 只看该作者
上面是根据例程修改的程序,希望各位高手指点一下。

使用特权

评论回复
5
zhangyu198530|  楼主 | 2014-9-17 18:13 | 只看该作者
请路过的高手指点一下。

使用特权

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

本版积分规则

26

主题

331

帖子

1

粉丝