I'm developing bluetooth logging software on the nRF51 DK using SDK 12.3.0. We had been developing for some time in mbed, but were advised to switch over to Keil using the ble_app_uart example as a basis (ble_app_uart_pca10028_s130.uvprojx to be specific). After spending some time to understand the flow of the code, porting to Keil went without too much of a hitch. But, we recently ran into a bit of an issue.
In our code, we read the BLE UART commands through the nus_data_handler function. In this, we decode the commands sent and respond with the necessary response. The problem we’re running into is that the code seems to either crash or timeout if it is in this function for too long. Certain short commands like reading a temperature value enter this function and exit it without problem. However, longer commands like reading the entire log data do not.
I thought this was due to a timer interrupt. But, I’ve tried various things from disabling the timer (periodic_callback_id) to simply extending it to be longer than necessary and the crash still occurs. I tried adding printf statements to see if it was some piece of code that didn’t get ported properly from mbed. But, adding printf statements just changes the location of the error. This is what has lead me to believe that it’s some sort of timeout issue. Granted, it is difficult to read from Keil’s debugger (hence using printf statements instead) given that, when trying to debug, the error sometimes cause the DK to reset and not trigger the debugger at all. So, while it’s possible that it could be something else, the common denominator from what I’ve been seeing seems to be time spent in the nus_data_handler function.