2025-09-03 4:55 AM - edited 2025-09-03 4:55 AM
Hello,
On a custom-designed PCB, I am using an STM32H745IIT6 (LQFP176) MCU. I am actively using analog channels, various I/O pins, Ethernet, QSPI, and other peripherals. The code I am using was previously running on an F7 series MCU. It has been fully ported to the H7 version and tested. However, during testing, I noticed an issue with sampling on the PA0 pin, which is configured as ADC1 INP16 in single-ended mode. A total of 19 analog channels are active, and 18 of them show no problems, but on this particular channel I can clearly observe a shift in the raw ADC values.
- ADC1-2-3 are running in independent mode, 16-bit, triggered by Timer1.
- Data is read via DMA.
When I monitor with Serial Wire Viewer (SWV), I observe sampling behavior as shown in the image. The channel where I am experiencing the issue is the red signal shown with the name adc_bc. The other three signals were added for comparison. A single source was used to provide the signal to these four channels. When monitoring the raw ADC values, the difference at the upper and lower peaks can reach around 200–250. This corresponds to a calculation error of up to 10 mV.
The image on the SWV may be misleading due to scaling. The other image is an Excel graph generated with the same data. The orange one is our channel with the problem in there.
Does anyone have suggestions for a solution, or has anyone experienced a similar issue?
Thank you in advance.
2025-09-03 5:48 AM
What is your PA0 pin connected to? Can you show a schematic?
Past the multiplexer, the ADC is the same for all channels so must be something upstream from that.
Doing an FFT on the data might show something. Perhaps the signal is getting cross-talk of a specific frequency in which case the frequency will give clues as to the source.
2025-09-04 3:32 AM - edited 2025-09-04 3:36 AM
The connection to the MCU PA0 pin is as follows:
This circuit is the same for all channels. 1 VAC RMS / 50 Hz signal is applied from the AN_INPUT_11 label. It goes directly to the MCU pin from the AN_INPUT_MCU_11 label.
The graph of all raw values (better visualized from before) for a 10-cycle signal taken at a random time is as follows:
(yes, there is a picture with white background:) )
As you suggested, I performed an FFT on the raw data. (a normal channel, which shown in blue, was also included for reference).
There appears to be some signal around 85 Hz, but I am a bit doubtful that it would have such an effect.
2025-09-04 6:10 AM - last edited on 2025-09-04 6:14 AM by Andrew Neil
ADC channels are not the same, there are 3 categories;
Direct channels are connected to analog I/Os (PA0_C, PA1_C, PC2_C and PC3_C) to optimize ADC performance.
Fast channels correspond to PF3, PF5, PF7, PF9, PA6, PC4, PB1, PF11 and PF13.
Slow channels correspond to all ADC inputs except for the Direct and Fast channels.
So, I'd not expect readings matching in between them.
2025-09-04 6:17 AM - edited 2025-09-04 6:18 AM
85 Hz and its harmonics are in there. I don't think this is an STM32 thing. More likely something is getting coupled onto that channel from outside and the STM32 is just telling you what's there.
If the signals were the same, the FFT would be the same. They're not--so see what is different. The only difference here is the 85 Hz + harmonics (and a slight DC offset for blue). Still there for blue, but maybe 10% the amplitude.
Could be that the PA0 circuit is closer to the noise source and is therefore picking up more noise.