cancel
Showing results for 
Search instead for 
Did you mean: 

Can the STM32 ADC do what the PIC16F ADC can do?

BrianG
Associate II

I have an existing design using an 8-bit PIC16F and am attempting to upgrade it to using the STM32L071, primarily due to needing more memory. This design has 6 input signals being sampled using the same ADC. One signal is an audio signal that needs to be sampled at an 8kHz rate. The other five signals are DC and their sampling rate isn't critical. With the PIC, I am using a timer to trigger ADC conversions at a 16kHz rate. The process then selects a different input upon the ADC results completion interrupt. It alternates between the audio signal and any of the other five DC signals, thus sampling the audio at an 8kHz rate. So... sample the audio, then DC1, audio, DC2, audio, DC3, etc. This has proven to be a solid process using the PIC. However, I cannot get this to work with the STM32 ADC because you cannot select or switch the input signals in this manner using the STM32 ADC. If I understand it correctly, you must pre-define all your inputs and sample them in the order they are labeled (or in reverse of that order). I am running experiments to fully understand the modes and capabilities of the STM32 ADC, but am struggling to find a way to use it for my purpose. Am I correct in my understanding? That you must pre-define the ADC inputs and can only change them by re-initializing. Can anyone with a good understanding of the STM32 ADC provide me with some direction?

4 REPLIES 4
TDK
Guru

For that chip, you can't alter the sequence to have it convert the audio channel every other conversion.

You could sample all channels at 8 ksps and just discard the ones you don't want.

Other STM32 ADCs (e.g. STM32F401 but many others) can be configured how you want.

If you feel a post has answered your question, please click "Accept as Solution".
BrianG
Associate II

Thank you! I will investigate sampling everything and taking only what I need at 8kHz.

I also was reading something about injecting conversions into the pre-defined channel sequence, but cannot find that in the parts' manual. Do you know anything about that or is it a different part?

I haven't worked with injected channels much. Are you looking at the reference manual (as opposed to the datasheet)? That would be the primary reference which would explain the details.
If you feel a post has answered your question, please click "Accept as Solution".
BrianG
Associate II

Injection is mentioned in AN3116 but not anywhere in the reference manual. Maybe it's not an option on this specific part.

Thank you for you help.