PCB Review: RP2040 Breakout with Variable Use USB - Page 1
Forum section: electronics / beginners

author: jcdickinson
author_rank: Newbie
timestamp: January 06, 2025, 08:13:18 pm
content: Firstly, thank you for taking the time to review my PCB.I have already made a few PCBs using MCU breakout boards, and have decided the time has come to learn how to use the MCU directly. This RP2040 breakout board is really just that, with a small feature that's relevant to my next project: dual-purpose USB-C. I have tried to build the board as defensively as possible, trying to imagine how hosts could be reasonably out of spec: this may someday be submitted for FCC certification.This will also be my first stencil + paste + hot plate job (somewhat unavoidable with the QFN components).Starting with the USB-C port with the single extra feature on the board:A host device/motherboard (breadboard for now) will have daughterboard-facing USB-C ports that have their CC pins tied to ground (preventing real USB enumeration). This R7 and R8 format a voltage divider to determine whether a real USB host is connected (reboot into DFU) or whether the motherboard is connected (use D+/D- for UART).Power supply:Here I am using the TI LMR10510YMF for converting 5v to 3v3 logic level. I opted for a switching power supply because each daugtherboard wil have its own power supply, and could host watt-hungry components, so efficiency is pretty important. Pretty-much a 1:1 copy of the typical application.No schottky diode between VBUS and the power supply, as there will already be one on the motherboard, and USB-C prevents reverse polarity.RP2040, Flash, Crystal:Pretty-much a direct copy of the typical application, optional components included.Files:I have attached PDFs for convenience, but the source is also available:https://codeberg.org/jcdickinson/hexkbd/src/branch/main/schematics_new/hexkbd

author: ataradov
author_rank: Super Contributor
timestamp: January 06, 2025, 09:47:53 pm
content: You should not connect SBUx to the ground, leave them floating.Also, your detection scheme will not work all the time. You need to sample both CCx pins, since depending on the orientation only one of them would be high. Also, you may not get enough voltage after the divider. Why even have the divider? Just connect CCx directly to the I/O pins.

author: jcdickinson
author_rank: Newbie
timestamp: January 07, 2025, 02:05:59 am
content: Thank you so much. I failed to mention that I have selected one of the ADC pins, so I can emulate any arbitrary logic level.I am super concerned about some out-of-spec USB device blowing up the RP2040 if I do that, and I would still need a divider to make sure that the measurement doesn't affect the regular 5.1k negotiation? I really only want to use a single GPIO pin here. With your feedback in mind I approached the problem again with more research. I have also included the host-side components in my schematic, so that I can account for them. I have split the 5.1k resistors each into a voltage divider, and then use another voltage divider between them (to mitigate affecting the resistance required for regular USB/DFU).I have included the values that the ADC will see for a USB host that uses 5V on the CC line, but 3.3V also checks out (it bottoms out at about 300mV).

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2025, 02:18:41 am
content: Your parallel resistors will affect things way more than ADC or I/O ever could. If you are worried about out of spec devices, then put TVS diodes on CCx lines like you did for D+/D-. 100 kOhm resistors are much better for this if you really want just one channel.The DFP (host) side does not use 5.1 k Ohm pull-up resistors, the values depend on the voltage so that final levels are much less than 3.3 V regardless of the actual supply on the pull-up side.I also don't understand 100 kOhm on the Motherboard side.

author: jcdickinson
author_rank: Newbie
timestamp: January 07, 2025, 02:48:19 am
content: Quote from: ataradov on January 07, 2025, 02:18:41 amThe motherboard will have dedicated ports for daughter devices (and a single regular USB port). The resistor is just there to make sure that USB never works on those ports, that CC is in a defined state, and I don't want it attempting a USB handshake with a UART. So is this what you are suggesting?

author: Buriedcode
author_rank: Super Contributor
timestamp: January 07, 2025, 02:53:53 am
content: Your power supply - look at R18

author: ataradov
author_rank: Super Contributor
timestamp: January 07, 2025, 03:32:53 am
content: Quote from: jcdickinson on January 07, 2025, 02:48:19 amuse two 100 kOhm resistors from each of the CCx pins. Then hard 0 would mean no USB connection and any non-zero value would be a valid USB host.It is still sketchy, but if this is what you need to do, then do it. Ideally you need to use two different pins.Another idea to consider is a pair of diodes and a single I/O pin on the other side.

author: jcdickinson
author_rank: Newbie
timestamp: January 07, 2025, 05:48:46 am
content: Quote from: Buriedcode on January 07, 2025, 02:53:53 amWhoops. Only figured that out after making my intent more clear on the schematic. Good catch.Quote from: ataradov on January 07, 2025, 03:32:53 amI'll have a go at this tomorrow, my main concern is that there are only 4ADCs on the RP2040. 25% of them is a steep cost to pay, especially given that I don't care about orientation. I'm not attached to my ideas in any way, so if you can think of any other solutions please do share.

author: ataradov
author_rank: Super Contributor
timestamp: January 08, 2025, 12:29:03 am
content: Quote from: jcdickinson on January 07, 2025, 05:48:46 amOne other solution is a dual comparator and two digital pins. You can also try to combine comparator outputs into a single signal.

author: jcdickinson
author_rank: Newbie
timestamp: January 08, 2025, 06:15:41 am
content: Quote from: ataradov on January 08, 2025, 12:29:03 amI went with this advice, it's a lot more complicated but "sketchy" got me worried. Edit, whoops got the voltage divider the wrong way round.

author: ataradov
author_rank: Super Contributor
timestamp: January 08, 2025, 02:49:17 pm
content: i don't think combining comparators outputs like this will work. For 3.3 V supply Rp values may be 36 kOhm, 12 kOhm or 4.7 kOhm depending on the current supply capabilities.. This results in possible voltages of 0.4 V, 1 V or 1.7 V. So you need to compare with 0.3 V or so. And if either line is higher, then there is a valid host.But only one line will be high, so if you connect open drain outputs directly, then it will always be 0 V, since one of the lines is always 0 V.

author: jcdickinson
author_rank: Newbie
timestamp: January 15, 2025, 03:08:44 am
content: Thanks again, I've been slammed with work so I've only gotten back to this now. I also upped the vref to 0.3V as you suggested. I was being silly attempting to save a GPIO now that it's logic-level input. Each is on a different pin, as you were suggesting from the startEdit: wrong resistor values

author: ataradov
author_rank: Super Contributor
timestamp: January 15, 2025, 04:05:12 am
content: Yeah, this looks fine.