原子哥的例程,是针对某一天。楼主想设置每天
[mw_shl_code=c,true]
void RTC_Set_AlarmA(u8 week,u8 hour,u8 min,u8 sec)
{
EXTI_InitTypeDef EXTI_InitStructure;
RTC_AlarmTypeDef RTC_AlarmTypeInitStructure;
RTC_TimeTypeDef RTC_TimeTypeInitStructure;
RTC_AlarmCmd(RTC_Alarm_A,DISABLE);//1رÕÄÖÖóA
RTC_TimeTypeInitStructure.RTC_Hours=hour;//D¡ê±
RTC_TimeTypeInitStructure.RTC_Minutes=min;//·ÖÖó
RTC_TimeTypeInitStructure.RTC_Seconds=sec;//Ãë
RTC_TimeTypeInitStructure.RTC_H12=RTC_H12_AM;
RTC_AlarmTypeInitStructure.RTC_AlarmDateWeekDay=week;//DÇÆú
RTC_AlarmTypeInitStructure.RTC_AlarmDateWeekDaySel=RTC_AlarmDateWeekDaySel_WeekDay;//°′DÇÆúÄÖ
RTC_AlarmTypeInitStructure.RTC_AlarmMask=RTC_AlarmMask_None;//¾«è·Æ¥ÅäDÇÆú£¬ê±·ÖÃë
RTC_AlarmTypeInitStructure.RTC_AlarmTime=RTC_TimeTypeInitStructure;
RTC_SetAlarm(RTC_Format_BIN,RTC_Alarm_A,&RTC_AlarmTypeInitStructure);
RTC_ClearITPendingBit(RTC_IT_ALRA);//Çå3yRTCÄÖÖóAμıêÖ¾
EXTI_ClearITPendingBit(EXTI_Line17);//Çå3yLINE17éÏμÄÖD¶Ï±ê־λ
RTC_ITConfig(RTC_IT_ALRA,ENABLE);//¿aÆôÄÖÖóAÖD¶Ï
RTC_AlarmCmd(RTC_Alarm_A,ENABLE);//¿aÆôÄÖÖóA
EXTI_InitStructure.EXTI_Line = EXTI_Line17;//LINE17
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//ÖD¶Ïê¼t
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //éÏéyÑØ′¥·¢
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//ê1ÄüLINE17
EXTI_Init(&EXTI_InitStructure);//ÅäÖÃ
NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>