2021-06-24 09:08 AM
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?
2021-06-24 09:22 AM
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.
2021-06-24 09:53 AM
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?
2021-06-24 10:30 AM
2021-06-24 10:50 AM
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.