USB circuit design for STM32 - Page 1
Forum section: electronics / projects

author: bodzio_stawski
author_rank: Regular Contributor
timestamp: February 04, 2021, 08:57:52 pm
content: Hello!I would like to design a simple, but sufficient circuit for connecting with stm32 (especially STM32F103C8T6) via USB and providing the ability to program directly via USB using the bootloader. And I discovered in the datasheet of the mcu that:"To be compliant with the USB 2.0 full-speed electrical specification, the USBDP (D+) pin should be pulled up with a 1.5 kΩ resistor to a 3.0-to-3.6 V voltage range")". And until now, I thought it should look like this:And I have doubts about it. I see this pull-up resistor very often on other diagrams and it should come from the choice for USB Full Speed (or pull-down resistor for the Low Speed mode). but is it good for the calculation process that the pull-up would be connected to 3.3V permanently? And then, how to connect correctly the ID and Shield pins?PS: The mosfet is used by me to protect against reverse polarity.

author: tszaboo
author_rank: Super Contributor
timestamp: February 04, 2021, 09:19:50 pm
content: Just delete the whole thing you already made, RTFM and start again.https://www.st.com/resource/en/application_note/dm00296349-usb-hardware-and-pcb-guidelines-using-stm32-mcus-stmicroelectronics.pdfYou dont need the 22 Ohm resistors.You dont need the FET, nobody can force the USB port backwards in there. What are you protecting against. Negative USB 5V?You probably dont even need the 1.5K if you are bus powered.Yes, connect shield and GND together. Anybody telling you otherwise never had to pass any EMC requirements. And then there is maybe 1 in 1000 of those suggestions (to not to connect) that actually know what they are doing, and talking about some very special niche application.Sorry for being rude, but I'm just so sick and tired of people blindly copying each other's broken electronics schematics.

author: pigrew
author_rank: Frequent Contributor
timestamp: February 04, 2021, 10:02:17 pm
content: Change the 22 ohm to 0-ohm, and it should work.(ADDED: See ST's AN4879's FAQ which states "On the internal USB PHYs, the matching output impedance is already embedded in the pad transceiverand is in line with the USB specification. No external resistors are needed.". Adding extra resistance would cause a mismatch.)The STM32F103 does not have a USB bootloader. Its bootloader only supports UART (or you can flash with JTAG).In a "real" product, I'd add ESD protection on BUS, D+, and D-, but that's not completely required for personal boards.You're not going to care about low speed USB, so no need to ever have a D- pull up.If you are using self-powered mode (and not bus powered), you need a way to sense BUS via a voltage divider on a digital pin (or have the pull-up only enabled when Vbus is connected).I'm attaching the STM32F103 dev board's schematic, but as already noted, probably just short the shield and ground. (side note: I measured a bunch of my USB cables recently, and most (as in >50%) of them don't have a continuous shield between cable ends).Quote from: NANDBlog on February 04, 2021, 09:19:50 pmSTM32F103 does not have an internal pull-up, so an external one is required. (Most other STM32 have one internal).

author: eliocor
author_rank: Unknown
timestamp: February 05, 2021, 04:30:22 am
content: for a working USB solution, take a look at the Maple Mini schematics:https://github.com/leaflabs/maplemini/blob/master/maplemini.pdffor the sources of a bootloader for the STM32F103, see:https://github.com/rogerclarkmelbourne/STM32duino-bootloader