AnsweredAssumed Answered

ADucm360 sleep (mode 4)

Question asked by shortDan on Aug 15, 2016
Latest reply on Aug 19, 2016 by ABuda


Hello,

 

I'm trying to create a sleep function for the ADucm360 board, which will put the device to deep sleep (mode 4) for a configurable amount of miliseconds and afterwards the CPU should be woken up by the wake-up timer.

 

My problem is that it doesn't work. The CPU enters Mode4, but it never wakes up from it.

The wake-up timer seems to be configured correctly -independently of the sleep code ( I've tried it on the evaluation board - toggling the LED at a predefined time interval).

 

Here is the code snippet.

 

void sleep( uint32_t ms )

{

  int32_t index = 0;

  uint32_t miliseconds = 2*ms;

    /* enable the wake-up timer */

  pADI_WUT->T2CON = T2CON_MOD_PERIODIC|T2CON_WUEN_EN|T2CON_PRE_DIV16|T2CON_CLK_LFOSC;

  /* configure the interrupt for wake-up field D */

  pADI_WUT->T2IEN |= (0x8 & 0x1F);

  /* Configure the timeout  for the wake-up timer */  

  pADI_WUT->T2WUFD0= (short)(miliseconds&0x0000FFFF);

  pADI_WUT->T2WUFD1= (short)(miliseconds>>16);

 

  SCB->SCR = 0x04; // sleepdeep mode

  pADI_PWRCTL->PWRKEY = 0x4859; // key1

  pADI_PWRCTL->PWRKEY = 0xF27B; // key2

  pADI_PWRCTL->PWRMOD = 0x4;  /* deep sleep mode */

/* enable the timer */

nvicEnableIRQ(WUT_IRQn);

   T2CON_ENABLE_BBA = 1;

  for (index=0;index<2;index++);

  asm("WFI");

  for (index=0;index<2;index++);

}

 

and the wake-up timer interrupt handler

void wakeUpInterruptHandler(void)

{

 

 

  pADI_WUT->T2CLRI = 0;

  asm("DSB");

  //pADI_WUT->T2CON = T2CON_ENABLE_DIS;

  T2CON_ENABLE_BBA =0 ;

  nvicClearPendingIRQ(WUT_IRQn);

  nvicDisableIRQ(WUT_IRQn);

}

 

Any idea what I'm doing wrong?

Outcomes