10 years, 8 months ago.

How i can set ADC sampling time?

There are already related questions ... but no good answer for my application. I would like that the ADC sampling will start after 15us and will continous read every 20us

is this posible and how?

1 Answer

10 years, 8 months ago.

You can use a Ticker and call AnalogIn every 20us, although it will be close if AnalogIn is fast enough. You can get it faster with directly writing the ADC registers, google the user manual for it. Mainly because AnalogIn does three conversions (5us per conversion) and takes the median of that. It might be just fast enough, you can check that of course, it also depends on what else your mbed must do at the same time.

You can have a look at http://mbed.org/users/Sissors/code/FastAnalogIn/, it runs the ADC at the background. Main downside for you will be that you don't know exactly when the last sample was processed, while if you use AnalogIn or directly do a single conversion with register writes you do know exactly when that is done. Upside is that it is alot faster than any other option, leaving more time for other processes.

Accepted Answer