我想改成5s进一次中断怎么改?求助大神!!!!!!!!!!!!!!!!!!!!! void RTC_AlarmConfig(void) { RTC_TimeTypeDef RTC_TimeStructure; RTC_AlarmTypeDef RTC_AlarmStructure; EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RTC_DateTimeTypeDef RTC_DateTimeStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); PWR_BackupAccessCmd(ENABLE); RCC_LSICmd(ENABLE); RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);//ÄÚ²¿ RCC_RTCCLKCmd(ENABLE); RTC_AlarmCmd(RTC_Alarm_A,DISABLE);//¹Ø±ÕÄÖÖÓA // RTC_GetDateTime(&RTC_DateTimeStructure); // // RTC_AlarmStructure.RTC_AlarmTime.RTC_H12=RTC_H12_AM; // RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours=RTC_DateTimeStructure.Hour; // RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes=RTC_DateTimeStructure.Minute; // RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=RTC_DateTimeStructure.Second+5; // if(RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds >=60)RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=0; /////////////// /* Get current time */ RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure); RTC_AlarmStructure.RTC_AlarmTime.RTC_H12=RTC_H12_AM; RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours=RTC_TimeStructure.RTC_Hours; RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes=RTC_TimeStructure.RTC_Minutes; RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=RTC_TimeStructure.RTC_Seconds+5; if(RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds >=60)RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=0; ///////////////////////// RTC_AlarmStructure.RTC_AlarmDateWeekDay = 0x31; RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date; RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Minutes | RTC_AlarmMask_Hours; // RTC_AlarmStructure.RTC_AlarmMask =RTC_AlarmMask_Seconds; // // RTC_AlarmSubSecondConfig(RTC_Alarm_A,RTC_TimeStructure.RTC_Seconds+5,RTC_AlarmSubSecondMask_SS14_1); // RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure); /* Clear the Alarm A Pending Bit */ RTC_ClearITPendingBit(RTC_IT_ALRA); //Êä³öÉ趨µÄÄÖÖÓ»½ÐÑʱ¼ä // RTC_ITConfig(RTC_IT_ALRA, ENABLE); RTC_ITConfig(RTC_IT_ALRA, ENABLE); /* Enable the alarm */ RTC_AlarmCmd(RTC_Alarm_A, ENABLE); /* 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); //PWR_BackupAccessCmd(DISABLE); } void RTC_IRQHandler(void) { RTC_TimeTypeDef RTC_TimeStructure; RTC_AlarmTypeDef RTC_AlarmStructure; RTC_DateTimeTypeDef RTC_DateTimeStructure; SystemInit(); RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); PWR_BackupAccessCmd(ENABLE); // RCC_LSICmd(ENABLE); // RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);//ÄÚ²¿ // RCC_RTCCLKCmd(ENABLE); LED_Init(); if (RTC_GetITStatus(RTC_IT_ALRA) != RESET) { RTC_ClearITPendingBit(RTC_IT_ALRA); RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure); // RTC_GetAlarm(RTC_Format_BIN,RTC_IT_ALRA); // RTC_AlarmStructure.RTC_AlarmTime.RTC_H12=RTC_H12_AM; RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours=RTC_TimeStructure.RTC_Hours; RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes=RTC_TimeStructure.RTC_Minutes; RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=RTC_TimeStructure.RTC_Seconds+5; if(RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds >=60)RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=0; RTC_AlarmStructure.RTC_AlarmDateWeekDay = 0x31; RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date; RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Minutes | RTC_AlarmMask_Hours; // RTC_AlarmStructure.RTC_AlarmMask =RTC_AlarmMask_Seconds; //RTC_AlarmSubSecondConfig(RTC_Alarm_A,RTC_TimeStructure.RTC_Seconds+5,RTC_AlarmSubSecondMask_SS14_1); RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure); RTC_ITConfig(RTC_IT_ALRA, ENABLE); /* Enable the alarm */ RTC_AlarmCmd(RTC_Alarm_A, ENABLE); } EXTI_ClearITPendingBit(EXTI_Line17); //PWR_BackupAccessCmd(DISABLE); } |
评分
查看全部评分
f030 没有你说的那些东西啊。
你好,我使用的是STM32F072CBT6,在工程中查询怎么没有RTC_WKUP_IRQn中断,我需要产生一个7分钟的中断的,可以分享一下你的这块详详细的配置代码吗?
您好,这个中断代码是需要自己写的。可以参考官方的例程。
你这个问题解决了吗