cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting USB Type-C Connections with FreeRTOS on Nucleo STM32H503RB

himani
Associate II

Hello everyone,

I’m working on a project with the STM32H503 microcontroller and need to implement USB Type-C connection detection using FreeRTOS. Specifically,

I have come across several examples that utilize Azure RTOS ThreadX environment with nucleo STM32H503 , but I have some question in my mind ,I'm using RTOS already with my application now I want to add USB support also so azure RTOS stack will not work with my FreeRTOS,  but I’m looking for guidance on how to implement this using FreeRTOS. 

  • Is it possible to manage USB Type-C detection with FreeRTOS?
  • If so, what would be the best approach to start?
  • Are there any libraries or resources recommend that can assist with USB Type-C implementation in a FreeRTOS environment?

Any insights or examples would be greatly appreciated!

Thank you!

5 REPLIES 5
XD
Associate III

Ive had a similar problem. 
Solved it by using an external USB-C PHY (TUSB320), configured it with the strapping pins to default to UPF for the USB-Bootloader. Then reconfigured it through I2C during runtime for whatever i needed. 

The PHY had an output pin that went low if a register was changed (ie if the USB connection state was changed).
I simply set a RTOS flag from the interrupt that notified the rest of the system that the USB-state had been changed.
Then the appropriate task could fetch the register content from the PHY to figure out what type of device was attached (DFP/UFP) and proceed from there.

 

Not sure if its the best approach but it has worked well for me!

himani
Associate II

Hey ,
thankyou for reply ,
just for the curiosity  why they directly jumped into direct auzre RTOS ?

Guenael Cadier
ST Employee

Hi @himani 

Maybe an alternative for you could be to use a STM32H562 or 563 or 573 (instead of STM32H503).
STM32H56x/57x embeds a UCPD peripheral able to manage USB Type-C/USB Power Delivery connections.

You could also find in STM32Cube H5 package available on st.com or Github, some applications running on STM32H573 Nucleo boards, illustrating use of this feature, either in a USB TypeC only context (no USB Power Delivery) or with support of USB Power Deliver protocol over USB Type C connections.


USB Data + USB Type-C only applications : here.

USB Power Delivery applications : here

Regards

NBALL
ST Employee

Hello

As only TypeC is required here, we can propose stusb1600 as TypeC controller.

It can be connected to stm32H7 thru I2C.
STUSB1600 can be 'DRP'.
If specific role is needed, I can propose some other parts.

Best regards,

MROUV.1
ST Employee

Hello Himani,

 

To implement USB Type-C connection detection using FreeRTOS with a STM32H5, you need :

  • USB-C PHY (CC lines)
  • VBUS management (VBUS line)
  • Some protections (ESD, OVP, OCP, …)
  • Associated software :smiling_face_with_smiling_eyes:

 

A basic USB-C PHY is not enough because missing ESD / Over Voltage Protection on CC lines.

 

ST proposition value is to integrate all needed parts.

 

They are two cases for USB-C Power Delivery with STM32:

  • STM32 without UCPD peripheral : STUSB (managed by I2C port) + external protections
  • STM32 with UCPD peripheral : TCPP series (connected to CC lines of STM32)
    • All protections are embeedded in TCPP + VBUS management because UCPD peripheral is a USB-PHY
    • Code generator is available on Cube-MX (Wiki)

 

Best regards,
Mathieu