开发流程
- 配置RTC时钟
- 设置RTC闹钟
- 配置RTC闹钟中断
- 实现中断函数
RTC闹钟初始化
// 闹钟外部中断
exti_flag_clear(EXTI_17);
exti_init(EXTI_17,EXTI_INTERRUPT,EXTI_TRIG_RISING);
// 重置闹钟
rtc_alarm_disable(RTC_ALARM0);
rtc_alarm_struct ras;
ras.alarm_mask = RTC_ALARM_HOUR_MASK | RTC_ALARM_MINUTE_MASK | RTC_ALARM_SECOND_MASK;
ras.weekday_or_date = RTC_ALARM_DATE_SELECTED;
ras.alarm_day = 0x21;
ras.alarm_hour = WRITE_BCD(23);
ras.alarm_minute = WRITE_BCD(59);
ras.alarm_second = WRITE_BCD(59);
ras.am_pm = RTC_AM;
rtc_alarm_config(RTC_ALARM0, &ras);
// 中断配置
nvic_irq_enable(RTC_Alarm_IRQn, 2, 2);
rtc_interrupt_enable(RTC_INT_ALARM0);
rtc_flag_clear(RTC_FLAG_ALRM0);
rtc_alarm_enable(RTC_ALARM0);
中断函数
void RTC_Alarm_IRQHandler() {
if (SET == rtc_flag
文章来源地址https://www.toymoban.com/news/detail-774029.html
文章来源:https://www.toymoban.com/news/detail-774029.html
到了这里,关于嵌入式——RTC闹钟Alarm的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!