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

nrf52 SAADC - NRFX_SAADC_EVT_DONE never called

using nRF5SDK 160098a08e2

I have the following code:

#define ADC_NOF_SAMPLES 16u
static int16_t s_sample_buffer[ ADC_NOF_SAMPLES ];
static nrf_saadc_channel_config_t const s_adc_channel0 = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE( NRF_SAADC_INPUT_AIN5 );
static void saadc_event_isr( nrfx_saadc_evt_t const *p_event )
{
    volatile uint32_t numOfSamples = 0;
    switch ( p_event->type )
    {
    case NRFX_SAADC_EVT_DONE:  // Event generated when the buffer is filled with samples.
        numOfSamples = p_event->data.done.size;
        break;
    case NRFX_SAADC_EVT_LIMIT: // Event generated after one of the limits is reached.
        break;
    case NRFX_SAADC_EVT_CALIBRATEDONE: // Event generated when the calibration is complete.
        {
            nrfx_err_t err;
            err = nrfx_saadc_buffer_convert( &s_sample_buffer[0], ADC_NOF_SAMPLES );
            APP_ERROR_CHECK(err);
            /*err = nrfx_saadc_sample();
            APP_ERROR_CHECK(err);*/
        }
        break;
    default:
        break;
    }
}

    nrfx_err_t err;
    static nrfx_saadc_config_t const s_saadc_config = {
            .resolution = NRF_SAADC_RESOLUTION_12BIT,
            .oversample = NRF_SAADC_OVERSAMPLE_256X,
            .interrupt_priority = NRFX_SAADC_CONFIG_IRQ_PRIORITY,
            .low_power_mode = false
    };

    // ADC driver is initialized in non-blocking mode, since an event handler is given
    err = nrfx_saadc_init( &s_saadc_config, saadc_event_isr );

    if ( err == NRFX_SUCCESS )
    {
        // Initialize the ADC channel 0
        err = nrfx_saadc_channel_init( 0, &s_adc_channel0 );

        if ( err == NRFX_SUCCESS )
        {
            /*
            * Calibrate the offset with a call to nrfx_saadc_calibrate_offset.
            * You need to wait for the SAADCs DONE event before you can proceed.
            * */
            do
            {
                err = nrfx_saadc_calibrate_offset();
            } while ( err == NRFX_ERROR_BUSY );

            rc = 1u;
        }
    }



I never receive NRFX_SAADC_EVT_DONE. Please advise

Parents
  • To close this issue. I have refered to the SAADC example and used TIMER1 (softdevice uses TIMER0).

    I have setup the timer to meet my sampling frequency and have confirmed i get the expected results.

    Thank you Karl for your support.

    maybe Nordic should consider to clarify that the nrfx_saadc_sample() only causes sampling of 1 sample and not the number of samples configured via nrfx_saadc_buffer_convert()

  • BardenDK said:
    Thank you Karl for your support.

    No problem at all! I am happy we could figure this out together and get your application to work as expected.

    BardenDK said:
    maybe Nordic should consider to clarify that the nrfx_saadc_sample() only causes sampling of 1 sample and not the number of samples configured via nrfx_saadc_buffer_convert()

    Yes, we will improve the function naming and accompanying API reference in the future.

    Best regards,
    Karl

Reply
  • BardenDK said:
    Thank you Karl for your support.

    No problem at all! I am happy we could figure this out together and get your application to work as expected.

    BardenDK said:
    maybe Nordic should consider to clarify that the nrfx_saadc_sample() only causes sampling of 1 sample and not the number of samples configured via nrfx_saadc_buffer_convert()

    Yes, we will improve the function naming and accompanying API reference in the future.

    Best regards,
    Karl

Children
No Data
Related