I am trying to figure out how to run the ADC without interrupts on a SAMV70 using ASF4. My current code runs both ADC0 and ADC with all channels sampling at 20 msecs using interrupts. This is generating a lot of interrupts (1 for each channel or 2 x11 = 22). These frequency of these interrupts are causing problems with some of the communications channels.
I would like to change the ADC code so it does not use interrupts at all. I will have the main program check to see if all ADC channels are done and then transfer their data and start the next sampling period. (see code below)
I tried disabling the ADC interrupts by changing ADC_IMR so the interrupts are disabled. However, this appears to also disable the ADC channels so that adc_async_start_conversion() does not start the conversion.
So I tried using NVIC_DisableIRQ(AFEC0_IRQn)) and NVIC_DisableIRQ(AFEC1_IRQn) instead to disable the interrupts at the NVIC. My ADC routine runs the first time, reads all the ADC channels without interrupts. But then the next and all following conversions trigger interrupts.
How do I start the ADC conversions for all channels without getting interrupts?
Also I can’t find any register description (what the bits mean) for the NVIC in the SAMV70 datasheet. Can someone point me to the NVIC register information?
bool AdcDriver::RunBackgroundAdc2() { bool bFlag = false; uint16_t ui16Time; ui16Time = m_AdcTimer.GetMsecs(); if (AreAllChannelsDone2() == true) // Are all ADC channels done? { if (ui16Time >= m_ui16ChannelSampleRateMsecs) // Is it time to Sample ADC? { m_AdcTimer.Reset(); // Reset Timer ReadAllChannels(); // Reads ADC data into FIFOs adc_async_start_conversion(m_pAdc); // Start next conversions } } else { if (ui16Time >= (m_ui16ChannelSampleRateMsecs * 2)) // Has ADC timed out? { bFlag = true; // Error, ADC Timeout m_AdcTimer.Reset(); // Reset Timer adc_async_start_conversion(m_pAdc); // Start next conversions } } return(bFlag); }