请问STM32F0的RTC_IRQHandler中断中EXTI_Line17的作用是什么?

2019-07-14 15:38发布

在学习STM32F0的RTC时,不太清楚AlARMA的中断函数RTC_IRQHandler中每次都要清除EXti_ClearITPendingBit(EXTI_Line17);
要是没有行不行,为什么要这样做?哪位高手给个解释啊?


程序如下:
void RTC_IRQHandler(void)
{
  /* Check on the AlarmA flag and on the number of interrupts per Second (60*8) */
  if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
  {
    /* ALARM is enabled */
    ALARM_Occured = 1;
   
    /* Clear RTC AlarmA Flags */
    RTC_ClearITPendingBit(RTC_IT_ALRA);
  }
  /* Clear the EXTIL line 17 */
  EXTI_ClearITPendingBit(EXTI_Line17);
  
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
6条回答
lifei639156
1楼-- · 2019-07-14 20:02
编程好习惯
就和指针用完置null一样
cmh23
2楼-- · 2019-07-14 21:41
lz你好,,可以分享下你RTC闹钟的配置吗?由于没有LSE,所以使用LSI作为时钟源,但是看起来不能正常工作
void RTC_Config(void)
{

  RTC_InitTypeDef RTC_InitStructure;
  RTC_TimeTypeDef  RTC_TimeStruct;
  
  /* Enable the PWR clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
        printf("999 ",0);
  /* Allow access to RTC */
  PWR_BackupAccessCmd(ENABLE);

  RCC_LSICmd(ENABLE);
  while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
  {
  }



  /* 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;  
  if(ERROR == RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct))
          printf("7 ",0);
    /* Enable the RTC Clock */
  RCC_RTCCLKCmd(ENABLE);
  
  /* Wait for RTC APB registers synchronisation */
  if(ERROR == RTC_WaitForSynchro())
          printf("2 ",0);
}

/**
  * @brief  Configures the RTC Alarm.
  * @param  None
  * @retval None
  */
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_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  /* Set the alarmA Masks */
  RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All;
  RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
  
  /* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */
  RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5);

  /* Enable AlarmA interrupt */
  RTC_ITConfig(RTC_IT_ALRA, ENABLE);
  
  /* Enable the alarmA */
  RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
  
}
cmh23
3楼-- · 2019-07-15 00:08
 精彩回答 2  元偷偷看……
7762642422d
4楼-- · 2019-07-15 05:33
cmh23 发表于 2018-11-29 08:25
lz你好,,可以分享下你RTC闹钟的配置吗?由于没有LSE,所以使用LSI作为时钟源,但是看起来不能正常工作
void RTC_Config(void)
{

用内部时钟需要校准!
TOPCB
5楼-- · 2019-07-15 11:03
Internal interrupt line 17  Connected to the RTC Alarm  event

这里说明了LINE17是RTC alarm中断引起的,所以要清除.
jiecai5388
6楼-- · 2019-07-15 16:29
7762642422d 发表于 2018-11-29 08:54
用内部时钟需要校准!

你好,怎么校准了?

一周热门 更多>