cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Modes

Amir1
Associate II

Folks

Is there a good resource for understanding various ADC modes in F303 family? There is much confusion about the terminology (regular versus injected, continuous versus discontinuous, etc.) The material presented in manual/datasheet are diffuse, vaguely or not at all defined, or, at times, inconsistent. The also seem to be inconsistent with CubeMx settings. For example, I gather from the documents that injected mode is used when conversion is trigered by software or by some event (such as timer trigger out event). However, the setting for CubeMx allows TRGO only for the regular mode and not for the injected mode.

I have also reviewed AN3116, but do not feel much more informed.

Amir

Thanks

3 REPLIES 3
S.Ma
Principal

Well, overall, the ADC have multiple input channels.

One of the ADC have internal additional channel such as Vref Vbat Vtemp

The channels are in 2 groups: Normal and "Injected" (=higher priority)

All normal channels share a single data register, so typically you'll use DMA to store multiple channel results. You can trigger a sequence of channels typically by a physical trigger pin or internal signal.

The injected channels are "higher priority" and each one has its own register.

Injected share a different trigger GPIO to launch conversion.

There is a feature called "analog watchdog" which can trigger an alert if an injected channel goes above or below limits.

That's the overall idea. When multiple ADC are present, it's possible to sync up 2 of them to boost the samples per second.

Continuous is where the ADC is in saturation, where one sample starts immediately after the previous one completes. Operation is "Continuous"

Discontinuous would be where each group of samples (you list and rank) starts when triggered or requested to start. It can be repeatedly triggered via a TIM, I would tend to use this pacing as it is not dependent on other ADC settings, timings or clocks. Easier to set a TIM to do 44100 Hz "sampling".

Injected is where you want to throw some other randomly arriving request to convert into the mix. Say you get an EXTI from a button on an oven door or something, and only then do you want to measure a temperature, or something..

The REFERENCE MANUAL clearly defines triggering sources including TRGO and EXTI for the ADCs Injected operation.

0690X0000087ZLoQAM.jpg

https://www.st.com/content/ccc/resource/technical/document/reference_manual/4a/19/6e/18/9d/92/43/32/DM00043574.pdf/files/DM00043574.pdf/jcr:content/translations/en.DM00043574.pdf

CubeMX is a monkey, and not a very smart one. Understand how the silicon works, then you won't need it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you both. I am much more clear now and have done some successful exploratory hardware tests too. One part of the confusion was the liberal use of the word "single" in the documents to refer to both the number of channels and a single-shot conversion.

One more thing: my tests show that if a trigger event is used (I am using TIM2), the continuous conversion becomes irrelevant as the ADC will convert once per trigger event anyways. In other words, TRGO turns the operation into a periodic single-shot conversion, irrespective of the selection of the continuous mode (I have to inspect the manual to confirm or reject this though). Thus far, I have managed to read a high-frequency signal from the ADC and reproduce it with excellent fidelity at an analog output, with both ADC and DAC trigered by TIM2 TRGO.

Clive: What I use CubeMx for is to get my foundational code. Otherwise, for trimming, I use register-level coding (i.e., working with the silicon as you call it) with the aid of the manual. I agree that code generators, irrespective of their level of smartness, are not really suitable for elegant coding or learning, but they come in handy for me to get something basic going first on which I could base a deeper understanding. Will abandon it as soon as I get good enough. Thank you again.