cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behavior on STM32F4 USB

Mark Greally
Associate II
Posted on January 11, 2018 at 12:42

Hi.

I have developed some USB HID code using STM cube and seems to be working ok, in that it is seen in the device manager. However when going through the workings of this code it seems a little odd.

When the current mode is set to device mode GUSBCFG -> bit30, this sets GINTSTS bits 12 &13, reset and enumeration.

Its only later on when the SDIS bit is set in the DCTL register that the device starts communication with the host. Surely the reset and enumeration would not be done until this line is pulled high as the host sees nothing connected.

Why is the core setting enumeration is complete before it is even connected??

Thanks.

2 REPLIES 2
Ben K
Senior III
Posted on January 11, 2018 at 17:56

The STM32 HAL libraries support only a fixed host or device role USB implementation, OTG functionality is not provided as part of their USB stack. And in fact as long as the application doesn't require dual-role support, this works just fine, there is no point in enabling OTG if the software won't handle one of the roles.

Posted on January 15, 2018 at 12:28

OTG is not enabled. Device mode is selected by setting bit 30 in 

GUSBCFG. As far as the host (pc) is concerned there is nothing connected and there is no voltage on D+. It is not until VBUSBSEN is enabled in GCCFG and the pull up resistor is enabled and then there is a voltage present on this line.

According to the reference manual:

USBRST: USB reset The core sets this bit to indicate that a reset is detected on the USB.

This suggests that the host(pc) has sent a reset signal to the device. I have viewed on the oscilloscope that there is no signal being sent. It is not until this line goes high that the host then begins sending its data to the device.

USBRST should not be set until the host has actually sent its reset signal but is getting set when device mode is selected. Why is this the case or is it perhaps not functioning correctly due to some other config setting?

Thanks.