2025-04-28 8:02 PM
(Please see attached PDF for best formatting and screenshot images. Complete code of main.c and usbd_cdc_if.c are also attached as txt.)
Hi everyone,
This is my first post! Please excuse any mistakes I might make in my question :).
I am trying to use the USB_OTG_HS functionality in Full Speed (FS) Mode on a custom STM32H723ZGT6 microcontroller custom PCB. However, the USB is not detected by any computer — nothing appears when I plug it in (no device, no "unknown/unrecognized USB" error, no activity at all).
I am using ST-Link/V2 for programming/debugging.
I can get the LED in PA10 to blink with programmed interval (using a specific HAL_Delay() time), turn ON or turn OFF.
I would like to be able to communicate with my computer to change the duration of blinking based on user input. I have divided this into 4 steps.
Be able to blink LED without user input (just run the code and ensure everything is working). This is done and correct.
Get the device to transmit “Hello World” message to the host computer and I should receive this message on my host computer. → I am unable to do this. My host computer does not even see the microcontoller PCB when I plug it in (It doesn’t even give a “USB not recognized” error – it just “does nothing”).
Once steps 1 & 2 are working, I would like to give some command to the STM32H723ZGT6 microcontroller via terminal and then receive some response based on my input.
Once 3 is working, I would like to submit the duration for the blink via terminal to the microcontroller, which will adopt the blinking interval based on my user input.
Linux (Ubuntu 24.04.2)
Windows 10
Windows 11 (different computer)
(Both show no device detected when the microcontroller is plugged in.)
No external oscillator is installed. According to the data sheet (https://www.st.com/resource/en/datasheet/stm32h723ve.pdf, pages 50/257 and 231/257), the internal HSI48 clock should be sufficient for FS mode.
USB-C connector wired directly to PA11 (DM) and PA12 (DP).
No series resistors between DP/DN and the USB port.
Both DP and DN lines are protected with ESD protection diodes.
CC1 and CC2 are pulled down to GND with 5kΩ resistors (indicating a USB device, not a host).
PA10 is connected to an LED for testing.
PCB is already produced by JLCPCB so we need to stick to the current schematic/layout if possible.
See attached PDF for schematic.
PA10: LED_Out pin (SET = ON; RESET=OFF)
PA11: USB-OTG_HS_DM
PA12: USB-OTG_HS_DP
PA13: DEBUG_JTMS-SWDIO
PA14: DEBUG_JTCK-SWCLK
All others are default.
I clicked “Resolve Clock Issues” and now 48MHz to USB using HSI (even in the PLL Source Mux).
No errors are reported by the software.
See PDF for screenshots of my clock settings.
RCC > High Speed Clock (HSE) > Disable
RCC > Low Speed Clock (LSE) > Disable
Connectivity > USB_OTG_HS > External Phy > Disable
Connectivity > USB_OTG_HS > Internal FS Phy > Device_Only
Connectivity > USB_OTG_HS > Active_SOF > Disable
Connectivity > USB_OTG_HS > Activate_VBUS > Disable [The reason this is disabled is because I did not connect anything to PA09, so I fear if I turned this on then the USB would never be on since it would never measure anything on VBUS (PA09).]
Middleware and Software Packs > USB_DEVICE > Class For HS IP > Communication Device Class (Virtual Port Com)
Trace and Debug > Debug > Serial Wire [I am using STLink/V2.]
Please see the full code attached as “main.c” and “usbd_cdc_if.c” files
Specific changes that I made are:
including usbd_cdc_if.h file in line 25:
#include "usbd_cdc_if.h"
making a USB transfer buffer with known size to transferring in lines 46-47:
uint8_t usbTxBuf[USB_BUFLEN]; /* We need a measure of the length of the Tx buffer*/
uint16_t usbTxBufLen;
Printing the transfer details line 118-121:
usbTxBufLen = snprintf((char *) usbTxBuf, USB_BUFLEN, "%lu\r\n", HAL_GetTick()); /* */
CDC_Transmit_HS(usbTxBuf, usbTxBufLen);
HAL_Delay(500); /* Send the text every 500 ms*/
Specified the baud rate, number of bits and some details in lines 98-103:
USBD_CDC_LineCodingTypeDef LineCoding = {
115200, /* baud rate */
0x00, /* stop bits - 1 */
0x00, /* parity - none */
0x08 /* nb. of bits 8 */
};
CDC_SET_LINE CODING in lines 230-235:
case CDC_SET_LINE_CODING:
LineCoding.bitrate = (uint32_t) (pbuf[0] | (pbuf[1] << 8) | (pbuf[2] << 16) | (pbuf[3] << 24));
LineCoding.format = pbuf[4];
LineCoding.paritytype = pbuf[5];
LineCoding.datatype = pbuf[6];
break;
CDC_GET_LINE_CODING in lines 237-245
case CDC_GET_LINE_CODING:
pbuf[0] = (uint8_t) (LineCoding.bitrate);
pbuf[1] = (uint8_t) (LineCoding.bitrate >> 8);
pbuf[2] = (uint8_t) (LineCoding.bitrate >> 16);
pbuf[3] = (uint8_t) (LineCoding.bitrate >> 24);
pbuf[4] = LineCoding.format;
pbuf[5] = LineCoding.paritytype;
pbuf[6] = LineCoding.datatype;
break;