How interrupt is working in the ADC(in nrf saac driver)?

Hi,

How interrupt is working in nrf saac driver? I can see that it is already code is present in the adc_nrf_saac.c

static int init_saadc(const struct device *dev)
{
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END);
nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE);
nrf_saadc_int_enable(NRF_SAADC,
NRF_SAADC_INT_END | NRF_SAADC_INT_CALIBRATEDONE);
NRFX_IRQ_ENABLE(DT_INST_IRQN(0));
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
saadc_irq_handler, DEVICE_DT_INST_GET(0), 0);
adc_context_unlock_unconditionally(&m_data.ctx);
return 0;
}

How the flow of interrupt is working ?

Do we required any coding from application to enable the interrupt ?

here only interrupt is enable for two events that is  NRF_SAADC_INT_END and NRF_SAADC_INT_CALIBRATEDONE , Can we generate interrupt on more events ?

  • Hi

    Have you read the SAADC chapter in the product specification
    It shows the relationship between the different tasks and events.

    Essentially the driver only exposes the END and CALIBRATEDONE events, since these are the most critical ones for most use cases. 

    The END event happens after one of the SAADC buffers have filled up, which is normally when the application needs to respond and process the data in the buffer.  

    The CALIBRATEDONE event happens once calibration is complete, telling the application that the SAADC module is now available for sampling again. 

    Do we required any coding from application to enable the interrupt ?

    No, as long as you configure an event handler through the driver the interrupt will be enabled accordingly. 

    Best regards
    Torbjørn

Related