2019-11-01 10:15 PM
Hey,
the STM32G431 data sheet states that the UCPD unit has internal pull-down resistors. Now I want to flash my G431 via DFU, and USB-C doesn't provide power to a sink unless CC1 and CC2 are pulled down.
It seems that the internal UCPD only works when the MCU is flashed; can I use the internal UCPD with external resistors on CC1 and CC2? This seems to be required to flash the MCU via DFU the first time;
Can I still use the UCPD of the G431 in this case?
Solved! Go to Solution.
2019-11-16 09:35 AM
Have you researched into dead battery mode of USB-C PD? The entire purpose of this functionality is to present the Rd pull-downs so that the source provides that base +5V needed to power your core and PD controller. I think this might be what you're describing.
You do not need to add your own external resistors, as the STM32G431 presents Rd even while the MCU is powered off. It requires 2 additional pins, each one is simply shorted to its respective CC line.
Check this App Note from TI for thorough high-level discussion:
2019-11-14 04:00 PM
The UCPD unit doesn't provide power to the MCU, it only manages the PD negotiations via the CC lines; the intention being to control supply of an external load.
If you are trying to sink VBUS on an UFP to power your MCU (via VIN or +5V pins), then yes you can simply pull the CC pins on that UFP to ground. Those pins are not connected to the UCPD unit. Note however you will only get "Default USB" supply (+5V, 500mA), so you will only be able to use the +5V pin to power the G431, since VIN requires at minimum 7V-12V.
But no, I don't believe it's possible to power the MCU using that same MCU's internal UCPD interface.
2019-11-15 11:42 AM
So you basically convey that the UCPD in the G431 can't be used to negotiate power to the device itself, if powered via USB.
I looked at the data reference manual again and I'm pretty sure it should work; the reference manual says that by setting ANAMODE in the UCPD_CR register, UCPD is configured as sink; subsequently, CC Rd resistors can be enabled via the TYPEC_VSTATE_CC1 and TYPEC_VSTATE_CC1 values in UCPD_IMR register.
Nothing in the reference manual states that the UCPD can't be used to negotiate PD for the device itself.
However, configuring a G431 to UCPD sink in STCubeMX doesn't seem to generate code which works for this...
2019-11-15 12:42 PM
Well, generating code from ST32CubeMX for an STM32G431 to act as a USB PD sink doesn't work out-of-the-box in general, regardless if the load is external or not. You should expect to make modifications to the generated code. I'm using the same MCU =)
Anyway, regarding your actual question, I think my first answer may have been confusing or misleading. I'll elaborate.
To power the MCU from a USB PD source so that it's in a state you can flash the DFU bootloader, you don't need to generate and implement a USB PD sink device at all. The USB PD protocol will cause the upstream PD source to provide sufficient power as long as the CC pins present the correct Rd resistors. Simply follow these steps:
Now the important part of this process is detailed in the STM32G431KB user manual, section 6.4.1 "Debugging while using VIN or EXT as an external power supply", which says:
When powered by VIN or 5V, it is still possible to use the ST-LINK for
programming or debugging only, but it is mandatory to power the board first
using VIN or EXT (either 3V3 or 5V), then to connect the USB cable to the PC.
By acting this way, the enumeration succeeds, thanks to the external power
source. The user must respect the following power-sequence procedure:
1. Connect the external power source to VIN or 5V
2. Power on the external power supply 7 V< VIN < 12 V for VIN, or 5 V for 5V
3. Check that the green LED LD4 (5V_PWR) is turned ON
4. Connect the PC to the USB connector CN1
If this order is not respected, the board may be powered by USB first, then by
VIN or 5V as the following risks may occur:
1. If the board needs more than 300 mA current, the PC may be damaged or can
limit the current supplied. Consequently, the board is not powered
correctly.
2. Enumeration requests 300 mA, so there is risk that the request is
rejected and the enumeration does not succeed if the PC cannot provide
such current. Consequently, the board is not power supplied (LED LD3
remains OFF).
Also, do you mind providing some details on your hardware configuration? How are you accessing the pins in the Type-C interface, and how are you connecting which pins of that interface to the MCU?
Hope this helps
2019-11-15 01:34 PM
I'm looking into using the STM32G431CBT6 for a usb device which might need more than 500mA (it's a _really_ bright keyboard).
If possible I'd like to avoid adding a battery to power the MCU up. Also flashing via DFU is a must because nobody has a STLink programmer flying around or knows how to use it.
I've build a breakout PCB around my understanding of the documentation with a USB-C port:
Now when I populate the resistors R1 and R2 in above schematic the breakout board is flashable via DFU. Everything works like I want, however I suspect that populating external Rd resistors will prevent the MCU from negotiating more power (say, 1.5A).
So I'm wondering if I can basically achieve flashing via DFU without populating the two external resistors, using only the internal resistors on the MCU.
And if I have to populate the external resistors, can I still negotiate PD up to a high profile?
I guess being more specific in my original question would have helped here.
2019-11-15 01:55 PM
Just FYI: using a Type-C connector, you can draw up to 3A of current if your source can provide it, even without USB Power Delivery. The USB Type-C spec requires this, and describes it in detail (with references and examples) starting in section 4.6 Power.
2019-11-16 09:35 AM
Have you researched into dead battery mode of USB-C PD? The entire purpose of this functionality is to present the Rd pull-downs so that the source provides that base +5V needed to power your core and PD controller. I think this might be what you're describing.
You do not need to add your own external resistors, as the STM32G431 presents Rd even while the MCU is powered off. It requires 2 additional pins, each one is simply shorted to its respective CC line.
Check this App Note from TI for thorough high-level discussion: