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.

320 usec units of sleep timer

Other Parts Discussed in Thread: CC2430, Z-STACK, TIMAC, CC2531

Hi,

 

I'm trying to sleep the cc2430 and i want to decide the time that remains sleeping.

For that reason I use void halSleepSetTimer(uint32 timeout) to set the timout of the sleep timer.

The parameter of this function is:

 

 @param       timeout - Timeout value in 320 usec units.  The sleep timer compare is set to this value.

 

Anyone knows the conversion that I have to do to pass  my "normal" seconds to 320 usec units?

 

Thanks a lot.

 

Àngel

  • Why not start with a great example from Z-Stack sample code that uses milliseconds? Note that converting from "normal" seconds to milliseconds is done by dividing by 1000 - but be careful of overflowing variables and rounding and note that the 8051 is very slow at crunching UINT32 math, so try to keep that to a minimum.

    This is from Z-Stack 1.4.3-1.2.1 (only because Angel is working with the old CC2430 - otherwise look at Z-Stack 2.3.0 and soon 2.3.1!) file "hal_sleep.c":


    /* convert msec to 320 usec units with round */
    #define HAL_SLEEP_MS_TO_320US(ms)           (((((uint32) (ms)) * 100) + 31) / 32)

    Some rhetorical questions for you (i.e. not expecting an answer): Why are you working without having the Z-Stack or TIMAC code as an example? Why are you working with the old generation CC2430 and not the exciting and superior CC253x parts, which include a cheap USB dongle device (CC2531) soon to be released in a Mini-kit?