- Please ensure that the BLE subsystem (BLESS) interrupt has the highest priority i.e., the priority should be 0.
- Make sure that CyBle_ProcessEvents is called at regular intervals in the firmware. If any custom function consumes more time for execution, call CyBle_ProcessEvents inside it.
Thanks P Yugandhar, for the inputs. I have checked with interrupt priority to Zero i.e. Highest. Still the issue is there.
I am calling CyBle_ProcessEvents, this in while loop continuously, with some other functions serially. I have observed that, this issue is not because, other functions taking longer time for execution. I have used debug prints and verified that.
But the stuck condition occurs, when timer interrupts comes while processing CyBle_ProcessEvents.
Whenever there is the exact match of this condition, cpu is stuck inside this function CyBle_ProcessEvents forever. And this stuck creates watchdog reset.
I mean to say if CyBle_ProcessEvents is taking some time to process & another timer isr comes while processing BLE, then it is getting stuck.
Should I disable timer interrupts while processing CyBle_ProcessEvents ?
Should I use CyEnterCriticalSection ?
Please attach your project (if possible) so that we can reproduce the issue and find out the root cause. (If not complete project please share a simplified project where the issue is getting).
Please share your email id, so that I can share the project.
Ok. So, the scenario is that, If Watchdog Timer Counter 1 or RING_BUTTON interrupt occurs while processing CyBle_ProcessEvents(). The device hangs and resets because of watchdog.
To create that scenario, for that you can decrease timer period, so it will increase the no. of interrupts & may help recreating the issue.
Timer_Set_Period(32768);// make this 327 or 100 or something little...
You can also use the RING_BUTTON continuously to generate the interrupts simultaneously.
If it is stuck you can see "UART_DBG_PutString(".");" the dot printing in main() has stopped, if it is in wake-up condition.
You can also check that in this stuck condition CPU is still processing timer ISR, you can observer prints " UART_DBG_PutString("##");".
Please refer the below points.
1. Don't write big code inside any ISR. Instead, set a variable inside ISR and check the variable status and call the function in main loop.
2. Always keep Bless interrupt to highest priority i.e., bless interrupt priority to 0.
3. Please clear the WDT interrupt after completion using CySysWdtClearInterrupt(), this function will Clears all the WDT counter interrupts set in the mask.
4. It is not recommended to use the delays inside any ISR and also it is not recommended to disable the global interrupts inside the ISR (using CyGlobalIntDisable). This will block the other interrupts to execute.
5. Use the upgraded components in the project (Goto Project -> Update_components ).