Alternative USB Discovery Circuit

What are you developing?
Post Reply
EntropyWizard
Posts: 4
Joined: Thu Nov 16, 2017 5:03 am

Alternative USB Discovery Circuit

Post by EntropyWizard » Wed Jan 03, 2018 10:09 pm

I've been working on my own little development board for the STM32F103C8T6 and other compatible LQFP-48 chips. I'm attempting to avoid using pins that are part of one of the periperal devices, which leaves basically PC13 and PB2-BOOT1 for on-board use. I've assigned PC13 to the status LED, and I'm working on using PB2 for the USB connect circuit.

The tricky part is that PB2 needs to be held low on reset in case BOOT0 is set to select the ROM serial bootloader, while the normal (maple-mini) reset circuit expects the reset signal line to be held high, and then pulled low to activate USB enumeration.

I've re-worked the circuit so that it behaves like the maple reset circuit, but with inverted signal logic (PB2 has a 3.3k pull-down elsewhere):
USB_Discover_2TRAN_Schematic_Main_v1.png
USB_Discover_2TRAN_Schematic_Main_v1.png (19.89 KiB) Viewed 259 times

Here is a simulation of the circuit in the Falstad online circuit simulator: http://tinyurl.com/y8eqtahv . The 3 switches from left to right are: 1) Option jumper - permanent 1.5k pullup vs PB2 control. 2) Switch port mode from High-Z input to push-pull output. 3) Push-pull port high vs low. The key voltage is the TP between the 22 and 15k resistors which represents the voltage on the USB D+ line.

I have built a prototype board with a variant of this circuit working with the inverted logic. I had to alter both the stm32duino boot loader and runtime to use PB2 and inverted logic, but it seems to work reliably. I wanted to post here for comments or ideas, are there any obvious problems I'm overlooking?

victor_pv
Posts: 1864
Joined: Mon Apr 27, 2015 12:12 pm

Re: Alternative USB Discovery Circuit

Post by victor_pv » Thu Jan 04, 2018 7:28 pm

Not sure if you are aware, but we discovered we could force re-enumeration without any external circuit, and we use that method with generic boards that lack the circuit.
I don't remember seeing anyone posting of a problem with that method, so you could give it a shot and may be able to skip all that circuit.
That's how we do the re-enumeration in boards like the bluepill, which seems to be used a lot, so the method seems to work well enough.

EntropyWizard
Posts: 4
Joined: Thu Nov 16, 2017 5:03 am

Re: Alternative USB Discovery Circuit

Post by EntropyWizard » Sat Jan 06, 2018 1:57 pm

Hey, thanks for the comment, yes, I've read some of the forums discussing reseting the USB by driving USB D+ low via the port peripheral itself (also looked at the code). It sounds like that is reliable for most people. I will have to test it a bit more, I was thinking I had problems requiring reset fiddling, but I may be miss-remembering. The board I'm designing is not as space limited as some, I do have room for a bit of extra stuff. So, I guess, one question is - what is the proper or ideal configuration?

One site on USB stated that the 1.5k pull-up is required to be removed from DP within 10 sec if the host (vbus) loses power. I assume that is what the first transistor in the maple mini circuit cleverly does. It also coincidentally allows the GPIO to be used for other subsystems without the 1.5k pull-up when USB is disconnected/unused. I guess this is not a huge issue though, since many boards have a permanent pull-up to 3.3V.

ag123
Posts: 854
Joined: Thu Jul 21, 2016 4:24 pm

Re: Alternative USB Discovery Circuit

Post by ag123 » Fri Jan 12, 2018 5:38 pm

i think maple mini (and clones) has something similar
https://github.com/leaflabs/maplemini/b ... lemini.pdf
i never quite examined it closely, but now i noted that there are 2 transistors which could be used to disable the D+ pull up to VCC (which interestingly is 3.3v). This seem to work by first pulling PB9 high, which based on the circuit 'disables' the pull up to VCC. my guess is then it would be easier to pull D+ and D= low (single ended zero) http://www.usbmadesimple.co.uk/ums_3.htm
which should prompt the host controller to recognise it as a usb-reset, thereby re-doing the usb enumeration

Post Reply