求救,有谁用过STM32F0的RTC闹钟功能,始终无法进中断

2020-01-01 17:40发布

最近做一个项目用STM32F071的片子,调试RTC功能时发现设置闹钟功能后始终无法进中断,只要使能闹钟RTC_AlarmCmd(RTC_Alarm_A,ENABLE);就会直接跳到启动代码的B  .处,有没有人遇到过帮忙解答下,非常着急在线等
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
18条回答
Huge2014
2020-01-03 04:40
下面是我在STM32F051中用的秒中断设置:
/**
  * @brief  This function configures the RTC Alarm.
  * @param  None
  * @retval None
  */
void RTC_AlarmConfig(void)
{
        EXTI_InitTypeDef EXTI_InitStructure;
        RTC_AlarmTypeDef RTC_AlarmStructure;
        NVIC_InitTypeDef NVIC_InitStructure;

//        RTC_AlarmStructInit(&RTC_AlarmStructure);
   
  /* 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 = 1;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

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

  /* Enable AlarmA interrupt */
        RTC_ITConfig(RTC_IT_ALRA, ENABLE);
  /* Enable the alarm  A */
        RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
}


这是秒中断
void RTC_IRQHandler(void)
{
        if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
        {
                RTC_TotalSeconds++;
                RTC_ClearITPendingBit(RTC_IT_ALRA);        /* Clear RTC AlarmA Flags */
        }
        EXTI_ClearITPendingBit(EXTI_Line17);        /* Clear the EXTIL line 17 */
}

一周热门 更多>