2025-06-26 4:36 PM
Hi
I use CPU pin 6 as ADC input ADC_IN12. I take measurements every 100us and save them to buffer[100] via DMA.
I have a 1M+10k resistor divider connected to ground to the ADC input.
I measure a rectified sine wave signal within 0..2V.
To my surprise, after a few minutes of measurement, the signal increased by about 400mV and it should go down to zero. It turned out that an internal pull-up was created in the CPU on pin 6 and even 10k to ground is not able to lower it to zero.
Connecting a milliammeter to ground gives about 0.7mA. I thought the program was to responisble for this situatiuon, but I made a test program in which the pin is only an input and the pull-up is permanent.
After replacing the CPU, the problem disappears and appears after another few minutes.
I checked it on 4 pieces. I have no idea what could be the reason for this, an oscilloscope connected to this input shows a rectified sine wave one moment and after a few minutes the same signal but with an additional constant component. Does this fit into errata documents?
I reject the possibility that the input signal or interference exceeded VDD or was below VSS. Additionally, a 10nF capacitor was connected to ground
Maybe if I used a divider with a 1k resistor I wouldn't notice the problem but it has a big impact on the measurement itself. Has anyone had a similar problem?
I have not encountered such a case on any STM32. Is there any way to fix this? I am not lucky because I also tried to measure on pin 4 (NRST) which I disabled in OB software. The measurement itself worked fine on the same program except that at the start for the first 4 clock cycles the pin is a reset and only the logical 1 signal is able to start the CPU which is very problematic if we want to use this pin as an ADC input :(
Regards
2025-06-26 5:14 PM - edited 2025-06-26 5:16 PM
The chips don't spontaneously generate internal shorts. Something happened. And on 4 chips, it's repeatable. Look at transients at startup or whenever a change happens.
Can you show the signal you're measuring on a scope?
This is your circuit?
[SIGNAL] --- [1 MOhm] -+------------+--- [ADC PIN]
| |
[10 kOhm] [10 nF]
| |
[GND] [GND]
You have 200V on the board. Is everything sufficient isolated? Can you show the board layout/schematic? Note that flux residue or cleaning products can cause high resistance paths between components you don't want.
2025-06-26 10:21 PM
Don't forget that each resistor has some stray capacitance, so TDK's 10 nF (or whatever fits) is actually a must have and might already help.
And a TVS or Zener diode wouldn't hurt either.
At these input voltages you should "protect" the MCU with a (opamp) active voltage divider (inverting with bias).
Depending on the sine frequency you might get some rectifying behaviour and thus some higher voltage than you expect. Mind the low pass behaviour, though...