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

saadc_init fails with NRFX_ASSERT generated from err_code = nrf_drv_saadc_channel_init(0, &channel_config)

I am using SDK 15.3, SES 4.3 and SD 130.  I've added the saadc example code into my code which is comprised of the ble_central, nordic UART and saadc.

I've changed the timer instance from 0 to 1 and 2 because of the softdevice:

static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(1);

#define SAMPLES_IN_BUFFER 5
volatile uint8_t state = 1;

static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(1); // Eric - changed from 0 to 1 since 0 is used by SD
static nrf_saadc_value_t m_buffer_pool[2][SAMPLES_IN_BUFFER];
static nrf_ppi_channel_t m_ppi_channel;
static uint32_t m_adc_evt_counter;

//  APP_TIMER_DEF(saadc_timer);   // Eric - added this line. Code doesn't seem matter.
void saadc_timer_handler(nrf_timer_event_t event_type, void *p_context) {
  saadc_callback();
  printf("saadc timer timed out");
}

I thought that the app_timers used timer instance 1 and they are working fine. I've also tried timer instance 2 but it didn't solve anything.  

Please tell me what I am missing here.

Parents
  • Additional info:

    The error is generated in line 10 below.  This corresponds to line 297 of nrfx_saadc.c.

    nrfx_err_t nrfx_saadc_channel_init(uint8_t                                  channel,
                                       nrf_saadc_channel_config_t const * const p_config)
    {
        NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
        NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
        // Oversampling can be used only with one channel.
        NRFX_ASSERT((nrf_saadc_oversample_get() == NRF_SAADC_OVERSAMPLE_DISABLED) ||
                    (m_cb.active_channels == 0));
        NRFX_ASSERT((p_config->pin_p <= NRF_SAADC_INPUT_VDD) &&
                    (p_config->pin_p > NRF_SAADC_INPUT_DISABLED));
        NRFX_ASSERT(p_config->pin_n <= NRF_SAADC_INPUT_VDD);
    
        nrfx_err_t err_code;
    

Reply
  • Additional info:

    The error is generated in line 10 below.  This corresponds to line 297 of nrfx_saadc.c.

    nrfx_err_t nrfx_saadc_channel_init(uint8_t                                  channel,
                                       nrf_saadc_channel_config_t const * const p_config)
    {
        NRFX_ASSERT(m_cb.state != NRFX_DRV_STATE_UNINITIALIZED);
        NRFX_ASSERT(channel < NRF_SAADC_CHANNEL_COUNT);
        // Oversampling can be used only with one channel.
        NRFX_ASSERT((nrf_saadc_oversample_get() == NRF_SAADC_OVERSAMPLE_DISABLED) ||
                    (m_cb.active_channels == 0));
        NRFX_ASSERT((p_config->pin_p <= NRF_SAADC_INPUT_VDD) &&
                    (p_config->pin_p > NRF_SAADC_INPUT_DISABLED));
        NRFX_ASSERT(p_config->pin_n <= NRF_SAADC_INPUT_VDD);
    
        nrfx_err_t err_code;
    

Children
No Data
Related