This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SAADC scans only one sample

Hello,

I am developing a solution that measures values on 2 AIN channels in scan mode with the following setup:

- differential mode

- no oversampling

- no burst mode

- 10 bit precision

- resistors disabled

The channels are configured standard way using nrf_drv_saadc_channel_init() and nrf_drv_saadc_buffer_convert(). I start conversion by calling nrf_drv_saadc_sample() and set low power mode. This I understood to run several scan samples until buffer lasts.

The callback function checks for p_event->type == NRF_DRV_SAADC_EVT_DONE, makes nrf_drv_saadc_buffer_convert() and copies measured values to a separate array for further processing outside of the callback. I am not doing calibration at this stage, as it requires scan to work.

The problem I am facing is that the callback function is called always when only 1 set of samples is done, i.e. 1 sample for each channel. Regardless of what size buffer I set (tried 2x10, 2x20, 2x30 size).

I want to note that nrf_drv_saadc_sample() is triggered from RTC2 timer interrupt handler, setup for 2 kHz frequency of calls.

I would like to know why I am not getting s full scan of those 2 channels through the whole buffer.

I am using nRF 52832, custom design, also DK PCA10040, SDK 14.2 and SD 132, v5.0.0.

What else I forgot to set for running the scan mode / what can block the scan mode to work? Is the scan mode supported under SD? According to the SD documentation open for SAADC. 

Any advice is very much appreciated.

Thanx.

peter

Parents
  • Hello Haakonsh,

    I followed your suggestion: called saadc_calibrate(), no nrf_drv_saadc_buffer_convert calling before that. Abort worked on the first call, as SAADC was idle.

    I dont see calibrate to call callback function with NRF_DRV_SAADC_EVT_CALIBRATEDONE event and also any other. I called saadc_get_registers() function right before and after calling saadc_calibrate(), function. Before, all the registers were 0, while after the EVENTS_STARTED 0x100 was 1. Is this according to expectations?

    When I added NRF_LOG_DEBUG() print function after the calibration call, the callback was called. As NRF_LOG_DEBUG calls an interrupt I suspect that this helped the callback to be called. I think there is something with interrupt settings not working correctly.

    Two additional questions:

    - is nrf_drv_saadc_buffer_convert() not needed for the calibration?

    - the calibration is valid for all ADC channels or only for those that are initialiazed? When I init another channel after calibration should i run calibration for those channels again?

    peter

  • Peter.J said:
    I dont see calibrate to call callback function with NRF_DRV_SAADC_EVT_CALIBRATEDONE event and also any other.

     That's strange, it should work. How, exactly, do you make sure that you've entered the callback?

    Peter.J said:
    Before, all the registers were 0, while after the EVENTS_STARTED 0x100 was 1. Is this according to expectations?

    I'm not 100% sure the calibration task triggers a started event, but it would not surprise me if it did. If it does not then it means that something else in your application is triggering the start task of the SAADC while you're calibrating. 

    Peter.J said:
    is nrf_drv_saadc_buffer_convert() not needed for the calibration?

    Nope. 

    Peter.J said:
    the calibration is valid for all ADC channels or only for those that are initialiazed? When I init another channel after calibration should i run calibration for those channels again?

     The calibration is independent of the input channels and is valid for all channels. 

Reply
  • Peter.J said:
    I dont see calibrate to call callback function with NRF_DRV_SAADC_EVT_CALIBRATEDONE event and also any other.

     That's strange, it should work. How, exactly, do you make sure that you've entered the callback?

    Peter.J said:
    Before, all the registers were 0, while after the EVENTS_STARTED 0x100 was 1. Is this according to expectations?

    I'm not 100% sure the calibration task triggers a started event, but it would not surprise me if it did. If it does not then it means that something else in your application is triggering the start task of the SAADC while you're calibrating. 

    Peter.J said:
    is nrf_drv_saadc_buffer_convert() not needed for the calibration?

    Nope. 

    Peter.J said:
    the calibration is valid for all ADC channels or only for those that are initialiazed? When I init another channel after calibration should i run calibration for those channels again?

     The calibration is independent of the input channels and is valid for all channels. 

Children
No Data
Related