cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO STM32U575ZI-Q USB Device CDC Problem

IlariaCrupi
Associate II

Hello, 

I am trying to use the STMicroelectronics classic USB device middleware to implement a CDC class in the STM32U575 microcontroller. I am currently working on NUCLEO-u575ZI-Q. At first, I followed the tutorial on "How to use STMicroelectronics classic USB device middleware with new STM32 families" by @B.Montanari  (https://community.st.com/t5/stm32-mcus/how-to-use-stmicroelectronics-classic-usb-device-middleware-with/ta-p/599274) but I encountered the same errors pointed out in the tutorial comments by other users with STM32U5. Then, I created a new project and used the "STM32U5 classic core Middleware Firmware Package" repository (https://github.com/STMicroelectronics/stm32u5-classic-coremw-apps) without any success. 

In the end, I created another project using the USB Device CDC Standalone Library for STM32U5 (https://github.com/STMicroelectronics/stm32u5-classic-coremw-apps/tree/main/Projects/NUCLEO-U575ZI-Q/Applications/USB_Device/CDC_Standalone/USB_Device) and the classic USB Device Middlewares (https://github.com/STMicroelectronics/stm32_mw_usb_device/tree/2022e75b01a499b17acd17d28691b1ed5bbef2dc). In this case, I was able to successfully compile my project without any error but I can't see the VCOM generation on my PC. When entering Debug mode I see that the MX_USB_Device_Init() does not return any error but still, I can't see the VCOM.

In the .ioc file, the USB_OTG_FS is set in "Device_Only" mode, the VBUS is activated and the USB OTG FS global interrupt is enabled. In the RCC, the HSE is set as BYPASS Clock Source, and the LSE is set as Crystal/Ceramic Resonator. In the Clock Configuration settings, I checked that CLK48 Clock Mux returns 48 MHz to USB. In the images below you can see the aforementioned .ioc settings, while the .rar is the last project described.
I would like to know if:
- Is there an available project using the CDC transmit successfully working on the stm32u5 microcontroller? (I couldn't find any)
- Is there an alternative option to implement the CDC class without using threadX and USBX for stm32u5?
- Can it be that the problem is related to Windows 11 drivers?


Thanks

Best regards

IlariaCrupi_0-1709029783341.png

IlariaCrupi_1-1709029800660.png

IlariaCrupi_2-1709029817595.png

IlariaCrupi_4-1709029965795.png

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
IlariaCrupi
Associate II

Hi everyone! 

I stumbled upon this GitHub repo (https://github.com/BlaineMoon30/stm32u575_nucleo_mw_usb_device_cdc/tree/master) containing a working project that implements USB-CDC transmission with NUCLEO-u575ZI-Q. The project features a data loopback Tx and Rx example, but the CDC_Transmit_FS() function can be seamlessly integrated into the main() code. In the latter case, I suggest including a check for USB initialization status before starting data transmission; not doing so may result in the USB device not being recognized by the PC. 

View solution in original post

6 REPLIES 6
FBL
ST Employee

Hello @IlariaCrupi 

Some modifications should be done to the example.

  PeriphClkInitStruct.IclkClockSelection = RCC_CLK48CLKSOURCE_HSI48;

I confirm an issue on myside, and it is linked to the implementation. This issue is reported to dedicated team.

Internal ticket number: 174743 (This is an internal tracking number and is not accessible or usable by customers).

Otherwise, could you check the usart pins being used? PG9 and PA10?

FBL_0-1709052054601.png

 

I hope this helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi!

Thank you for your quick answer. However, I have already done the modification you suggested, and it still doesn't work. 

As regards your question, on the NUCLEO board I am using the USB-C connector (CN15) and not the STLINK-V3 to implement the USB CDC transmission. 

In the meantime, working on the same project I previously shared with you, I noticed that in the MX_USB_Device_Init() the dev_speed variable of the &hUsbDeviceFS handle is set as USBD_SPEED_HIGH instead of USBD_SPEED_FULL. 

Furthermore, by using an oscilloscope I saw that both the DP and DN lines of the USB connector are silent (both at GND level). In the attached image (Setup USB.jpg) you can see my setup. 

Do you have any clue about that? 

Thanks again. 

IlariaCrupi_0-1709053704972.png

 

You can use my project:

https://github.com/tjaekel/NUCLEO-U5A5JZ-Q_QSPI 

Just toggle the macros to:

XXX_STM32U5A5xx
STM32U575xx
ATT: In C-compiler AND in Assembler macro settings (via project -> properties).

It works on U5A5 and U575 (they differ on USB HS vs. FS PHY in MUC).

VCP UART (CDC) works fine for me (on both MCUs).

But it is not "classical" - it is based on AZURE RTOS and USB stack.

FBL
ST Employee

Hello @IlariaCrupi 

 

If I understand correctly now the issue, your code now goes to Error Handler when trying to run line "((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();" which is in USB_CDC_Init() function of usbd_cdc.c file. 

You need to initialize your configuration correctly (dev_speed  ...). I suggest you check through usbd_cdc.h

  1. data IN and OUT,
  2. command packet size,
  3. the device string descriptors,
  4. size of temporary buffer ...
    I hope this will help you, Otherwise, I suggest if your first questions were answered please close this thread and open new ones if still having issue.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi, 

I found out that the error at the line "((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();" was due to the fact that the TIM Base generation in interrupt mode was called twice (both in the CDC_Itf_Init() and in the TIM_Config() functions in usbd_cdc_if.c file). However, my code still stops working and goes to HAL_UART_ErrorCallback(). 

As regards the configurations, I changed the defines and the descriptor settings as explained in the above-mentioned tutorial "How to use STMicroelectronics classic USB device middleware with new STM32 families" but I don't know if there's something else that needs to be configured for the VCOM CDC class to work properly with STM32U5 and I couldn't find anything online. Do you know if there's any specific configuration for STM32U5? 

Attached you can find the last version of the project. 


Thanks. 

IlariaCrupi
Associate II

Hi everyone! 

I stumbled upon this GitHub repo (https://github.com/BlaineMoon30/stm32u575_nucleo_mw_usb_device_cdc/tree/master) containing a working project that implements USB-CDC transmission with NUCLEO-u575ZI-Q. The project features a data loopback Tx and Rx example, but the CDC_Transmit_FS() function can be seamlessly integrated into the main() code. In the latter case, I suggest including a check for USB initialization status before starting data transmission; not doing so may result in the USB device not being recognized by the PC.