您的位置 首页 传感器

STM32 AWU RTC闹钟从停机形式唤醒CPU

网上找不到范例自已对着PDF整了半天!!voidRTC_EXTI_INITIAL(FunctionalStateinterrupt_en_or_dis){NVIC_InitTypeDefNVIC_In

网上找不到典范 自已对着PDF整了半响!!

void RTC_EXTI_INITIAL(FunctionalState interrupt_en_or_dis)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;

//————EXTI 装备 ——————-
EXTI_InitStructure.EXTI_Line = EXTI_Line17;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = interrupt_en_or_dis;
EXTI_Init(&EXTI_InitStructure);
//————设置 中止——————-
NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn;//防拆
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = interrupt_en_or_dis;
NVIC_Init(&NVIC_InitStructure);
//——————————————-
}

void RTC_SET_ALARM(u32 sec)
{
//DEBUG_COM_STREAM(“-闹钟-“,NULL);
RTC_SetAlarm(RTC_GetCounter()+sec);
//DEBUG_COM_STREAM(“-闹钟1-“,NULL);
RTC_WaitForLastTask();
//DEBUG_COM_STREAM(“-闹钟2-“,NULL);
RTC_ITConfig(RTC_FLAG_ALR,ENABLE);
}
void RTC_AWU_SET(void)
{
//启用PWR和BKP的时钟(from APB1)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
//后备域解锁
PWR_BackupAccessCmd(ENABLE);
RTC_ITConfig(RTC_IT_SEC, DISABLE);
RTC_SET_ALARM(5);
//PWR_BackupAccessCmd(DISABLE);
RTC_EXTI_INITIAL(ENABLE);
}

void RTCAlarm_IRQHandler(void)
{
EXTI_ClearITPendingBit(EXTI_Line17);
//SYS.wake_id|=1<<17;
}

void RTC_IRQHandler(void)
{
if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
{

RTC_ClearITPendingBit(RTC_IT_SEC);


RTC_WaitForLastTask();
//TIME_COUNT=RTC_GetCounter();
//RTC_WaitForLastTask();
}
if (RTC_GetITStatus(RTC_FLAG_ALR) != RESET)
{RTC_ClearITPendingBit(RTC_FLAG_ALR);
RTC_WaitForLastTask();
//SYS.wake_id|=1<<1;
}

}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/chuanganqi/260832.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部