函数原型:
void RTC_Set_WakeUp(u32 wksel,u16 cnt)
{
EXTI_InitTypeDef EXTI_InitStructure;
RTC_WakeUpCmd(DISABLE);//关闭WAKE UP
RTC_WakeUpClockConfig(wksel);//唤醒时钟选择
RTC_SetWakeUpCounter(cnt);//设置WAKE UP自动重装载寄存器
RTC_ClearITPendingBit(RTC_IT_WUT); //清除RTC WAKE UP的标志
EXTI_ClearITPendingBit(EXTI_Line22);//清除LINE22上的中断标志位
RTC_ITConfig(RTC_IT_WUT,ENABLE);//开启WAKE UP 定时器中断
RTC_WakeUpCmd( ENABLE);//开启WAKE UP 定时器
EXTI_InitStructure.EXTI_Line = EXTI_Line22;//LINE22
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断事件
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //上升沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//使能LINE22
EXTI_Init(&EXTI_InitStructure);//配置
NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02;//抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//子优先级2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能外部中断通道
NVIC_Init(&NVIC_InitStructure);//配置
}
主函数中调用:RTC_Set_WakeUp(RTC_WakeUpClock_CK_SPRE_16bits,0); //配置WAKE UP中断,1秒钟中断一次
为什么这里的cnt设置为0?怎么算出来1秒钟中断一次?
@正点原子 谢谢原子哥!
一周热门 更多>