Why does the dead battery feature of UCPD cause issues reading the CC voltage?
I am trying to use the UCPD peripheral on a STM32G4 (later on STM32G0) target to detect when a debug accessory device has been plugged into the USB-C port. This is going to be used in factory test.
The issue I'm having is the dead battery pull downs are causing erroneous readings in the TYPEC_VSTATE_CCx registers.
I noticed when I uncheck the "Dead Battery Signals" box in STM32CubeIDE (UCPD Mode and Configuration window), the issue goes away. I am pulling up the CC pins with a 56k ohm resistor to 5V to indicate a standard USB power source. The CC voltage with the "Dead Battery Signals" disabled is 0.432V, as would be expected with a 5.1k Rd. With "Dead Battery Signals" enabled, this voltage goes up to 0.644V and the TYPEC_VSTATE_CCx registers start reporting erroneous values (ie: not vRd-USB, as per table 428 in RM0440).
I then measured the voltage when the MCU was unpowered. It was around 0.62V, which I suppose is fine because a USB-C Source should recognize this as a Sink connected. This was the case regardless of the “Dead Battery Signals�? checkbox. I then realized that the DBCC pins are “enabled�? regardless of this checkbox when the MCU is unpowered. This checkbox is extremely confusing!
My notes are below:
The UCPDx_DBCCy pins have special hardware, they do not require register settings to enable them.
If they are shorted to their respective UCPDx_CCy pins, the Rd resistors will automatically be enabled when power is applied to the CC line, even if the MCU is completely unpowered (ie: battery is dead).
However, it seems that having this dead battery pull down enabled when the UCPDx peripheral is operating (ie: it has enabled its own internal CC1/CC2 Rd pull-down resistors) causes incorrect voltage level readings in the TYPEC_VSTATE_CCy registers.
It is not made clear in the documentation (UCPD section nor CubeMX) that this may happen. There is no mention of the related UCPD1_DBDIS register in Power Control Register 3 (See RM0440, section 6.4.3)
The only place where UCPD1_DBDIS is mentioned is in the debug (DBG) section (section 47). This is mentioned because it can cause issues with the JTAG reset function on the same pin. This register is not mentioned in the UCPD chapter at all.
The "Dead Battery Signals" checkbox in the CubeMX UCPDx configuration GUI sets this bit (disables dead battery pull downs) if left unchecked. Checking this box (enabling dead battery signals from a user perspective) does not affect their actual operation when the MCU is unpowered. This is misleading. The only effect it has is clearing the UCPD1_DBDIS bit, enabling the dead battery pull-down resistors at runtime. Checking this box only causes issues with UCPD CC voltage detection.
I'm mostly writing this so that others that may find this and save them a few hours of confusion.
ST -- please update the reference manual with information about this and add a note about the UCPD1_DBDIS bit!
