This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2431 don´t wake up with Sleep Timer Interrupt

Other Parts Discussed in Thread: CC2431

Hello everybody

I have some problems waking up the CC2431 after sending him to PM 1 or 2, in fact it doesnt wake up, stay forever in the power modes.
Below is posted the code used, it's based on DN106. Anyone knows what's wrong?

Thanks in advance

_Pragma("vector=0x2B") __near_func __interrupt void ST_ISR(void);
_Pragma("vector=0x2B") __near_func __interrupt void ST_ISR(void) {


///////////// Code section #2 begin: Switch to [HS XOSC] /////////////
// Power up [HS XOSC] (SLEEP.OSC_PD = 0)
SLEEP &= ~0x04;
// Wait until [HS XOSC] is stable (SLEEP.XOSC_STB = 1)
while ( ! (SLEEP & 0x40) );
// Apply NOPs equivalent to 64 ìs
asm("NOP");
// Switch system clock source to [HS XOSC] (CLKCON.OSC = 0)
CLKCON &= ~0x40;
// Wait until system clock source has actually changed (CLKCON.OSC = 0)
while ( CLKCON & 0x40 );
// Power down [HS RCOSC] (SLEEP.OSC_PD = 1)
SLEEP |= 0x04;


// Clear IRCON.STIF (Sleep Timer CPU interrupt flag)
IRCON &= 0x7F;
SLEEP &= 0xFC; // Not required when resuming from PM0

  ST0=1;
  ST1=0;
  ST2=0;
}

/////////////////////////////////////
//SLEEP
////////////////////////////////////
static void sleep(void)
{
  STIF=0;// Clear IRCON.STIF (Sleep Timer CPU interrupt flag)
  STIE=1;
  EA=1;
  
  ST0=1;
  ST1=0;
  ST2=0;
  
  SLEEP = (SLEEP & 0xFC) | 0x01;
  asm("NOP");
  asm("NOP");
  asm("NOP");
  // Power up [HS RCOSC] (SLEEP.OSC_PD = 0)
SLEEP &= ~0x04;
// Wait until [HS RCOSC] is stable (SLEEP.HFRC_STB = 1)
while ( ! (SLEEP & 0x20) );
// Switch system clock source to HS RCOSC (CLKCON.OSC = 1)
CLKCON |= 0x40;
// Wait until system clock source has actually changed (CLKCON.OSC = 1)
while ( !(CLKCON & 0x40) );
// Power down [HS XOSC] (SLEEP.OSC_PD = 1)
SLEEP |= 0x04;

  if (SLEEP & 0x03)
  {
    PCON |= 0x01;
    asm("NOP");
  }

}
 
  • Problem solved.

    For posterior reference, the problem was the order that ST registers are defined. ST0 must bee the last register to be defined in order to properly define ST2:ST1:ST0 compare value


      ST1=0;

      ST2=0;

      ST0=1;