cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO output not working

abhijith_raj
Associate III

Hi, 

I’m working on an STM32G491 MCU and facing an issue with GPIO PB9.

In my project, I initialize PB9 as a digital output and try to set it HIGH, but the pin always stays LOW on the board.

However, if I configure PB9 as input and toggle the pin externally in the same circuit, I can read HIGH and LOW correctly.

Why would PB9 not go HIGH when configured as output? What could be the possible reasons or things to check?

1 ACCEPTED SOLUTION

Accepted Solutions

@Ozone 
Issue identified: I’m using STM32CubeIDE with the default CubeMX plugin for pin configuration. The pin was originally set as an input, and when I changed it to output in CubeMX, the generated code didn’t update accordingly. CubeMX wasn’t regenerating the new pin configuration in my project, so the code still had the old input settings.

View solution in original post

2 REPLIES 2
Ozone
Principal II

Nobody on this forum has a crystal ball, so you should post the relevant code.
There is even a specific editor menu point for that ('</>').

> Why would PB9 not go HIGH when configured as output?

Have you checked the schematics of your board ?
Other hardware at that pin might interfere.

Is the peripheral clock for GPIOB enabled ?

> ... and try to set it HIGH, but the pin always stays LOW on the board.

The STM32 GPIOs have separate registers for input and output, and separate output registers to set or reset pins.
Share the relevent code.

@Ozone 
Issue identified: I’m using STM32CubeIDE with the default CubeMX plugin for pin configuration. The pin was originally set as an input, and when I changed it to output in CubeMX, the generated code didn’t update accordingly. CubeMX wasn’t regenerating the new pin configuration in my project, so the code still had the old input settings.