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
I had forgotten to say that the correct value (thai is 0 in this buffer) is located with same offset in the other buffer (of the other signal)
I have discovered now that when the data from ADC is swapped, this situation continues until I reset the system.
In previus immage I stopped the debug at the first 0. The other values after the 0 are old values on the buffer
ok. so the issue is that the adc is not triggered on every fall on the input pulse, is that maybe the case?
The issue may be that you don't have time for all interrupts. Either, they are too fast on it's own, or there is a possibility that you don't get the lpcomp interrupts (lpcomp_event_handler) in time, because the CPU is busy doing something else, such as handling one of the ADC events.
I suggest that you try to use PPI, like it is done in the example. It sets up a timer, and then uses the ppi to trigger the sampling on this event, rather than handling the timer interrupt using the CPU.
Dear Edvin,
the interrup is triggered on all fall edge. The LPCOM work perfectly and follow all edge.
The ADC in scann mod, on 2 channels, work but some times the data are swapped into the doubble buffer.
I have found other with my problem, see: https://devzone.nordicsemi.com/f/nordic-q-a/16885/saadc-scan-mode-sample-order-is-not-always-consistent
For now I have resolved using two call, each with only one channel ON.
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; err_code = nrf_drv_saadc_channel_uninit(0); APP_ERROR_CHECK(err_code);
In this configuration all work good, also using 1 mS between two fall edge.
the above code use 55uS for both channels.
But this is not the correct solution. I hope to found the error in the scann mode configurations
Thanks
Marco
Hello,
Sorry. I forgot to mention that if you have two channels that are enabled, the scan function will scan both channels. I wasn't aware that you wanted to scan on different times based on two different input pulses.
The ticket that you link to is not entirely the same. We have seen similar cases when they use the internal SAADC timer to trigger samples, when they are sampling very fast, and have several channels.
If you want to measure on different times, you need to disable one channel at the time, like you do here.
How does that behave? I am still a bit confused about your description.
Marco Pennacchietti said:I had forgotten to say that the correct value (thai is 0 in this buffer) is located with same offset in the other buffer (of the other signal)
So how is your channels mixed up? Could you clarify?
Best regards,
Edvin