cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeMX 5.3.0 USB mouse code not working

Barry Richards
Associate II

0690X000009joLoQAI.png0690X000009joLjQAI.pngI have custom board with a STM32F446 processor I am trying to test

using cubeMX (v5.3.0) generated code for a USB human interface (mouse).

Unfortunately, I have had very sporadic results with getting the computer

to recognize it as a USB mouse. The computer shows it connecting, then

disconnecting, rarely but sometimes recognizing it as a mouse only to disconnect a minute later. Micro is running at 168Mhz. with heap size set to 1000.

 I have replaced the USB connector on the board, the cpu and the crystal. Confirmed the same USB cable I am testing with works perfectly with other devices.

Could someone confirm the code generated by the cubeMX as a OTG USB device, human interface still produces working code for a USB mouse?

5 REPLIES 5
TDK
Guru

Is your chip running fine otherwise? Where in your code do things fail or get hung up?

If you feel a post has answered your question, please click "Accept as Solution".
Barry Richards
Associate II

Chip runs fine and does not hang. In debug, the last line that executes is MX_USB_DEVICE_Init() in main(). If I put something the while(1), it will run.

Barry Richards
Associate II

In case someone comes across this...

The cubeMX (v5.3.0) generated code for a USB human interface (mouse) works fine.

My problem was caused by the the long 3.3V rail going around the perimeter of the board. I replaced C12 with a 47uF capacitor and the device remained connected and working for over 4 hours before I disconnected it.

Only odd thing is the MCU did not hang and would execute any other code without issue even though the USB connection failed. Maybe the part of the MCU which handles the USB is powered by pin 48.

STM32F4 has a brownout detector, Clock security system. Maybe, worth to enable that to ensure correct operation.

-- pa

I did not know that and will definitely look into it. Might have saved me a lot of trouble.

Thank you.