GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post Reply
User avatar
janosch
Posts: 306
Joined: Tue Jun 30, 2020 9:23 am
Location: London, UK
Has thanked: 67 times
Been thanked: 54 times
Contact:

GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post by janosch »

Here is an odd one:

I only get a reading from my GPIO pins when I have a pre-resistor of less than 30 Ohm & 3.4V. That's nearly a short to ground. This worked for a while but I lost pins one by one.

- Did I burn the pins out previously and now they need a lot of current to still trigger them?
- What is a typical and reasonable value for a pre-resistor that should still trigger a 3.3V pin? 7k Ohm?

I am using Olimex STM32H103 & stm32-template.

I will try an experiment this afternoon where I work myself down from a 500k resistor with a fresh chip.
User avatar
joromy
Posts: 371
Joined: Fri Jun 28, 2019 12:56 pm
Has thanked: 1 time
Been thanked: 3 times

Re: GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post by joromy »

Inputs have max rating of 3,6V, some of the inputs are 5V tolerant, but I always put a 10k in series to be sure.
This pdf may help to understand the different methods of input/output circuitry.
STM32_5VtolerantIO.pdf
(298.03 KiB) Downloaded 115 times
Thomas A. Edison “I have not failed. I've just found 10,000 ways that won't work"
User avatar
janosch
Posts: 306
Joined: Tue Jun 30, 2020 9:23 am
Location: London, UK
Has thanked: 67 times
Been thanked: 54 times
Contact:

Re: GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post by janosch »

Lovely thanks, I will give that PDF a read.

I also just did the measurements and some of the pins work with 2.7k Ohm, so I suspect I just burnt the other ones out when I first played around with them!

10k Ohm good value to know, too, I thought it had to be something in the thousands like that.
User avatar
janosch
Posts: 306
Joined: Tue Jun 30, 2020 9:23 am
Location: London, UK
Has thanked: 67 times
Been thanked: 54 times
Contact:

Re: GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post by janosch »

Ok, I must be making some other mistake, and not just burnt out pins.

I have four wires coming into a fresh chip now and all with 10k Ohm resistors, I activated the internal pull-down, and all of them are on GPIOB* which is on.

Green: triggers as expected.
Three others: when switch is closed, voltage at switch drops from 3.2V to 0V, but my circuitry does nothing.

I tried measuring the I/O pins for resistance.
Green: Ohmmeter triggers the switch functionality.
Three others: 27, 26, 34 Ohm respectively. I expected 30k - 50k from internal resistor.

* = GPIOB9,8,7,1
I also just spotted that GPIOB1 which is my green wire is configured as PIN_OUT in `write_bootloader_pininit` in `hwinit.cpp`. That might be a clue. Investigating. But if that was the issue, how did it ever work before I wonder.


EDIT: FOUND IT!
hwinit.cpp set exactly the other three pins as output pins. I assumed digio_prj.h is everything I needed to look at, but I also needed to delete the following line:
// gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO7 | GPIO8 | GPIO9);

So I put Amps into pins that were configured as outputs!

Then the final question, why did they still work as inputs when my resistance was small enough/non existent?
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post by johu »

You overloaded the poor low side mosfet and forced the pin high. But I think it can survive that
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: GPIO Pin only triggers with less than 30 Ohm pre-resistor

Post by EV_Builder »

and on top of that all outputs can be back-read if i'm correct. So you can read if the actual output setting is reached or not.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
Post Reply