打印
[STM32L1]

不产生RTC闹钟中断

[复制链接]
1583|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
274048251|  楼主 | 2018-11-29 21:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
最近碰到一个问题,有关RTC闹钟的中断,就是要求每一个小时整点产生一次RTC闹钟中断,前几个小时正常,可后面就不产生RTC中断,各位指点下.
沙发
xinpian101| | 2018-11-29 23:28 | 只看该作者
肯定是处理中断处理的不对了。

使用特权

评论回复
板凳
xinpian101| | 2018-11-29 23:28 | 只看该作者
你这样每次中断后,你重新初始化一次这个配置。

使用特权

评论回复
地板
jiekou001| | 2018-11-30 08:17 | 只看该作者
楼上好建议,毕竟中断次数太少,每次中断处理结束后再执行一次初始化还是可以的。防止配置失效。

使用特权

评论回复
5
274048251|  楼主 | 2018-12-3 17:22 | 只看该作者
本帖最后由 274048251 于 2018-12-3 17:26 编辑
xinpian101 发表于 2018-11-29 23:28
你这样每次中断后,你重新初始化一次这个配置。

给你看下,void NVIC_Configuration(void)
{
        NVIC_InitTypeDef NVIC_InitStructure;
        EXTI_InitTypeDef EXTI_InitStructure;

        /* Set the Vector Table base location at 0x08000000 */
        NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

        /* 2 bit for pre-emption priority, 2 bits for subpriority */
        NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
        //------RTC闹钟-------------------------------------------------------
        NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
        
        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);
        
        // 键盘
        NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       //蓝牙
        NVIC_InitStructure.NVIC_IRQChannel = BLE_INT_EXTI_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
        //恢复出厂按键
        NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

#if WATCHDOG_ENABLE
        NVIC_InitStructure.NVIC_IRQChannel = WWDG_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 4;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
#endif
        
        //------TIM6-------------------------------------------------------
        NVIC_InitStructure.NVIC_IRQChannel = TIM6_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        #if LOCK_WITH_FINGERPRINT
        // 指纹
        NVIC_InitStructure.NVIC_IRQChannel = FP_MODULE_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 6;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
       #endif

        //------TIM4读卡-------------------------------------------------------
        NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
        
        //------TIM3-------------------------------------------------------
        NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 8;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        // console串口
        NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 9;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 10;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);
        
        NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 11;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);

        NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 12;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);void RTC_Alarm_IRQHandler(void)
{       
        keylock_t * keylock=Keylock_Msg_Accept();

        RFID_ChkCard_Disable();               
        if (RTC_GetITStatus(RTC_IT_ALRA) != RESET)
        {
                RTC_ClearITPendingBit(RTC_IT_ALRA);
                EXTI_ClearITPendingBit(EXTI_Line17);               
                //System_Sleep_Disable();
                IntWakeupSce.Sys_sync_flag= SYNC_RECYCLE;
                }
        if (RTC_GetITStatus(RTC_IT_ALRB) != RESET)
        {                       
                RTC_ClearITPendingBit(RTC_IT_ALRB);
                EXTI_ClearITPendingBit(EXTI_Line17);
                if (keylock->lockedflag == TRUE)
                {
                        IntWakeupSce.lockedrelease = TRUE;
                        }
                }
        #ifdef CHECK_WAKEUP_MODE
                wakeup_mode |= WAKEUP_BY_RTC;
        #endif

void RTC_RandomPwUpdate_Alarm(void)
{
        RTC_TimeTypeDef  RTC_TimeStruct;
        RTC_AlarmTypeDef RTC_AlarmStruct;

        APP_TRACE_DBG("%s %d\n", __FUNCTION__, __LINE__);
           RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
        RTCTime_AddCalculate(1, CALCULATE_HOUR, &RTC_TimeStruct);

        /* Allow access to BKP Domain */
        PWR_RTCAccessCmd(ENABLE);
        RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
          RTC_AlarmStruct.RTC_AlarmTime.RTC_H12 = RTC_TimeStruct.RTC_H12;
          RTC_AlarmStruct.RTC_AlarmTime.RTC_Hours = RTC_TimeStruct.RTC_Hours;
    RTC_AlarmStruct.RTC_AlarmTime.RTC_Minutes = (RTC_TimeStruct.RTC_Minutes + 10) % 60;
    RTC_AlarmStruct.RTC_AlarmTime.RTC_Seconds = 0;
        RTC_AlarmStruct.RTC_AlarmDateWeekDay = 0x31;
          RTC_AlarmStruct.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
          RTC_AlarmStruct.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay| RTC_AlarmMask_Hours;
          RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStruct);
          RTC_WaitForSynchro();
        RTC_ClearFlag(RTC_FLAG_ALRAF);       
        EXTI_ClearITPendingBit(EXTI_Line17);
        RTC_ITConfig(RTC_IT_ALRA, ENABLE);
          RTC_AlarmCmd(RTC_Alarm_A, ENABLE);

我这里改成10分钟一次.
本来我要的是1个小时一次中断

使用特权

评论回复
6
paotangsan| | 2018-12-4 13:00 | 只看该作者
估计是程序哪里跑丢了

使用特权

评论回复
7
wakayi| | 2018-12-4 13:07 | 只看该作者
程序跑飞了 有可能是数据类型的问题

使用特权

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

本版积分规则

6

主题

22

帖子

0

粉丝