I have 24VDC signal and I want STM32G030K6 MCU to detect it (state low/high). I know this MCU has internal diodes on some pins, connected from inputs to VDD and max positive injected current is 5mA. Can I just apply this 24VDC through eg. 100k series resistor with internal diodes turned on?
1 Answer
This will work but I wouldn't consider it a good design because it will lead to external current flowing somewhere which is basically out of your control. And probably not the intended way to power things on your board.
The internal protection diodes are also not a really well defined part of the MCU, so this might lead to different behavior, especially over longer periods of time and under different temperature.
I would probably use a resistive divider to bring the voltage down to VDD levels, or 5 V (most pins are 5 V tolerant). If you care about preventing single failures resulting in catastrophic failures adding the series resistor at the pin is probably a good thing too.
If your only concern is cost then the series resistor will work, but I won't make any guess on how reliable that is.
This question and answers might be worth a read as well.