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.

cc2541 unresponsive on sleep code

Other Parts Discussed in Thread: CC-DEBUGGER

I had a project that worked just fine with the default power management settings.

Once I turned on the POWER_SAVING flag, the device started getting stuck when sleeping from the main loop.

Specifically, This behavior is presented in void halSleep( uint32 osal_timeout ) in hal_sleep.c, in line 344:

// check if radio allows sleep, and if so, preps system for shutdown
if ( LL_PowerOffReq(halPwrMgtMode) == LL_SLEEP_REQUEST_ALLOWED )

When stepping over the call to LL_PowerOffReq, the debugger stops responding and the device probably does too, for no good reason. When manually pressing the "break" button in the workbench, I reach llStopTimer2(), but never leaves there.

I can't step-in to the function because it has no source. When stepping through the assembly it's difficult to determine when exactly it gets stuck, since it does all sorts of banked-code trickery, various jumps etc, and the debugger responds VERY slowly to single-instruction stepping (don't understand why).

This happens right on the first sleep the device encounters. I'm working without any optimizations. Using CC-Debugger.

Any help will be appreciated.

  • After some digging, found this thread that describes a similar problem with no solution.

  • Hi Amir,

    Do you have an external 32.768Hz oscillator?

    LLPowerOffReq doesn't really do anything interesting apart from stopping the MAC timer and syncing it with the sleep timer. Which will require a functional sleep timer.

    Best regards,
    Aslak 

  • Yeah, we have a working external oscillator as required by the design. Any advice on how I can verify it works properly (other than calling LLPowerOffReq of course)?

    Any other ideas on what I can do to progress this issue?

    Currently we can't enter proper sleep mode and it forces us to manually disconnect batteries for our product, which is obviously undesirable :)

    Thanks

  • Hi Aslak,

          I have a similar problem with this, but there's no  32.768Hz oscillator designed on my board. Do you have any suggestion about this? How could I do to set my board working in PM2 state when there's no task during two advertising?

  • We have 32.768 KHz oscillator on our board.
    What are all requirements for LL_PowerOffReq() to return 0 value(LL_SLEEP_REQUEST_ALLOWED),
    so that code doesn't hang at this line: if ( halSleepPconValue && ( LL_PowerOffReq(halPwrMgtMode) == LL_SLEEP_REQUEST_ALLOWED ) )?
  • Hi,

    Does SimpleBLEPeripheral hang at this line? If so, you may not have mounted the crystal correctly.

    If you have an external crystal, you can configure this in hal_board_cfg.h (in IAR, HAL/Target/CC2540EB/Config/hal_board_cfg.h)

    // For non-USB, assume external, unless an internal crystal is explicitly indicated.
    #if !defined (XOSC32K_INSTALLED) || (defined (XOSC32K_INSTALLED) && (XOSC32K_INSTALLED == TRUE))
    #define OSC_32KHZ EXTERNAL_CRYSTAL_OSC
    #else
    #define OSC_32KHZ INTERNAL_RC_OSC
    #endif

    Best regards,
    Aslak