Answers for "AUTO WAKEUP PART1"

0

AUTO WAKEUP PART1

void vPortSetupTimerInterrupt( void )
    {
        NVIC_InitTypeDef NVIC_InitStructure;
        EXTI_InitTypeDef EXTI_InitStructure;
    
            /* Enable PWR and BKP clocks */  /* PWR clock (power control) and BKP clock (RTC backup register) enable */  
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
        
        /* Allow access to BKP Domain */ /*Enable RTC and backup register access */  
        PWR_BackupAccessCmd(ENABLE);

        RCC_LSICmd(ENABLE); /*  Enable internal 32.768K clock */

        /*  Waiting for the internal 32.768K clock ready */
        while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);
        
        /*  Select the internal 32.768K clock as the RTC clock */
        RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
        
        /* Set RTC prescaler: set RTC period to 1 millisecond */   
        /*  Suozhang, use external 32.768K crystal, set 32 ​​division, count 1024 times for 1S, November 15, 2018 09:28:52 */ 
        RTC_SetPrescaler( 40 );

        /* Enable the RTC Interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;                                                                                    
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configKERNEL_INTERRUPT_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                     
    NVIC_Init(&NVIC_InitStructure);
    
        /* Enable the RTC Alarm Interrupt */
        NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn;
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configKERNEL_INTERRUPT_PRIORITY;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructure);  
  
        //The alarm is interrupted to the external line of line 17
   EXTI_ClearITPendingBit(EXTI_Line17);
    
   EXTI_InitStructure.EXTI_Line = EXTI_Line17;
   EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
   EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
   EXTI_InitStructure.EXTI_LineCmd = ENABLE;
   EXTI_Init(&EXTI_InitStructure);
     
        /*  Enable power management clock */
         RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR , ENABLE);
     
         /* Enable RTC Clock */
        RCC_RTCCLKCmd(ENABLE);
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();
        
        /*  Enable the RTC to generate a timer interrupt based on the selected clock source and the division value setting, as the FreeRTOS clock source. */
        RTC_ITConfig(RTC_IT_SEC, ENABLE);
        RTC_WaitForLastTask();
        
    }
Posted by: Guest on June-22-2021

Browse Popular Code Answers by Language