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

Problems with SAADC

Hello, I am trying to use SAADC with nrfx APIs and the ADC does not execute the conversion, and the callback function is never called.

Here is my code:

//ADC interrupt callback function
void adcCallback(nrfx_saadc_evt_t const * p_event) {
  uint8_t debug1 = 0;
  debug1++;
  if (p_event->type == NRFX_SAADC_EVT_DONE) {
    debug1 = 0;
  }
}

int main(void) {
//Init the ADC
  nrf_saadc_channel_config_t channelConfig = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
  nrfx_saadc_config_t         adcConfig = NRFX_SAADC_DEFAULT_CONFIG;
  
  err_code = nrfx_saadc_init(NULL, adcCallback);
  APP_ERROR_CHECK(err_code);

  err_code = nrfx_saadc_channel_init(0, &channelConfig);
  APP_ERROR_CHECK(err_code);

  err_code = nrfx_saadc_buffer_convert(adcBuffer[0], SAMPLES_IN_BUFFER);
  APP_ERROR_CHECK(err_code);

  err_code = nrfx_saadc_buffer_convert(adcBuffer[1], SAMPLES_IN_BUFFER);
  APP_ERROR_CHECK(err_code);

  nrf_saadc_value_t value1 = 0;
  nrfx_saadc_sample_convert(0, &value1);
  
  while (true)
    ;
}

I am using also the GPIOTE functions from my other post (Example)

15.3 SDK, PCA10040

I have connected multiple cables from different potentiometers to the PCA board, using the P2 connector, which according to the user guide (and the back side of the board) should all be the analog inputs.

I will try to set the pins as inputs using GPIO functions, see if that changes anything.

Any help is appreciated. Thank you

Parents Reply Children
No Data
Related