Page 1 of 1

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

Posted: Mon May 24, 2021 8:56 am
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.

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

Posted: Mon May 24, 2021 10:47 am
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

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

Posted: Mon May 24, 2021 10:56 am
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.

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

Posted: Mon May 24, 2021 3:22 pm
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?

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

Posted: Tue May 25, 2021 6:01 pm
by johu
You overloaded the poor low side mosfet and forced the pin high. But I think it can survive that

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

Posted: Sat Oct 09, 2021 7:31 pm
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.