cancel
Showing results for 
Search instead for 
Did you mean: 

ADC single vs continuous mode. If the ADC is set in single conversion mode will a repetitive pin read initiate another conversion at each read or will the same data be read each time after the first read?

TJM
Senior
 
6 REPLIES 6
S.Ma
Principal

ADC has 2 trigger pins, one of normal and injected channels. When there is a trigger signal, a sequence of one to many channel can be performed. Iniected channels own individual data register while normal channel typically requires a dma to store multiple channels in a ram array.

Injected channels have higher priority than normals and a min max interrupt can optionally be triggered.

TJM
Senior

Thanks for the response.

In light of your answer the question becomes "does an analogRead() (or the ST-IDE equivalent) trigger another conversion in single conversion mode or do we need continuous conversion to always read fresh data?"

Just for the record, I've only introduced myself to the stm32 MCU in the past couple weeks so I'm in a collecting information mode.

Thanks,

tjm

Ozone
Lead

That depends on the implementation of the function analogRead(). I assume this name is just a placeholder here.

A simple read of the ADC data register will return the last result, and not trigger a conversion.

Continuous mode, OTOH, will start a new conversion after the previous one is finished, and overwrite the old result when done.

In most use cases, you want a notification (EOC or EOS interrupt of the ADC, or TC interrupt of the connected DMA) that a conversion result is ready.

There are not much practically meaningful use cases for continuous conversion mode. ST used it extensively in example code, because it is simple to setup. And the unsynchronized result read does not require any design effort.

For practical application, you usually want equidistant sampling, i.e. a regular (periodic) trigger, and coordinated samples from more than one channel.

TJM
Senior

Yes, just used the analogRead() as a generic 'lets get some data' placeholder. I think I understand what you mean here regarding the sampling. Thanks for that. It's probably the wrong place to ask this and just for my own info, if using a quick and dirty Arduino program as an example to read and display the ADC conversion data from a pin we don't see the setup code, so would it be normal to setup in continuous mode because it's easier or is the IDE smarter than that?

Arduino is hiding a lot under it's hood.Sometimes even important things, like init settings.

From a very superficial look, it seems to support a fixed number of analog channels for specific devices.

Initializing continuous mode and providing a simple API to retrieve an analog values is a simple method to implement it.

Just guessing, I don't use Arduino, and don't know any details.

However, in most applications, you need multiple ADC channels with determined relation, i.e. sampled at a specific rate, and basically simultaneous.

You wouldn't want to use continuous mode for that.

TJM
Senior

Again, thanks for the info.

I'll continue with the project now having a bit more information.

tjm