When I use the CC1110 with the power mode 2 and sleep timer, there's a problem. Firstly I set the system clock
SLEEP &= ~SLEEP_OSC_PD; // Both HS XOSC and HS RCOSC oscillators powered up
while( !(SLEEP & SLEEP_XOSC_S) ); // Wait for HS XOSC to be stable
// System clock oscillator select (high speed crystal oscillator)
CLKCON &= ~CLKCON_OSC;
// system clock speed 26MHz
CLKCON = (CLKCON & ~CLKCON_CLKSPD) | CLKSPD_DIV_1;
CLKCON = (CLKCON & ~CLKCON_TICKSPD) | TICKSPD_DIV_1;
// Wait for system clock setting to take effect
while ( (CLKCON & CLKCON_OSC) ) ;
// Oscillator not selected by CLKCON.OSC bit powered down.
SLEEP |= SLEEP_OSC_PD; // HS RCOSC will be powered down
then select 32768 HZ LS XOSC as sleep timer clock source,
CLKCON &= ~CLKCON_OSC32;
then config the sleep timer
event = time.sec*32768 + time.msec*32768/1000;
event0 = (uint16)event;
WORCTL = (WORCTL & ~WORCTL_WOR_RES) | WORCTL_WOR_RES_1;
/* Must wait for 2 clock periods after resetting the Sleep Timer before setting EVENT0 value */
// Reset timer and set EVENT0 value.
WORCTL |= WORCTL_WOR_RESET; // Reset Sleep Timer
char temp = WORTIME0;
while(temp == WORTIME0); // Wait until a positive 32 kHz edge
temp = WORTIME0;
while(temp == WORTIME0); // Wait until a positive 32 kHz edge
WOREVT0 = event0 & 0x00FF; // Use 32 for EVENT0 value
WOREVT1 = event0 >> 8;
Normally it works correctly: sleep, wake, sleep and wake....
However some time the firmware is "dead". I use the IAR to debug the firmware and find that the code execution is hung on the line of <while(temp == WORTIME0); > I marked with red.
It seldom occurs. The problem isn't in wake-up situation. It just occurs before I first enter the power mode 2.
Any Ideas what is going on??
Thanks