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.

SimpleBLECentral - cc2540 - sleep mode issue

Other Parts Discussed in Thread: CC2540, CC2541

Hi,

I have a problem with wakeup from sleep mode. My application should wakeup after button is pressed and
than start scanning for other devices and connect to them.

Now it works that the device wakes up but than stays in one strange state. By debugging with IAR i receive error. as XDATA is outside of stack 0xFFFF. Maybe my settings are wrong in project.

We use external OSC, device is CC2540, sleeps in P3 mode, BLE is 1.3.1 version and IAR 8.20.2.

What would be the best procedure to achieve this requirement?

Where could I call Hal sleep now function (OSAL event, CB,...)?

  • How have you setup the button to wake-up the device?  Interrupt?  Polling?    Gonna go out on a limb and say you may have triggered an event that you didnt place the proper return statement from.  This is a common error that causes the behaviour you described.  But we really need more info to help out.  

  • Button is setup as interrupt. we are using CC2541. Sorry for the typo.

  • Here is a list of things I would double check.  Unfortunately for the error you are seeing there are hundreds of potential causes, so I'll just list the common ones.  I assume you handle the button interrupts in your application through an app_ProcessOSALMsg() function passed to you from the HAL.   No doubt this would trigger an osal event to start your wake-up processes.  So here are some ways things could go wrong:

    • Your setup in HAL_Key.c is not masking/clearing interrupts properly, as a result you are overloading the system.  Can you make sure that when you press the button only one interrupt is generated?
    • The subsequent osal events that trigger as part of your wake,  make you each event has an event return.  Otherwise the OSAL will go into a weird state as you have an event that would relinquish control to the system.
    • Have you checked the Memory Summary found in the .map file of you project?  Perhaps post those values.  You'll find them at the bottom of the .map file in your project (should be in the Output folder)
    • What is your INT_HEAP_LEN set to in pre-compiler settings?
    • In pre-compiler settings add OSALMEM_METRICS=TRUE.   Then add memAlo and memMax variables to your watch list in the OSAL_Memory.c line 190 and 191.   When running, before you press the button, pause your application and see what these values report.  Set a break point right after the interrupt is triggered and again see what these values report.
    • Sometimes i've seen this issue when my firmware was triggering a reset of the board.  This caused the baord firmware to be out of synch with the CCdebugger and causes the error you see.

    Hopefully one of these suggestions sets you on the right path.  Post the values I recommended checking out, hopefully this is just a simple fix.

  • Thank you for reply. I wrote also one more mistake. We use internal oscillator.

    I will look into your suggestions and get back feedback.



  • I have done a total rework of my code and now it works. It looks like that full optimisation, have done something strange with my code, therefore now I have a project without any optimisation.