cancel
Showing results for 
Search instead for 
Did you mean: 

How to set and use two usb_pd_port in stm32g4 ?

Gbang
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

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);
}

View solution in original post

8 REPLIES 8
Yohann M.
ST Employee

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 II

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
Associate III

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

Gbang
Associate III

Hello, I have another board nucleo-g431rb, and I use the demo project "USB-PD_Provider_1port" from STM32G474E-EVAL, and set the marco to STM32G431xx. and then connect ucpd_cc1 and ucpd_cc2 in a typec board, which connect to a sink device. However, g431rb don't send any pd message?

Is the project error or the hardware error? thanks.

in the projects we deliver, the internal trace is enabled. It is possible to see if you have communication between 2 boards.

Trace is done through USART pins connected to ST link. You should use Cubemonitor-UCPD and use the functionality described in the following image:0690X00000ApRTRQA3.png

Gbang
Associate III

Hello, I used logic analyzer to moniter ucpd pin(UCPD_CC1, UCPD_CC2), but got nothing. I'm not sure it's the project error or the connect error.

btw, I debug the project and "MX_USBPD_Init" and other function in the "main" function all excute right.

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);
}

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\