Why doesn't GPIOG work on the STM32L5?

October 29, 2020

The NUCELO-L552ZE-Q board wires it's LPUART1 pins GP7 and GP8 on PORTG to the debugger VCP...


I've been working on getting more boards ported to zig and UART is one of the first few features to port over. The UART instance was enabling fine but when writing to it, it would throw a FrameError every time. The scope was showing that it wasn't doing anything on the bus (hence the error). Setting up GP7 or GP8 as GPIO pins and toggling them didn't do anything on the scope either.

After wasting two full evenings digging through thousands of lines of code trying to figure out what I was doing wrong... I finally discovered that GPIOG will not work on the STM32L5 (and apparently the STM32L4) without setting the "VDDIO2 Independent I/Os supply valid".

A simple write to PWR_CR2:

// Set VDDIO2 as valid or GPIOG won't work
util.setBit(&PWR.CR2, hw.PWR_CR2_IOSV);

And now it works... To any ST devs out there, please document this kind of stuff!!

Hope that helps someone!