cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H563ZI: implement USB CDC communication using ThreadX & USBX middleware

Pranathi
Visitor

Hello STM32 community!

I'm relatively new to the embedded field and have been diving into communication protocols through small projects. Currently, I'm working on implementing USB CDC on an STM32H563ZI, and I've been facing challenges for the past two weeks.

I've extensively searched the internet and followed various tutorials, but unfortunately, none of them seem to work.
One of the tutorial(from STM community) that I followed: https://www.youtube.com/watch?v=LdY2bieaPwk
I have added read functions to receive the data. I have made two separate semaphores for read and write functions. (It should work even without semaphores though). When I run the code, it's not taking any input from the terminal. 
Inside app_usbx_device.c file,

Pranathi_0-1732711652034.png

these two threads(for read and write) were created inside MX_USBX_Device_Init() function.

Pranathi_1-1732711797138.png

I am giving semaphore inside the while loop here...

Inside ux_device_cdc_acm.c file,

Pranathi_2-1732711995037.png

I am declaring variables...

Pranathi_3-1732712104510.png

I am defining the read and write functions like this...

Pranathi_4-1732712186113.png

it's not taking any input data

Pranathi_5-1732712534618.png

this is the heap and stack size I'm giving,

Pranathi_6-1732712629753.png

clock configuration,

Pranathi_7-1732712696129.png

to USB,

Pranathi_8-1732712729514.png

 

I would greatly appreciate it if anyone who can debug the mistake in this process and could guide the further steps to take.

Your insights and guidance would be invaluable to me. Thank you in advance for any assistance you can provide!

Please find the attached, project folder for further info.

1 REPLY 1
Lukasz Nowak
Associate III

The easiest way is to open an existing example. Here is probably the simplest one - it copies data from a hardware uart to the usb cdc:

\STM32Cube\Repository\STM32Cube_FW_H5_V1.3.0\Projects\NUCLEO-H533RE\Applications\USBX\Ux_Device_CDC_ACM\USBX\App\app_usbx_device.c

Doing it from a blank CubeMx project is actually seriously non-trivial. There are multiple files and settings which need to be changed compared to the default USBX configuration (memory pool sizes, interrupt priorities etc.). None of it is documented properly anywhere.

I did it once, for a CDC device in a USBX standalone mode (without ThreadX) and it was a lot of work.

If you want to go through that, you would need to compare the entire source tree with the example project (Core and USBX directories) and pick out all the changes they made in the example. There will be dozens of them.