Environment:
nRF5 SDK version: 17
SoftDevice: S140
Tool: Segger Embedded Studio
Debugger: J-Link EDU Mini
Board: Arduino Nano 33 BLE (Using SWD pins with the J-Link)
Processor: nRF52840
(Added a custom board file containing the pin definitions for the Arduino Nano 33 BLE. I used several standard non-ble peripheral examples, edited them heavily, and all worked fine with this board.)
Problem:
The following problem occurs when I try to use ble_app_blinky examples. For the rest of the text, let’s call the Board running Central ble_app_blinky as BLE_Cen, and let’s call the Board running Peripheral ble_app_blinky as BLE_Per.
BLE_Per not working correctly with BLE_Cen neither with the Android app. The connection is established successfully in both cases, but LED is not updated on pressing the button on one board or on the app. Led remains green all the time. But connection/disconnection works successfully.
After debugging, I noticed that the application crashes and goes to hard fault whenever I press the button on one board (say BLE_Cen), and the information is sent to the other board (say BLE_Per) via BLE. If I don't press the button, it keeps running and can make or break connections successfully. At pressing the button on one board I checked if it reaches the “led_write_handler(...)”. It does and executes the LED on/off code lines. However, it crashes afterward. I placed the breakpoint right after the line where this handler is called. It does not return, instead, it goes to some error and stops, pressing again, it starts and goes to a hard fault. I replaced the LED update code with a simple integer assignment to check if it is a problem with the led stuff, but the behavior remains the same.
I have not changed anything in the example code or configuration, just compiled and programmed the boards. I only added the custom board file containing the pin definitions for the Arduino Nano 33 BLE. Nothing else. And it is working with other non-ble peripheral examples as well as my own project code. The following are a few debugging details.
After successful connection (green LED on both boards), I press the button on BLE_Cent, BLE_per reaches the “led_write_handler(...)”, wherein I have placed a breakpoint to stop. Then I place a breakpoint at the next line where this led handler is called. This is in “nrf_sdh_ble_evts_poll(void * p_context)” at “if (ret_code != NRF_ERROR_NOT_FOUND)”. I press the run to continue execution. It crashes and never reaches the other breakpoint. It stops at “00000A60: 4B01 ldr r3, [PC, #4]”. When I press run to continue again, it stops at “NRF_BREAKPOINT_COND;” in “app_error_fault_handler(...)”.
If I execute without debugging, there is no effect on led on pressing the button. I am sure the same is happening in this case. It would be great if you can please help me in this regard.