Reentrant Cy_SysPm_Sleep issue with Bluetooth

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi there,

We are running a simple project with Bluetooth using only single core CM0+ to test Bluetooth with low power functionality.

We've run into an unknown problem that is better depicted by the Call Stack that we've observed after stopping execution while in debug mode. This is the Call Stack on running into the problem:

0 Cy_SysPm_Sleep(cy_en_syspm_waitfor_t waitFor = <optimized out>) Generated_Source\PSoC6\pdl\drivers\peripheral\syspm\cy_syspm.c 382 0x10002BB2 (All)

1 Cy_BLE_HAL_SysPmSleep(cy_en_syspm_waitfor_t enWaitFor = <optimized out>) Generated_Source\PSoC6\pdl\middleware\ble\cy_ble_hal_pvt.c 1195 0x10003802 (All)

2 ll_wait_to_exit_dsm() ?????? ?????? 0x1000CF1A (All)

3 ll_exit_low_power_mode() ?????? ?????? 0x1000C3B2 (All)

4 CyBle_ControllerExitLPM() ?????? ?????? 0x1000BCBA (All)

5 BT_timer_process_signals() ?????? ?????? 0x1000A512 (All)

6 CyBle_StackTaskHandler() ?????? ?????? 0x1000A730 (All)

7 OS_scheduler() ?????? ?????? 0x1000B566 (All)

8 CyBleStackMgr_ProcessBleEvents() ?????? ?????? 0x10009E76 (All)

9 Cy_BLE_ProcessEvents() ?????? ?????? 0x1000A072 (All)

10 Transmission_BleSsHandler() main_cm0p.c 255 0x1000032E (All)

11 Cy_BLE_BlessInterrupt() Generated_Source\PSoC6\pdl\middleware\ble\cy_ble_hal_int.c 260 0x10003280 (All)

12 <signal handler called>() ?????? ?????? 0xFFFFFFF9 (All)

13 Cy_SysLib_ExitCriticalSection() Generated_Source\PSoC6\pdl\drivers\peripheral\syslib\gcc/cy_syslib_gcc.S 96 0x10002F6E (All)

14 Cy_SysPm_Sleep(cy_en_syspm_waitfor_t waitFor = CY_SYSPM_WAIT_FOR_INTERRUPT, cy_en_syspm_waitfor_t waitFor@entry = CY_SYSPM_WAIT_FOR_INTERRUPT) Generated_Source\PSoC6\pdl\drivers\peripheral\syspm\cy_syspm.c 382 0x10002BB8 (All)

15 SystemCore_TryToSleep() main_cm0p.c 310 0x100004C4 (All)

16 main() main_cm0p.c 361 0x100005AA (All)

The problem seems to be that, at times, the BLESS interrupt will trigger and wake up the device. On wake up, the CPU finishes executing the Critical Section inside Cy_SysPm_Sleep, and then the BLESS interrupt and its callback functions are handled. One of the internal callback functions attempts to put the CPU to sleep mode which causes a reentrant issue.

We've attached the project that we're testing if it helps to reproduce the described problem. Note that the problem doesn't occur until after connectnig to Bluetooth (regardless if a remote device remains connected or if Bluetooth goes back to advertising, the problem occurs).

Best,

Steve

0 Likes
1 Solution
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Steve,

Looks like you are trying to call the "Cy_BLE_ProcessEvents" from the interrupt context?? Am I right??

Can you try the polling method I mentioned in the other posts? See "ll_wait_to_exit_dsm" relies on an interrupt to clear/set a flag indicating exit from deep sleep mode for the BLE sub system. Since the API is called from within the same interrupt that is supposed to modify the flag, you might end up in these cases. I did not dig deep into the stack implementation but from a high-level, this looks like the issue.

If this does not solve the issue, try increasing the ECO startup time (Alt HF settings) to 1500 us in the Clocks tab as shown below -

pastedImage_2.png

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
1 Reply
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Steve,

Looks like you are trying to call the "Cy_BLE_ProcessEvents" from the interrupt context?? Am I right??

Can you try the polling method I mentioned in the other posts? See "ll_wait_to_exit_dsm" relies on an interrupt to clear/set a flag indicating exit from deep sleep mode for the BLE sub system. Since the API is called from within the same interrupt that is supposed to modify the flag, you might end up in these cases. I did not dig deep into the stack implementation but from a high-level, this looks like the issue.

If this does not solve the issue, try increasing the ECO startup time (Alt HF settings) to 1500 us in the Clocks tab as shown below -

pastedImage_2.png

Regards,

Meenakshi Sundaram R

0 Likes