Hey
im having trouble getting the SAADC over BLE UART from your github to work
i am getting some weird values over BLE to your uart app which i have included a image of
when in print out the string being sent over NUS onto my pc uart terminal it shows up fine
Picture of output on phone
https://drive.google.com/file/d/1S7qN0NKhIGJpotomLckT7rz7YuPvrZxt/view?usp=sharing
picture of pure adc output
https://drive.google.com/file/d/1RslcU3im57Zht2w9MVa7PWStFwF2gL0O/view?usp=sharing
picture of with printed value of value
https://drive.google.com/file/d/1FM2oOVMvYYKKuSRDS9EIkjs-OViWqdo8/view?usp=sharing
werent able to put in the code file so i just put the code for my SAADC callback function here
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;
uint16_t adc_value;
uint8_t value[SAADC_SAMPLES_IN_BUFFER*2];
uint8_t valuetest[SAADC_SAMPLES_IN_BUFFER*2];
uint16_t bytes_to_send;
// set buffers
err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);
// print samples on hardware UART and parse data for BLE transmission
printf("ADC event number: %d\r\n",(int)m_adc_evt_counter);
for (int i = 0; i < SAADC_SAMPLES_IN_BUFFER; i++)
{
printf("%d\r\n", p_event->data.done.p_buffer[i]);
adc_value = p_event->data.done.p_buffer[i];
//printf("pure ADC value from p buffer %d\r\n", adc_value);
value[i*2] = adc_value;
//tester
valuetest[i*2] = adc_value;
//printf("after first value calc %d \r\n", value[i*2]);
value[(i*2)+1] = adc_value >> 8;
//printf("sent over BLE nus service %d\r\n", value[(i*2)+1]);
}
// Send data over BLE via NUS service. Makes sure not to send more than 20 bytes.
if((SAADC_SAMPLES_IN_BUFFER*2) <= 20)
{
bytes_to_send = (SAADC_SAMPLES_IN_BUFFER*2);
}
else
{
bytes_to_send = 20;
}
err_code = ble_nus_data_send(&m_nus, valuetest, &bytes_to_send, m_conn_handle);
if (err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}
m_adc_evt_counter++;
}
}