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 am checking the callback function by setting up a flag when called. I check the flag then outside on upper level.

    I stepped into scan investigation again. I used logging level for finding out results of calls.

    I am scanning 2 channels. When the buffer size was set 2, "scan" worked. I could see log:

    <info> saadc: Function: 233084, buffer length: 2, active channels: 2.
    <info> saadc: Function: nrf_drv_saadc_buffer_convert, error code: NRF_SUCCESS.
    <debug> app: Saadc init 0 saadc_battery_and_temperature_handler error code: NRF_SUCCESS
    <debug> saadc: Event: NRF_SAADC_EVENT_STARTED.
    <info> saadc: Function: nrf_drv_saadc_sample, error code: NRF_SUCCESS.
    <debug> saadc: Event: NRF_SAADC_EVENT_END.

    When I increase size of the buffer to 4 then it gets stuck. The callback is not called as scan is not finished.

    I recap that I am running Saadc low power mode as it only triggers scan task software way - when e.g. PPi is not used (see my explanation earlier).

    Do you have any idea what I should check?

    peter

  • Peter.J said:
    When I increase size of the buffer to 4 then it gets stuck.

    I need to know exactly what's changed, how do you increase the buffer size? 

    Peter.J said:
    I recap that I am running Saadc low power mode as it only triggers scan task software way

     How many times do you trigger the SAMPLE task?

  • Hello Haakonsh,

    I call

    err_code = nrf_drv_saadc_buffer_convert(m_resistivity_measurement_buffer_pool, SAADC_SAMPLES_IN_BUFFER);

    where 

    static nrf_saadc_value_t m_resistivity_measurement_buffer_pool[SAADC_SAMPLES_IN_BUFFER];

    and 

    SAADC_SAMPLES_IN_BUFFER I set 2 resp 4. I scan 2 channels.

    I trigger  nrf_drv_saadc_sample() once right after the buffer convert call.

    peter

  • You need to trigger the sample task twice to fill the buffers now, otherwise, you will never get an END event. 

    One SAMPLE task will sample all enabled channels once. 

Reply Children
No Data
Related