求一份F4系列RTC闹钟的例程,要求是每天早上启动,下午关闭。是不是A、B闹钟都要设置?
[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;//ÇàÕ¼óÅÏ輶1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//×óóÅÏ輶2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ
}[/mw_shl_code]
[mw_shl_code=c,true]
void RTC_Alarm_IRQHandler(void)
{
if(RTC_GetFlagStatus(RTC_FLAG_ALRAF)==SET)//ALARM AÖD¶Ï?
{
RTC_ClearFlag(RTC_FLAG_ALRAF);//Çå3yÖD¶Ï±êÖ¾
printf("ALARM A!
");
}
EXTI_ClearITPendingBit(EXTI_Line17); //Çå3yÖD¶ÏÏß17μÄÖD¶Ï±êÖ¾
}[/mw_shl_code]
每天要怎么设置,不是某一星期?闹钟B要怎么设置
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>