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.

CC1110 sleep timer: hang on <while(temp == WORTIME0);>



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

  • Hi.

    Sounds a little weird. As long as the 32 kHz is running, WORTIME0 should count at the set WOR_RES rate. The only thing i can think off right now is that the crystal does not start properly. Do this happen using the internal RC?

    Kjetil

  • Kjetil, thanks for your reply.

    I test another firmware (sleep timer sample code) with the same hardware. It seems no any problem.

    So I will try internal RC as you proposed and other methods.

  • I think the problem may be due to the sleep timer clock selection.

    I noticed "32 kHz clock oscillator select. The HS RCOSC must be clock source for the system clock (CLKCON.OSC=1) when this bit is to be changed." in datasheet P82.

    What I do before is

            1. select the HS XOSC as system clock

            2. Select 32.768K Crystal Oscillator

    So I should make sure the HS RCOSC is the clock source before doing 2. I changed the sequence of initialization.

            1. Select 32.768K Crystal Oscillator

            2. select the HS XOSC as system clock

    It seems the hang didn't occur again by now.

    Cheers,