STM32 AWU RTC alarm wakes up CPU from stop mode

Publisher:码上奇迹Latest update time:2016-02-25 Source: eefocusKeywords:STM32  AWU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I couldn't find any examples online, so I spent a lot of time looking at the PDF!

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

//-----------EXTI configuration -------------------    
   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); 
//------------ set up interrupt------------------- 
   NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn;//防拆
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPrio rity = 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("-Alarm-",NULL);
RTC_SetAlarm(RTC_GetCounter()+sec);
//DEBUG_COM_STREAM("-Alarm1-",NULL);
RTC_WaitForLastTask();
//DEBUG_COM_STREAM("-Alarm2-",NULL);
RTC_ITConfig(RTC_FLAG_ALR,ENABLE);
}
void RTC_AWU_SET(void)
{
//Enable PWR and BKP clocks (from APB1)
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
//Unlock backup domain
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;
   }
 
}


Keywords:STM32  AWU Reference address:STM32 AWU RTC alarm wakes up CPU from stop mode

Previous article:STM32_TEST.axf: Error: L6218E: Undefi
Next article:STM32 general timer introduction

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号