cancel
Showing results for 
Search instead for 
Did you mean: 

How to create basic USBPD sink application with STM32G431KB?

ardnew
Associate III

I purchased a NUCLEO-G431KB to begin and test firmware development of my project, using the latest STM32CubeIDE with the STM32Cube_FW_G4_V1.1.0 library BSP.

Following several USBPD library examples of a sink application -- and some considerable configuration to FreeRTOS and the initial STM32Cube-generated code -- I am able to build the firmware, flash the target, and debug via ST-Link running on the little NUCLEO device. 

I can verify the USBPD middleware thread and the TRACER_EMB utility thread are being created by FreeRTOS. But the main USBPD process that listens for USB Type-C cable attach/detach seems to hang and never return (and it never calls any of the installed callback functions). This function is part of the CAD module I believe and is named USBPD_CAD_Process(). 

Unfortunately this function is implemented in the library core USBPDCORE_PD3_FULL_CM4_wc32.a (binary distribution), so I don't have any visibility into why it is hanging or not calling my callback functions. And I can't find any good documentation on troubleshooting this area of USBPD library either.

Also a side note -- I'm not real certain how to actually use the TRACER_EMB utility, and the STM32CubeMon-UCPD application does not detect any boards present when I have the target running.

--

EDIT:

My hardware setup is as follows. Equipment:

  1. NUCLEO-G431KB ( https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/stm32-mcu-mpu-eval-tools/stm32-nucleo-boards/nucleo-g431kb.html )
  2. USB 3.1/3.2 Type-C female receptacle breakout ( https://www.saikosystems.com/web/p-86-usb-type-c-female-receptacle-breakout-board-v20.aspx )
  3. Apple 87W USB-C Power Adapter ( https://www.apple.com/shop/product/MNF82LL/A/87w-usb-c-power-adapter )

Configuration:

  • Both (1) and (2) are placed on a breadboard. 
  • Jumper wires connecting all VBUS pins of (2) are connected to the open power rail on the breadboard. 
  • Jumper wires connecting all GROUND pins of (2) are connected to the open ground rail on the breadboard. 
  • Jumper wire connecting pin CC1 of (2) is connected to the UCPD_CC1 pin of (1).
  • Jumper wire connecting pin CC2 of (2) is connected to the UCPD_CC2 pin of (1).

With a digital multimeter attached to the open power and ground rails on the breadboard, I can verify that 5 V (default power profile per USB spec) is present when both the NUCLEO (1) is running my USBPD firmware, and the power adapter is plugged into the Type-C receptacle (2). 

If I disconnect and reconnect the power adapter to (2) while (1) is NOT running my USBPD firmware, the 5 V supply is NOT present again until the NUCLEO (1) target resets and begins running the firmware again. Therefore, I am fairly certain the USBPD library is functioning correctly to some extent, it just doesn't seem to be communicating with the main application.

11 REPLIES 11

Yup, that's what I did to resolve it, everything seems stable now.

I have a new problem that I think is unrelated to this topic, so I will post a new question and refer here for traceability. Thanks!

Hello @ardnew​ ,

the Application Note "How to create a simple USBPD sink application with STM32CubeMX" has been published : AN5418