2025-03-03 2:59 AM
I'm using ADC regular and injected channels in STM32G4. I need different oversampling ratio for regular and injected channels, in STM32CubeMX it's possible to configure the oversampling ratio independently for regular and injection channels, but when I took a look at the generated code I saw that the same function has been called for oversampling configuration. It seems like the second function call is overriding the first configuration.
Also I've checked on oscilloscope to measure both channels acquisition times. When I'm modifying the parameters of the first function call (which is the oversampling ratio of the regular channels), I see no changes in acquisition time of the regular channels, it's just following the parameters of the second call (injected channels oversampling ratio).
I have 2 questions:
Why we have configurations for oversampling ratio of both channels in STM32CubeMX, when it's not possible to control them independently?
Is there a way to have different ratios other than calling the LL_ADC_ConfigOverSamplingRatioShift() before every conversions? Because generally the purpose of using injected channels is to read the analog signal in precise timing and minimize the CPU workload , so calling this function in every trigger events makes no sense for INJECTED channels.
2025-03-03 6:24 AM
Oversamping for regular and injected channels can be enabled independently, but, if both are enabled, they follow the same oversampling scheme. If you need different oversampling configurations, you'll have to do that in software.
2025-03-03 6:40 AM
Thanks.
So it doesn't make sense to have two configurations in the code generator and call LL_ADC_ConfigOverSamplingRatioShift() two times when we enable oversampling for both channels. I think ST should fix this confusion in the next updates.