Showing results for 
Search instead for 
Did you mean: 

Problem with USB OTG FS (Device)

Associate II

Hey everyone!

Some context:

We are developing a medical device using STM32H7ZIT6 MCU. We succesfully developed a working prototype, using UART connection protocol. 


Couple of consistency problems (i.e. the device works flawlessly at times, sometimes we get "USB driver cannot be recognized" error, sometimes UART Recieve functions do not work, the connection cannot be established in some PC's, sometimes inserting the device causes other pc peripherals such as mouse to run wild, etc). and the fact that UART protocol is old caused us to decide to switch to USB CDC protocol.


This is what happened to us afterwards:

1) We succesfully managed to run the code on STM32H7A3ZI-Q Nucleo board. 

2) On bread board, we decided to test it before going for PCB board. First we tried the following connection (this is taken directly from STM's website):


WhatsApp Image 2023-12-25 at 19.02.44.jpeg

When we put the pull-up resistor, the PC recognizes a USB device is inserted but we get "USB Device driver not recognized" error (testing the DP via ossiloscope, we saw some information sent). With external pull-up resistor like this, we see 3.3V on ossiloscope in DP pin.

When we try without external pull-up resistor (activating the internal pull-up resistors from the cubeIDE), the PC does not recognize USB port at all in device manager. With internal pull-up resistors activated, we see around 1V on ossilioscope in DP pin.

Note: We tested with an power supply to see if the circuit is drawing too much power, but it is only 0.025'ish amp, well within what the USB port or our DC-DC converter can handle.


2) We then decided to test the following schematics, which we found in some forum somewhere:

WhatsApp Image 2023-12-25 at 20.13.34.jpeg

However, because we lack certain integrated circuits and we consider ourselves smart engineers ("this part of the circuit isn't necessary anways") we tested it as follows:

WhatsApp Image 2023-12-25 at 20.20.32.jpeg


In this setup, the PC does not recognize the USB device at all. Mind that internal pull-up resistors are not activated in this setup (but even if we activate them, it doesn't work - we tried).


3) We then get the following idea: "If the development board is working, why don't we replicate the development board's schematic exactly? This is surefire way to make it work!". So we pulled up the schematics of the dev board:

WhatsApp Image 2023-12-25 at 20.11.35.jpeg

But again, because we are geniuses and a LED light is obviously not compulsory for the circuit to work, we decided to test the following only:

WhatsApp Image 2023-12-25 at 20.11.17 (1).jpeg


Again, in this setup, the USB is not recognized at all on device manager.


Some notes:

1) We tested 3 different ceramic external clock (8-16-24 Mhz). USB clock is always 48 Mhz on clock configuration.

2) We made sure MCU is working at all times. The problem is only in connection.

3) MX_USB_Device_Init() is called and exits succesfully (we made sure in debug).

4) It is possible that we are making some incredibly silly mistake. Something so small, so elementary that it is not described in any forums. I say this, because this is precisely what happened a lot of times in this project.


Pavel A.
Evangelist III

You wrote only about the USB connection, but is the clock good for USB? The on-board ST-Link of Nucleo usually provides its clock to the STM32 in 'single-ended' mode. On your scheme there's a different thing - external crystal.

Hopefully this medical device is not of a life-critical type...


Senior II

Use debugging tools to inspect the USB signals, such as a logic analyzer or oscilloscope. Check the signal integrity and voltage levels on the D+ and D- lines during device enumeration.