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