Skip to main content
Visitor II
November 21, 2025
Solved

STM32G051c8t6 PA5 Not working as GPO

  • November 21, 2025
  • 3 replies
  • 233 views

I turned off all the other configuration aka Alternate Functions..only enabled GPIO PA5 as output Pushpull mode, low freq.its doesnt turn on or off individually..tried to turn on and off using HAL as well as direct registers..both work only when PA4 turns on ...what i mean if i want to turn on PA5 i should turn on PA4, then only it works..what is this causing this issue.can you help me out.tried on multiple hardwares..same issue so hardware issue eliminated, no pin short circuit.Screenshot 2025-11-21 103226.png 

    This topic has been closed for replies.
    Best answer by Ozone

    And in addition to that, check the schematics and user manual of your unnamed board, if external wiring could interfere.

    3 replies

    Super User
    November 21, 2025

    Double check that the generated code uses GPIO_PIN_5 and port GPIOA. Debug step into the HAL code setting PA5 like HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);.

    While debugging, check the peripheral registers view (aka STM32Cube Registers Tree) for GPIOA registers ODR and IDR.

    Its extremely unlikely that you found a chip related mismatch because G0 series was introduced in 2019 and there is nothing about that in the errata sheet.

    hth

    KnarfB

    OzoneAnswer
    Explorer
    November 21, 2025

    And in addition to that, check the schematics and user manual of your unnamed board, if external wiring could interfere.

    Visitor II
    November 21, 2025

    @Ozone @KnarfB  Thanks for the ANswers..@OZone  Schematics and board is a simple dev board which extends the pins of ic to more usable berg strip and programming done via direct 3v3 to SWD interface which works for past 8years.No hardware issue found. @KnarfB i looked into debugginf SFR register of GPIOA..

    both PA4 and PA5 Configured as ouput. both turned on and off after 2 sec => step by step debug reveals while starting..

    after HAL_init->MODER register 0xebffffff,IDR=>0x00,ODR=>0x00

    after  GPIOA clock enable-> IDR=>0x400,

    after GPIO init-> IDR=>0x400, MODER=>0xebfff5ff

    and come into while after PA4 writen on ->IDR=>0x4010,ODR=>0x10(till now ODR is 0x00)

    and after PA5 is written on->nothing changes

    while doing this repeated debug steps..both PA4and PA5 configured as GPIO(removed PA4 in another test still same result)..and turing PA5 only ON and OFF...step by step reveals...

    after HAL_Init->MODER register 0xebffffff,IDR=>0x00,ODR=>0x00

    after  GPIOA  clock enable-> IDR=>0x400,

    after GPIO init-> IDR=>0x400, MODER=>0xebfff5ff

    and come into while after PA5 writen on ->IDR=>0x4020,ODR=>0x20(till now ODR is 0x00)

    and come into while after PA5 writen off ->IDR=>0x4000,ODR=>0x00..

    Please help me out on this issue..i attach my code also

    Explorer
    November 21, 2025

    > and come into while after PA5 writen on ->IDR=>0x4020,ODR=>0x20(till now ODR is 0x00)
    > and come into while after PA5 writen off ->IDR=>0x4000,ODR=>0x00..

    Which means it works as expected, or not ?
    ODR = 0x20 means bit 5 (which is PA5) is set.

    Visitor II
    November 21, 2025

    Output is Not HIGH even though it set ODR=0x20, but idr 0x4010 and odr 0x10 means PA4 and PA5 both on..i know its strange but i am facing this issue. i am thinking configuration is wrong now after bit of searching PA5 configured as still analog..moder register should be after GPIO init-> IDR=>0x400, MODER=>0xebfff1ff instead, MODER=>0xebfff5ff..is that so..if thats the case GPIO init is not working..its standard Cube code of HAL gpio init..or am i thinking wrong

     

    Visitor II
    November 21, 2025

    Thank you for the reply its issue resolved works as intended PCB internal short resolved