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.

sleep timer value loading problem in cc2533

Other Parts Discussed in Thread: CC2533, Z-STACK, CC2530, CC2531, CC2540

Hi all,

I need help on the following register operation. STLOAD.LDRDY in CC2533.

In my coding i use sleep timer. So initially to load values to ST0, ST1and ST2 i use the following procedure.

 - ST2 = value1;

 - ST1 = value2;

 - wait till STLOAD.LDRDY becomes 1. (This bit is 0 while the Sleep Timer loads the 24-bit compare value and 1 when the Sleep Timer is ready to start loading a new compare value).

 - ST0 = value0;

In debugging process i put a break point on the next instruction immediately after STO = value0;. But in the register view in iar i can see that these values have not updated. What can i do to solve this problem?

Thanks&Regards

Jithesh

  • Hi,

     

    In the code, add several (3, or 4) asm("NOP"); commands, and set a breakpoint on the last

    NOP operation.

  • Sorry. I tried the same but the result is the same.

    I also tried for CLK32K bit in SLEEPSTA to become low and then high. But it too is not making my value to load in to the same register. Is there any other solution?

  • Hi,

     

    In your previous example, after LDRDY goes high after STx values are loaded,

    read the values back to some temporal variable, first ST0, then ST1 and finally

    the value of ST3.

    Is it the same value as loaded?

  • its too not giving the same values i load...

  • Have you tried to write to ST2, ST1 and ST0 and then wait for STLOAD.LDRDY to go high?

  • I tried the same too and that too is not working.

    I have one more observation. At the time of debug i used Register view to see the registers ST1 ST2 and ST3. Now i also used the watch window at the time of debug process. On the time of break point stop both the windows are showing different values for the same registers ST1 ST2 and ST3.  Why? (Image for the same problem have attached with this reply)

  • Hi,

     

    Here's a function from Z-stack, which is working (proved empirically) :)

     

    /**************************************************************************************************
     * @fn          halSleepSetTimer
     *
     * @brief       This function sets the CC2530 sleep timer compare value.  First it reads and
     *              stores the value of the sleep timer; this value is used later to update OSAL
     *              timers.  Then the timeout value is converted from 320 usec units to 32 kHz
     *              period units and the compare value is set to the timeout.
     *
     * input parameters
     *
     * @param       timeout - Timeout value in 320 usec units.  The sleep timer compare is set to
     *                        this value.
     *
     * output parameters
     *
     * None.
     *
     * @return      None.
    **************************************************************************************************
     */

    void halSleepSetTimer(uint32 timeout)
    {
    uint32 ticks;

    /* read the sleep timer; ST0 must be read first */
    ((uint8 *) &ticks)[UINT32_NDX0] = ST0;
    ((uint8 *) &ticks)[UINT32_NDX1] = ST1;
    ((uint8 *) &ticks)[UINT32_NDX2] = ST2;
    ((uint8 *) &ticks)[UINT32_NDX3] = 0;

    /* Compute sleep timer compare value.  The ratio of 32 kHz ticks to 320 usec ticks
    * is 32768/3125 = 10.48576.  This is nearly 671/64 = 10.484375.
    */
    ticks += (timeout * 671) / 64;

    /* subtract the processing time spent in function halSleep() */
    ticks -= HAL_SLEEP_ADJ_TICKS;

    /* set sleep timer compare; ST0 must be written last */
    ST2 = ((uint8 *) &ticks)[UINT32_NDX2];
    ST1 = ((uint8 *) &ticks)[UINT32_NDX1];
    ST0 = ((uint8 *) &ticks)[UINT32_NDX0];
    }

     

    The comparing and subtraction part isn't relevant for you, however the other parts should

    help you.

    By the way, the device (as you can see) is CC2530, but it is the same for CC2531, CC2533

    and CC2540.