The ADC (analog-to-digital converter) which is required to read an analog value doesnt work like a digital pin. It takes a bit of time for the ADC to measure the input. As per this reference it takes about 100 microseconds on ATmega based boards.
Funnily enough me trying to figure out how fast the ADC on an R4 minima is took me to this post.
So, to fully answer your question, you are not getting any faster than whatever the speed of the ADC is on the chip. Now there is also a caveat to this, that being that as per the official datasheet for the RA4M1 chip, the ADC only supports 12-bit and 14-bit operation (Table 1.8), however, by default, the analogRead() method is 10-bit by default for compatibility reasons with ATmega chips, so this might cause extra delay depending on implementation. It can be changed however, so that would be the first avenue to look into.
The documentation for the ADC starts at page 87 of the datasheet. As per Table 2.42, under the best circumstances in high-speed conversion mode, the ADC can take a measurament every 0.7 microseconds, however that is assuming the input impedance is less than 0.3 kΩ.
Reading further, the low power times are from around 2 microseconds to 21 microseconds, again depending on input impedance, reference voltage, etc.
Note that all those values are for the case where the ADC operates on its maximum clock (64 MHz), so if the ADC is running slower on the arduino, then you should expect slower measuring speed. The ADC takes samples of the input on that clock frequency, so keep in mind that the worse the conditions, the more samples it needs to give you an accurate reading, so the more time it takes.
My guess is that the ADC is in low power by default on the arduino, so writing your own analogRead() and setting the registers for high speed is a viable solution. Your best bet is first calculating your input impedance, looking up the apropriate table in the datasheet going from there.
My personal take on this, its easier to write code around this than dealing with it. First and foremost, if you write your own analogRead(), you are bound to that specific chip, so it wont work on other arduinos not based on the RA4M1. IMHO not worth the hassle.
I use one of the following three workarounds:
- If I dont care about doing nothing while waiting for the ADC, I just slap a delay(1) before it and am done. 1 millisecond is enough for any ADC you might come across.
- If I do care about doing nothing for one milisecond and dont care about optimizing code for speed on all chips. I just use millis() to make sure the ADC has enough time to do its thing.
- Lastly if everything needs to be perfect, I count program cycles and after estimating the lenght of loop() I try to read only in certain cycles based on the program lenght. I just abuse the overflow of uint8.
- It would be only here that I would consider needing faster read speed on the ADC.
Anyway hope you enjoyed my essay and hope this answers your question