1 of 1 people found this helpful
Please check the below points in your central device:
1. Please make sure that the BLE subsystem (BLESS) interrupt has the highest priority i.e., the priority should be 0.
2. Make sure that CyBle_ProcessEvents is called at regular intervals in the firmware. If a custom function consumes more time for execution, please call CyBle_ProcessEvents inside it.
3. If you have any interrupt routine in your code then don't write big code inside ISR. Instead, set a variable inside ISR and check the variable status and call the function in main loop.
4. Please refer to the ECO capacitor trim values for your EZ BLE module in this KBA link.
Please check the disconnection reason in your peripheral device. The parameter returned with the event "CYBLE_EVT_GAP_DEVICE_DISCONNECTED" contains a pointer to the reason for disconnection. In the firmware, you can get the event parameter value from the CYBLE_EVT_GAP_DEVICE_DISCONNECTED event as follows:
printf("Error code is: 0x%x \r\n", *(uint8 *) eventParam);
Please check the error code in the BLE_Stack.h file in project or find the corresponding description from the "HCI error commands" section in the BLE Core Specifications in version 4.2, vol2, Part D, Section 1.3: List of error codes.
Thank you for the response. I did update the priority levels as they were all set to 3 (two gpio, BLE and ADC). The calling of CyBle_ProcessEvents is called many times especially in long loops.
Non of the GPIO IRQ routines call anything else, they are just set a flag and return to main loop to be processed. However, there is one item I didn't mention in my thread. After 10 seconds of inactivity, I put the radio and MCU to sleep. At some period, the device wakes up and then goes back to sleep. I am assuming this wakeup is coming from the BLE stack to maintain connectivity to the peripheral. When it wakes up, it goes through the main loop which does check CyBle_ProcessEvents. Is there anything that I need to do in this sleep mode to ensure a disconnect is detected?
Here is my sleep routine.
/* Local variable to store the status of BLESS Hardware block */
/* Put BLESS into Deep Sleep and check the return status */
sleepMode = CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP);
/* Disable global interrupt to prevent changes from any other interrupt ISR */
/* Check the Status of BLESS */
blessState = CyBle_GetBleSsState();
if(sleepMode == CYBLE_BLESS_DEEPSLEEP)
/* If the ECO has started or the BLESS can go to Deep Sleep, then place CPU
* to Deep Sleep */
if((blessState == CYBLE_BLESS_STATE_ECO_ON || blessState == CYBLE_BLESS_STATE_DEEPSLEEP)&& (CyBle_GetState() != CYBLE_STATE_DISCONNECTED))
if(blessState != CYBLE_BLESS_STATE_EVENT_CLOSE)
/* If the BLESS hardware block cannot go to Deep Sleep and BLE Event has not
* closed yet, then place CPU to Sleep */
Could you please share your complete project so that we can check at our end.