Using XIAO ADC in background

I would like to use a lower-level interface to XIAO ADC. What I mean is I want to be able to manually start the ADC conversion, run some commands in parallel (while ADC is working) and then retrieve the ADC result once it is ready. That is what’s known as “Single Conversion” mode for Atmega controllers.

To illustrate it with an example, on boards like Arduino UNO we do it as follows

/* Initialize ADC control register for Single Conversion 
   mode and division factor of 32 */
ADCSRA = bit(ADEN) | 5;

/* Use AREF as reference voltage, read from pin A0 */
ADMUX = 0;

...

cli();

/* Ask the ADC to start the conversion */
ADCSRA |= bit(ADSC);

for (/* some number of iterations */)
{
  /* Wait for ADC conversion to finish */
  while ((ADCSRA & bit(ADSC)) != 0);

  /* Retrieve the result of the conversion */
  int16_t value = ADC;

  /* Ask the ADC to start the next conversion */
  ADCSRA |= bit(ADSC);

  /* Process the value, while ADC works in the background */
  ...
}

sei();

How do I do something like that in Seeeduino XIAO? Is it possible? Plain ‘analogRead’ is not acceptable since it is a blocking operation, which will wait for ADC results without letting me do anything in parallel.

So, where can I find the description of lower-level ADC interface? Is it available?

Thank you

OK, found source code for analogRead, which shows how it is done. Should be enough for me for now…

Hi, did you have any luck with this? I’m also looking for a non-blocking analog read on the Xiao