I need to measure with SAADC two channels in the same time (NRF_SAADC_INPUT_AIN6 and NRF_SAADC_INPUT_AIN4).
Is possible ?
Have you an code example?
Thanks
Marco
I need to measure with SAADC two channels in the same time (NRF_SAADC_INPUT_AIN6 and NRF_SAADC_INPUT_AIN4).
Is possible ?
Have you an code example?
Thanks
Marco
Anyone find a solution to this?
hi, John.
Unfortunately I never found a solution.
The frequency of my saples are 2 mS. Each 2 mS I need to sample 2 channels.
For now I set the ADC in order to make 2 different samples with one channel for time
Marco
I've been playing around with this issue a bit today and I may have found a solution, but I have no clue why or how. I'd be interested to find out if it fixes your problem as well.
My solution:
Change saadc_init() to the following:
void saadc_init(unsigned char type) { ret_code_t err_code; nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN6); err_code = nrf_drv_saadc_init(NULL, saadc_PULSE_INEX_callback); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_channel_init(0, &channel_config); APP_ERROR_CHECK(err_code); channel_config.pin_p = NRF_SAADC_INPUT_AIN4; err_code = nrf_drv_saadc_channel_init(1, &channel_config); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool_scann[0], SAMPLES_IN_BUFFER_SCANN); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool_scann[1], SAMPLES_IN_BUFFER_SCANN); APP_ERROR_CHECK(err_code); }
Can you try it and let me know if it fixes the issue? Or you are done with this project?
Your code seem same at my old inizialization. When did not work. The problem is connected to the interrupt.
Now I'm on new project and is difficult to come back on this.
But to resolve the problem I used the ADC without interupt. Waiting the end of conversion for each cannel. The time lost between the 2 conversion is abot 30 uS.
err_code = nrf_drv_saadc_channel_uninit(0); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_channel_init(0, &channel_config_PULSE); APP_ERROR_CHECK(err_code); nrfx_saadc_sample_convert(0, &value_1); adc_value_pulse = ADC_RESULT_IN_MILLI_VOLTS(value_1); // if (adc_value_pulse>35000) adc_value_pulse=0; err_code = nrf_drv_saadc_channel_uninit(0); APP_ERROR_CHECK(err_code); err_code = nrf_drv_saadc_channel_init(0, &channel_config_INEX); APP_ERROR_CHECK(err_code); nrfx_saadc_sample_convert(0, &value_2); adc_value_inex = ADC_RESULT_IN_MILLI_VOLTS(value_2); // if (adc_value_inex>35000) adc_value_inex=0;
The solution I proposed is different than your code in that it keeps the same channel_config, but alters the positive pin when init second channel. It's very possible that this doesn't solve your issue, but it solved mine.
Thanks for sending the code segment with your solution
The solution I proposed is different than your code in that it keeps the same channel_config, but alters the positive pin when init second channel. It's very possible that this doesn't solve your issue, but it solved mine.
Thanks for sending the code segment with your solution