I'm trying to send ADC data through BLE using nRF52840.
According to the example codes named ble_peripheral/ble_app_uart, peripheral/saadc, I wrote a code and it is able to transmit the data.
But the problem is that the throughput is about 850 kbps, which is much lower than I expected. When I ran the throughput demo, it was able to get 1M(conn_interval =7.5ms)~1.3M(conn_interval=400ms) bps.
So I wonder whether one of the ADC sampling or BLE task becomes a bottleneck as I aligned them in a serial way like the below code.
void saadc_callback(nrf_drv_saadc_evt_t const * p_event) { if (p_event->type == NRF_DRV_SAADC_EVT_DONE) { ret_code_t err_code; err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAMPLES_IN_BUFFER); APP_ERROR_CHECK(err_code); //SEGGER_RTT_WriteString(0, "saadc_callback function\n"); saadc2ble_convert(); uint16_t length = (uint16_t)(SAMPLES_IN_BUFFER * 2); //SEGGER_RTT_WriteString(0, "Trying to send data.\n"); notification_err_code = ble_nus_data_send(&m_nus, adc_output, &length, m_conn_handle); //sprintf(error_string, "Error number: %#x\n", notification_err_code); //SEGGER_RTT_WriteString(0, error_string); if ((notification_err_code != NRF_ERROR_INVALID_STATE) && (notification_err_code != NRF_ERROR_RESOURCES) && (notification_err_code != NRF_ERROR_NOT_FOUND)) { APP_ERROR_CHECK(notification_err_code); } } }
For now, ble_nus_data_send() is called every time when the SAADC buffer is full.
Will there be some advances if I save the ADC samples in a kind of buffer and call ble_nus_data_send() several times when the data are collected?