2024-11-27 05:17 AM - last edited on 2024-11-27 06:55 AM by Andrew Neil
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,
these two threads(for read and write) were created inside MX_USBX_Device_Init() function.
I am giving semaphore inside the while loop here...
Inside ux_device_cdc_acm.c file,
I am declaring variables...
I am defining the read and write functions like this...
it's not taking any input data
this is the heap and stack size I'm giving,
clock configuration,
to USB,
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.
2024-11-27 06:39 AM
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.