STM32 gotchas
86.'G0/'G4 USB-C Dead Battery conundrum (pin influenced by other pin, unexpected pulldowns)

The STM32G0xx and STM32G4xx families feature USB-C Power Delivery support. Part of this is so called Dead Battery support, where a battery-powered device signals readiness to receive power even if it is not powered/running, due to discharged battery. This is simply a nominally 5k1 resistor to ground.

In 'G0/'G4, this resistor is present in the UCPDx_CCx pins (see Pin assignment and description table in Datasheet to identify which pins have this functionality). It is connected through a transistor, gate of which is brought out to respective UCPDx_DBCCx pin. The purpose of this arrangement is for the users to be able to disable the 5k1 pulldown, by tying the UCPDx_DBCCx pin low (otherwise, if dead-battery support is desired, UCPDx_DBCCx pins should be connected to their respective UCPDx_CCx pins).

Remember, that this functionality has to be present even while the mcu is not running, so this is implemented purely in hardware. Once the application is running, it can disable the pulldown by setting UCPDx_STROBE bit in SYSCFG1_CFGR1 in 'G0/UCPDx_DBDIS in PWR_CR3 in 'G4.

There are several confusing consequences from this, for users who are not aware of this functionality:

Assorted threads from the STM32 forum dealing with the problem: here, here, here, here, here, here, here.