AnsweredAssumed Answered

ADuC7024 Wake-up timer

Question asked by Zeal on Dec 7, 2015
Latest reply on Dec 17, 2015 by Zeal

Hello, has anyone used the wake-up timer to bring a nap mode ADuC7024 back to its active mode?My testing codes are like below. When I comment out the line “PLL_OSC_CON_EnterPowerMode(OPERATING_MODE_NAP_MODE);”, My LED blinks correctly. However, the LED just keeps ON after it enters the NAP mode and it seems the wake-up timer has stopped working.


#define MMR_BASE                                                        ((uint32_t)0xFFFF0000)    

#define PLL_AND_OSCILLATOR_CONTROL_BASE         (MMR_BASE + 0x0404)

 

typedef struct{

     __W uint16_t POWKEY1;

     uint8_t Reserved0[2];

     __RW uint16_t POWCON;

     uint8_t Reserved1[2];

     __W uint16_t POWKEY2;

     uint8_t Reserved2[2];

     __W uint16_t PLLKEY1;

     uint8_t Reserved3[2];

     __RW uint8_t PLLCON;

     uint8_t Reserved4[3];

     __W uint16_t PLLKEY2;

} PLL_OSC_CON_TypeDef;

 

#define PLL_OSC_CON                 (*(PLL_OSC_CON_TypeDef*) PLL_AND_OSCILLATOR_CONTROL_BASE)

 

typedef enum{

  OPERATING_MODE_ACTIVE_MODE = 0x0000,

  OPERATING_MODE_PAUSE_MODE = 0x0010,

  OPERATING_MODE_NAP_MODE = 0x0020,

  OPERATING_MODE_SLEEP_MODE = 0x0030,

  OPERATING_MODE_STOP_MODE = 0x0040

} PC_TypeDef;

 

void PLL_OSC_CON_EnterPowerMode(PC_TypeDef mode){

     PLL_OSC_CON.POWKEY1 = 0x01;

     PLL_OSC_CON.POWCON = mode;

     PLL_OSC_CON.POWKEY2 = 0xF4;

}

 

void main() {

     Timer2_INIT_TypeDef Timer2_InitSetting;

     LED_INIT();    

     LED_On();

     Timer2_InitSetting.Precale = TIMER1_2_PRESCALER_32768;

     Timer2_InitSetting.Format = TIMER1_2_FORMAT_BINARY;

     Timer2_InitSetting.Mode = TIMER_MODE_PERIODIC;

     Timer2_InitSetting.Count_Direction = TIMER1_2_3_COUNT_DOWN;

     Timer2_InitSetting.Source = Timer2_Clock_Source_HCLK;

     Timer2_InitSetting.Load_Value = 1275;

     Timer2_Init(&Timer2_InitSetting);

     IRQ_CON_EnableIRQ(IRQ_WAKE_UP_TIMER);

     Timer2_EnableControl(TIMER_ENABLE);

     PLL_OSC_CON_EnterPowerMode(OPERATING_MODE_NAP_MODE);

     while(1);

}

__irq void IRQ_Handler () {

     static uint32_t t = 0;

     if(IRQ_CON.IRQSTA.b.Wake_Up_Timer == 1){

          TIMER2.CLRI = 0x1;         

          if(t++%2)          LED_On();

          else                 LED_Off();

     }

}

 

I will be very appreciated if anyone could help. Thanks.

Outcomes