ADC Speed on Arduino Uno R4 Wifi

Hi, How can I speed up the ADC? It currently takes about 21.43µs to use analogRead(), and I'd be looking for anyway to speed this up. Thank You!!

Use a lower resolution.

What code have you got now that measured the 21.43us?

int analogPin = A0;
int val;
float timer;

void setup() {
Serial.begin(115200); // setup serial
analogReadResolution(10);
}

void loop() {

unsigned long y = micros(); // time_1

val = analogRead(analogPin); // read the input pin

//Serial.println(val);

unsigned long x = micros(); // time_2

Serial.println(x-y);
}

That being said, I'm locked down to 10bits on the ADC (Design Specification). Are there any quicker alternatives to analogRead()?

Are you REALLY using an R4? And have you read the data sheet?
https://www.renesas.com/en/document/dst/ra4m1-group-datasheet?r=1054146

You'd have to check for the Renesas RA4M1 specifically, but virtually all modern microcontrollers can have the ADC output to DMA directly, running in continuous mode. Given the specifications of the controller, you should be able to get around 1MHz sampling rate.

Thank you, I'll look into that.

Yeah, It's an R4. Do you have any suggestions?

Can you try running the adc read in a counted loop - say 100 reads?

Have you contacted the renesas group forum?

Also I wonder if val = analogRead(analogPin); is not the right way to do the analog read.
See here
https://renesas.github.io/fsp/group___a_d_c.html

analogRead is the Arduino API function to the code in the FSP that you linked.

1 Like