cancel
Showing results for 
Search instead for 
Did you mean: 

USB CDC isn't working on STM32L476

NIX AIR SOLUTIONS
Associate II

We developed a PCB that have an STM32L476. In the hardware configuration I configured the USB communcation as a Device_only and virtual com. 

For the hardware connection, I have the USB D+ , D- and ground connected and verified. 

when connecting the PCB to PC there is no new device appearing and the stm isn't appearing to the PC. 

Can you help what might be the reason and how to debug it. Most of the tutorial show how to do the configuration and once they connect to the PC the STM appear. 

Note: when the STM32 is connected to the st-link and debugging, if I plug the usb cable to the STM32, the debug stopped and give connection error.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @NIX AIR SOLUTIONS , 

Based on the USB specification, a USB device must use VBUS sensing detection. When host connection is detected by the device, device connects pull-up resistor either to D+ or to D- data signal, allowing host to detect device presence on the bus.

1. Solution with a dedicated VBUS pin (PA9)

In order to reduce the voltage on PA9 below 4V, the usage of a voltage divider is recommended, so that AMR cannot be violated.

Recommended resistor bridge is "vbus-- R1=4.7k -- R2=10k -- gnd" and then VBUS detection (PA9) can be taken between R1 and R2.

2. Solution without usage of a dedicated VBUS pin
Any 5V tolerant pin with external interrupt functionality can be used with an external resistor divider, to fulfill AMR conditions. In this case, recommended values are 2x100 kOhms .

However the disadvantage of this solution is that the software handling of VBUS presence event needs to be implemented by the customer, since this is not managed within our STM32 USB library for the time being.

It is recommended to use a physical pull-up resistor.

For more information about how VBUS sensing shall be managed, I recommend you to take a look to Management of VBUS sensing for USB device design FAQ.

 

Thank you.

Kaouthar

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.

View solution in original post

6 REPLIES 6

> Note: when the STM32 is connected to the st-link and debugging, if I plug the usb cable to the STM32, the debug stopped and give connection error.

That sounds like some sort of hardware issue.

Observe VDD using oscilloscope during plugging in the USB cable.

How is VBUS from USB connector connected?

JW

KDJEM.1
ST Employee

Hello @NIX AIR SOLUTIONS ,

Could you please check your PCB?

I think that section 3 Hardware guidelines for USB implementation in AN4879 can help you.

This section describes the hardware requirements for correct operation of the USB peripheral.

I hope this help you!

Kaouthar

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.

Thank you for the info I followed another document when I did the design of the PCB, I should've use this one.

As per this documentation, STM32L476 support the interface B: USB 2.0 OTG_FS, that is, USB 2.0 FS device/host/OTG controller with on-chip FS PHY

and it had an embedded pull-up resistor on USB-DP line.

NIXAIRSOLUTIONS_1-1701743282773.png

and the connection as per the documentation should be as the following: 

NIXAIRSOLUTIONS_2-1701743612382.png

In my case, the stm32 is self powered so I have no connection between the VBUS and the stm32 power. But I don't have the resistor bridge, VBUS isn't connected to anything. 

In section 3.1.1, for self powered applications, "It is recommended to implement a resistor bridge (refer to Section 2.6 for more details)". However, in section 2.6, "Based on the USB specification, a USB device must use VBUS sensing detection. When the device detects the host presence, it connects its pull-up resistor to either a D+ or D- data signal. This allows the host to detect the device presence on the bus.The device is self-powered. VBUS sensing is mandatory."

I do have a pin not used next to PIN PA9 (VBUS_OTG_FS_VBUS) which is the USB voltage sensing pin, what I'm thinking about is to weld this pin to the PA9, put it as an output to power the PA9. In this way, the pull-up resistors are always connected or I can manage to power it in the software when I need it. 

 

What do you think about it? I think it's impossible to connect the pull-up resistor from the software. 

I'll observe VDD. But now it's not failing when connecting the stm to the PC it might be a voltage problem when I was doing that. 

VBUS isn't connected and as per the document https://community.st.com/t5/user/viewprofilepage/user-id/2043 section 3.1.1 and 2.6 I think this is my fault :( 

Can you check my response to KDJEM.1? 

Thank you!

 

KDJEM.1
ST Employee

Hello @NIX AIR SOLUTIONS , 

Based on the USB specification, a USB device must use VBUS sensing detection. When host connection is detected by the device, device connects pull-up resistor either to D+ or to D- data signal, allowing host to detect device presence on the bus.

1. Solution with a dedicated VBUS pin (PA9)

In order to reduce the voltage on PA9 below 4V, the usage of a voltage divider is recommended, so that AMR cannot be violated.

Recommended resistor bridge is "vbus-- R1=4.7k -- R2=10k -- gnd" and then VBUS detection (PA9) can be taken between R1 and R2.

2. Solution without usage of a dedicated VBUS pin
Any 5V tolerant pin with external interrupt functionality can be used with an external resistor divider, to fulfill AMR conditions. In this case, recommended values are 2x100 kOhms .

However the disadvantage of this solution is that the software handling of VBUS presence event needs to be implemented by the customer, since this is not managed within our STM32 USB library for the time being.

It is recommended to use a physical pull-up resistor.

For more information about how VBUS sensing shall be managed, I recommend you to take a look to Management of VBUS sensing for USB device design FAQ.

 

Thank you.

Kaouthar

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.

KDJEM.1
ST Employee

Hello @NIX AIR SOLUTIONS ,

If you need any further clarification, please don't hesitate to ask. 

If your question has been answered, please close this topic by choosing Accept as Solution. This will help other users find that answer faster. 

Thank you for your contribution in STCommunity.

Kaouthar

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.