2026-03-18 2:16 AM - last edited on 2026-03-18 6:56 AM by Gyessine
Hello everyone.
I am running into a USB Host <--> Device connectivity issue.
I have 2 STM32L496 MCUs, one as Host and other as Device.
I cannot get the CDC connectivity to work for some reason. The connections are as follows:
D+ <> D+, D- <>D-, GND<>GND.
I have VBUS, SOF and NOE disabled.
CubeMX forces to set Drive_VBUS as well over a GPIO, however, I am not using that in my circuit. Even though it is a recommendation in USB connectivity in AN4879, I believe it is possible for a simple connectivity without it as well. Would this be a wrong assumption (and hence the culprit)?
As a connection stability, I tested both MCUs individually as Devices, connecting to my PC and it sent data over USB just fine.
The attached code has NucleoL496 as the host.
Would appreciate your support.
Solved! Go to Solution.
2026-03-19 3:11 AM
Hello @osamashah15
I reviewed your host project .ioc file and found out that you disabled VBUS pin
To begin, enable the VBUS pin, as it is mandatory for host functionality.
Next, I recommend that you test the CDC host project functionality independently. Perform the following procedure:
-Configure the device board to send the "hello world" message continuously.
-Configure the host board to receive the message and store it in a buffer allocated in a known memory region.
-Flash both codes and connect the host board to the device board using a micro-B to micro-B USB cable.
-In a debug session, track whether the host board receives the messages sent from the device board
You can review this article. It may help you.
BR
Gyessine
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.
2026-03-19 3:11 AM
Hello @osamashah15
I reviewed your host project .ioc file and found out that you disabled VBUS pin
To begin, enable the VBUS pin, as it is mandatory for host functionality.
Next, I recommend that you test the CDC host project functionality independently. Perform the following procedure:
-Configure the device board to send the "hello world" message continuously.
-Configure the host board to receive the message and store it in a buffer allocated in a known memory region.
-Flash both codes and connect the host board to the device board using a micro-B to micro-B USB cable.
-In a debug session, track whether the host board receives the messages sent from the device board
You can review this article. It may help you.
BR
Gyessine
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.
2026-03-19 4:47 AM
@osamashah15 wrote:I tested both MCUs individually as Devices
But did you test your Host against a known-good Device?
2026-04-09 9:46 PM
I figured out the problem was not really with the hardware but a small but very relevant oversight from my side. Ever since the CubeMX update, my default 12 MHz input frequency of the crystal oscillator (HSE) was likely automatically reset to 8 MHz and therefore, I was having timing issues - the 48 MHz required for USB was set incorrectly on my STM32L4 MCU.
My prior codes testing for device were with the computer as a host, and I believe the timing issues are not as apparent with that.
My Nucleo board was working fine with USB and since the Nucleo does not require the HSE, but it uses MSI, it wasn't problematic.
Interestingly, VBUS sensing is not a requirement for the code to work, especially since the device is bus-powred. But still, for the next iteration, I will follow the ST recommended circuit with STMPS2141 power switch as overcurrent notifier.
A small but critical oversight on my part. Apologies and thank you for the support!
Kind Regards,
Osama