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.

How to prevent Deep Sleep?

Other Parts Discussed in Thread: CC2530

Hello,

I am working with cc2530 end devices running Zstack 2.5.1a.

I have POWER_SAVING defined and would like to enter Power Mode 2 (Timer Sleep) the maximum of 65 seconds.

I am using a modification of the GenericApp project where I only have one task that reads and sends sensor data and resets the osal_start_timerEx for the same task every 65 seconds.

Everything works fine for about 2-3 hours and then for some reason the module enters deep sleep.  I verified this with the debugger:

In the function, osal_pwrmgr_powerconserve( void )

next = osal_next_timeout();

next equals 0!!  (but only after 2 hours of running correctly) and then enters deep sleep since next = 0.

Why would this happen? Or what further steps could I use to debug?

Thanks

Sam

  • The only way that you can realize this failure is by using a one-shot OSAL Timer that you have to continually reset - it is much more recommended to use an auto-resetting timer (i.e. osal_start_reload_timer()).

    I can think of two ways that your code fails to get another one-shot OSAL Timer:

    1. The request for starting the timer again (i.e. osal_start_timerEx()) is made at an incredibly unlucky moment when a lot of messages are incoming or outgoing and the OSAL Memory heap is so depleted that the 13 bytes are not available (very unlikely).

    2. You have added code that leaks memory at a rate such that 2-3 hours into a run there is not even 13 bytes of heap left (most likely).

    So, before converting from the one-shot timer to the auto-resetting timer (which will mask the probable memory leak), fix the plumbing first.

     

  • Thanks.

    I used osal_start_reload_timer() so now my task executes every 65 seconds - even after the two hours.

    However, now it still does not transmit after 2 hours.  Traced the problem to a function in AF_DataRequest:

       stat = APSDE_DataReq( &req );

    returns stat = 0x10 which I looked up to be ZMemError

    So it looks that you are right with the memory leaks.

    Now I need to brush up on memory leak debugging.

    Thanks again!