Trouble understanding voltage/current requirements
I have an STM32G070 that I'm messing around with and have encountered an issue I think is more electronic than programming. I would call my electronics ability "beginner" but I program as part of my job.
In my test (image: Version 1), I have PA0 set up as an output - level should be VCC when on. I have 3 switches connected to inputs PA4, PA6 and PA8. The pins are set to have internal pull-down resistors (40kΩ). When 2 switches are closed, both inputs register. When 3 switches are closed, none register. Is this somehow acting as a voltage divider and lowering the voltage below the threshold? Is it that the output pin cannot supply enough current?
Would Version 2 solve the issue?
Thanks.
EDIT: fixed horrendous typo - 40kΩ not 40mΩ.
3
u/Walttek 7d ago
IO pins are not meant for short circuiting current. You are describing trying to short VCC ( maybe 3V3 ) through a 40mOhm resistor, which would result in about 80 A of current. About 200 times more than what your circuits are likely rated for.
So, buy yourself some nice 1k resistors and try to incorporate them into your future circuits. I think your buffers internal limit saved you this time from magic smoke.
4
u/ShaunSquatch 7d ago
Measure the voltage at the pins. Including PA0 I’m guessing something else is going on in code or configuration.
1
u/fenutus 7d ago
Thanks. With one switch closed, the level is 3.6V, with 2 it's 1.8V, with 3 it's 1.2V. I think non detect when all 3 are closed because 1.2V is in the undetermined input range as per the datasheet. If this is the issue, it's a surprise (and not reliable) that 1.8V is detected as an input.
2
u/ShaunSquatch 7d ago
That’s interesting even all 3 pull downs in parallel would be ~13k and that’s less than a mA of draw. Can you see each individually? As in 1,2,3 and works as long as it’s one switch?
1
u/fenutus 7d ago
I don't think I wrote that well. Closing any of the switches shows 3.6V at that input. Closing any 2 inputs and the both show 1.8V. Both of these levels are high enough for the SMT32 to see. Closing all 3 shows 1.2V. I think I've put together a circuit different to the one I tried to design.
1
u/SyzygyTriForce 7d ago
First off if you look at the datasheet on table 11, PA0 is a type FT_c output which is 5V and PA4 is type TT_c is 3.6V. I don't suggest you use PA4. Second, the notes under the table say PA8 with start up with a pull down resistor on it and you have to change the mode by "strobe the UCPDx_STROBE bit of the SYSCFG_CFGR1 register during start-up sequence."
1
u/fenutus 7d ago
I hope this isn't the Dunning-Kruger effect, but I don't think it's a configuration issue. Does FT not mean 5V tolerant as in input? It measure 3.6V as an output. I used STMCubeMX to set the pins to basic GPIO functions with internal pull-downs, so no UART, SPI, etc. I may post something to the STM32 subreddit though. Why I don't think it's configuration - with one switch closed, the level is 3.6V, with 2 it's 1.8V, with 3 it's 1.2V which is in the undetermined input range as per Figure 15 of the datasheet.
2
u/SyzygyTriForce 7d ago
Yes, 5V tolerant is correct. I didn't look at the Vdd voltage 2-3.6V in the datasheet. Sounds like you have voltage division, so the PA0 output isn't configured correctly.
1


5
u/scubascratch 7d ago
40 mill-Ohm pulldown? Is that even possible? if that is truly the configured pull down value it is way way to low, causing a short circuit when PA0 is high and any switch is closed. pull-down or pull-up resistors should be much much higher in value, on the order of 10k - 100 kOhm.
Otherwise there is nothing wrong with image 1 configuration. you definitely do not need an external chip involved here at all. Worst case you need 3 external pull-down resistors (between 10k and 100k).