Hi everyone,
I am using an nRF52840 dongle (MakerDiary) with SDK15.0 & SoftDevice S140 v6.0.0, and trying to change the BLE advertising manufacturer's data with the information from the SAADC reading. I wrote a small function "set_mfg_data()" that stops BLE advertising, updates the manufacturer's data, and then restarts the advertising. In my project, I made it so that when the button on the dongle is pressed, the button handler calls "nrf_drv_saadc_sample()" to start the ADC conversion, and the SAADC event handler function looks for the "NRF_DRV_SAADC_EVT_DONE" event, and when that event occurs, it calls my "set_mfg_data()" function to update the manufactuerer's data with the new SAADC reading. However, in this configuration, the nRF52840 crashes when it's trying to update the manufacturer's data, and just goes into the DFU/bootloader mode.
I confirmed that my "set_mfg_data()" function works properly by moving it out of the SAADC event handler callback function, to the button_press event handler function. With each press, I am seeing the advertised manufacturer's data change as expected. Can anyone shed any light as to why the device might be crashing when I attempt to change advertised manufacturer's data from within the SAADC event handler callback function?
Here is some of my code, here is the "set_mfg_data()" function:
Here is the SAADC event handler callback function that seems to crash the device. When the line with "set_mfg_data()" is commented out, it doesn't crash: