STM32L151中的RTC唤醒中断不会中断

2019-07-14 14:26发布

各位大大,我最近在做STM32L151时出现了一个问题,就是RTC唤醒(wake up)中断不会中断啊,不知道为什么。下面是我的部分程序:

  void RTC_Configuration(void)
{
/* Enable PWR and BKP clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);                  
  /* Allow access to BKP Domain */
  PWR_RTCAccessCmd(ENABLE);                                       
                                                         
  
   /* 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);
/* Enable the RTC Clock */
  RCC_RTCCLKCmd(ENABLE);
  /* Wait for RTC APB registers synchronisation */
  RTC_WaitForSynchro();
  
  RTC_InitStructure.RTC_AsynchPrediv = 0x06;
  RTC_InitStructure.RTC_SynchPrediv  = 0x66;
  RTC_InitStructure.RTC_HourFormat   = RTC_HourFormat_24;
  RTC_Init(&RTC_InitStructure);

/* Configure the RTC WakeUp Clock source: CK_SPRE (1Hz) */
  RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);
  RTC_SetWakeUpCounter(0x0);
/* Enable the RTC Wakeup Interrupt */
  RTC_ITConfig(RTC_IT_WUT, ENABLE);
/* Enable Wakeup Counter */
  RTC_WakeUpCmd(ENABLE);
                                                                                
}

  void NVIC_Configuration(void)
{
  NVIC_InitTypeDef NVIC_InitStructure;
// Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   

// 1 bits for Preemption Priority and 3 bits for Sub Priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;                  
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}

时钟用的是LSE,就是外部低速晶振(32.768K)的

一直不能产生中断,各位大大,帮我看看是怎么回事吧,小弟在此谢过了...  
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
9条回答
www034
2019-07-15 12:07
RTC中断配置程序有写吗?
例如:
/* EXTI configuration *******************************************************/
  EXTI_ClearITPendingBit(EXTI_Line20);
  EXTI_InitStructure.EXTI_Line = EXTI_Line20;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  官网上下载的STM32L固件库中就有RTC中断的例子,你可以参考。

一周热门 更多>