VOsch.net

PCB Fail: IO staying high? Inputs not reading? Grrrr, my MOSFETS!

I was using an STM32L01 to drive a PMOS based high side switch to a boost converter, nothing new. Unfortunately this time, it felt like the MCU IO wasn't responding to me at all!

First steps, sanity

Let's just use the smallest code possible to validate the issue:

#include <gpio.h>

int main(void) {
    gpio_init(BOOST_EN_PIN, GPIO_OUT);
    gpio_clear(BOOST_EN_PIN);
    return 0;
}

to pull the IO pin low - since it's a PMOS the input is reversed - to activate the booster. Now measure the output:

Multimeter showing 0.0V on booster v input

That's not right. Perhaps I misremembered the inversion, let's just uno reverse it:

gpio_set(BOOST_EN_PIN);

Nope... Still 0V. Let's pull it low again and measure the PMOS gate voltage instead.

Multimeter showing 5.2V on MOSFET gate

How's that 5V? Right, it has a pull-up resistor. But I've cleared the IO, so it should definitely be low right now... Or at least see some smoke appear.

Schema / PCB checks.

Okay, let's quickly verify the Schema.

Schema showing a PMOS with 5V line on Source, Boost V_In on Drain and BOOST_EN pin on Gate with a 10k pullup to Source

Source is attached to Vin (5V) and drain to Boost Vin. Nothing out of the ordinary, perhaps I messed up the PCB although I am certain I ran DRC.

PCB showing the MOSFET correctly connected according to KiCAD

Nothing seems wrong here, DRC not complaining, wired up correctly.

Let's make sure the MCU is doing as told.

Let's take a step back. The firmware is definitely setting the IO to low, let's add a quick printf statement to output the IO registers. Our pin is PORT_B pin 12.

[boost_enable] GPIOB MODER=cd30a3ff ODR=00000000 IDR=000018c0

(MODER >> 24) & 0b11 == 0b01
// 0b01 is "General Purpose Output"
ODR == 0
// ODR is all zeroes, so low.
(IDR >> 12) & 0b1 == 1
// IDR is 1, so reads high!?

Righhttt, so the MCU is trying, but something is reallyy pushing that 5V in.

Oooooohhhh

It's almost as if something is pushing that 5V in.

Right, sounds like a straight up short. I can't see any shorts on the PCB, perhaps I simply designed it wrong. Let's grab the pinout:

The MOSFET Pinout obviously being different than the schematicPCB showing the MOSFET correctly connected according to KiCAD

Huh. That gate is definitely not at the gate's position.

What I learned

Just, check basic component pinouts as well. Unfortunately I was working on 2 boards at the same time, and I simply copied the PMOS setup.