Skip to main content
Gbang
Associate II
October 10, 2019
Solved

How to set and use two usb_pd_port in stm32g4 ?

  • October 10, 2019
  • 8 replies
  • 2197 views

I bought B-G474E-DPOW1 and had one typec interface, which cc connect ucpd_dbcc pins. I need another typec interface to send pd message, could I use the ucpd_cc pins for this?

And I try to change the demo code "USB-PD_Consumer_1port", set USBPD_PORT_COUNT=2, while got error when pd init, error in USBPD_PE_Init.

 /* PE SET UP : Port 0 */
 CHECK_PE_FUNCTION_CALL(USBPD_PE_Init(USBPD_PORT_0, (USBPD_SettingsTypeDef *)&DPM_Settings[USBPD_PORT_0], &DPM_Params[USBPD_PORT_0], &dpmCallbacks));
#if USBPD_PORT_COUNT == 2

This topic has been closed for replies.
Best answer by Yohann M.

Hello, what is the voltages you see on CC lines? I suggest you also to refer on our User Manual UM2552 and check the source connection procedure described in Figure11:

0690X00000ApTjRQAV.png

And also remind that you can add your own traces, also described in the same document (3.6.4 TRACE system):

This USB-PD trace can be used by the end user for two purposes:
• Debug the USB-PD stack behavior (e.g. exchange of messages, notifications,
attachment events), Use CubeMonitor-UCPD (see documentation about how to
decode the trace)
• Put its own debug trace (see an example of how to add a trace in the code below)
void xxxxx_yyyy(uint8_t PortNum, …)
{
...
/* trace function exit */
USB-PD_TRACE_Add(USB-PD_TRACE_DEBUG, PortNum, 0, “EXIT function
xxxxx_yyyy�?, 24);
}

8 replies

Yohann M.
ST Employee
October 10, 2019

Hello,

STM32G4 has only one UCPD instance then it is not possible to set USBPD_PORT_COUNT to 2. If you want to use 2 instances, I advice you to switch on STM32G0. You could use CubeMX to regenerate another applications with 2 ports.

Regards

Yohann

JDUMA
Associate
October 10, 2019

Hello , can you precise the role of the second port (Sink, source or DRP ?) and power profiles you want to support , and if you need USB data too?

Some idea that should

  • use STM32G071GxUx as a companion chip to control 2 USB-C ports (G0 can control up to 2 UCPD)
  • Control the second port by running X-CUBE-USB-PD in STM32G4 (acting as a type-C port manager) to control an external TCPC such as FUSB307 or STUSB1602. BR.
Gbang
GbangAuthor
Associate II
October 10, 2019

hello, thank you, I need to use two port to achieve a usb pd message monitor between source and sink devices.

Nicolas P.
ST Employee
October 11, 2019

The G0 discovery board demonstration firwmare demonstrates this use case : spy messages between two devices. You can have a look at :

in the G0 firmware package : c:\Users\your_login\STM32Cube\Repository\STM32Cube_FW_G0_V1.3.0\Projects\STM32G071B-DISCO\Demonstrations\USBPD_Analyzer\