打印
[STM32L1]

RTC闹钟的中断

[复制链接]
1090|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yinxiangh|  楼主 | 2020-9-9 22:26 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
有关RTC闹钟的中断,就是要求每一个小时整点产生一次RTC闹钟中断,前几个小时正常,可后面就不产生RTC中断,各位指点下.

使用特权

评论回复
沙发
zyf部长| | 2020-9-9 22:29 | 只看该作者
肯定是处理中断处理的不对了。

使用特权

评论回复
板凳
yufe| | 2020-9-9 22:33 | 只看该作者
你这样每次中断后,你重新初始化一次这个配置。

使用特权

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

使用特权

评论回复
5
yinxiangh|  楼主 | 2020-9-9 22:40 | 只看该作者
给你看下,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
zhouyong77| | 2020-9-9 22:42 | 只看该作者
应该还是中断配置没对

使用特权

评论回复
7
tian111| | 2020-9-9 22:47 | 只看该作者
估计是程序哪里跑丢了

使用特权

评论回复
8
dingy| | 2020-9-9 22:50 | 只看该作者
程序跑飞了 有可能是数据类型的问题

使用特权

评论回复
9
yinxiangh|  楼主 | 2020-9-9 22:53 | 只看该作者

唉,还是没有什么结果,算了,多谢大家啦

使用特权

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

本版积分规则

723

主题

7134

帖子

2

粉丝