UART-USB Bridge - Page 1
Forum section: electronics / beginners

author: poflynn
author_rank: Newbie
timestamp: August 30, 2022, 11:20:34 am
content: Hi guys, first post so go easy!I'm developing a wireless (bluetooth) product that uses an NRF51 as it's MCU. The device is charged through a USB-C port. It also uses the USB D+ & D- pins during factory calibration & also if the device is returned for testing. The end-consumer never needs to interact with the device via USB as it's all handled with bluetooth.Currently we use a USB-UART bridge IC to bridge the USB comms to the chip during calibration & testing. However since this chip is only used during calibration (And mainly due to serious chip shortages in this area) I'm wondering if I can connect the TX and RX lines directly to USB D+ and D- and then use an external adapter at the factory and in our labs for testing that contains the USB-UART chip?The only problem I can see is if the device is connected to a laptop which then sends out USB data on D+ & D- at voltages that exceed what the chip can handle. The MCU can handle -0.3 to +3.6V.My Question: What is the operating voltage range relative to USB GND of the D+ and D- pins?I understand that the data is sent as a differential pair and that logic 1 and logic 0 are defined as voltage differences between D+ and D-. What I can't seem to figure out (after a lot of googling) is the range at which these voltages are allowed. Is the +- 200mV needed for the differential pair centered around 0 or around 2.5V or 3.3V etc? Basically I just don't want to fry my chip.I tried to measure this with my scope and got a central value of around 2.5V. Does that sound correct? Is that device specific?Thanks for your help guys, I'm very much stuck on this one! - A lowly 3rd yr electronics student.PS. Wild one here - Could I use an MOV to protect the MCU pins from higher voltages? I know that a Zener would be too slow for this given USB operates in the MHz range.

author: pcprogrammer
author_rank: Super Contributor
timestamp: August 30, 2022, 12:45:12 pm
content: A 3.6V zener diode to ground on either line works without problems. Include a small resistor in series like 47 ohms or so and you will probably be fine. I have used this with USB normal speed devices. (12Mbps)Even though USB power supply is 5V the USB signals are limited to 3.3V for as far as I know.

author: ataradov
author_rank: Super Contributor
timestamp: August 30, 2022, 03:24:29 pm
content: Don't do this. You are going to damage user equipment. A device is expected to have D+/D- as inputs (one pulled high, one pulled low depending on the USB speed). The host then would drive the bus. If your MCU also drives one of the lines, then there will be an electrical conflict.The voltage levels on the lines are clearly specified in the USB specification. But again, don't do this. It is a bad idea.One way I would even remotely consider doing this is if UART TX is disabled by default and both lines are inputs pulled low. Then the TX pin is activated once it received a valid non-trivial command over the RX pin. But having the UART pin low by default may confuse the UART, so it depends on how the MCU handles this.

author: langwadt
author_rank: Super Contributor
timestamp: August 30, 2022, 03:37:21 pm
content: Quote from: ataradov on August 30, 2022, 03:24:29 pmif the uart isn't too fast it'll probably work through a 1.5k resistor, then the TX high would just look like the usual pull-up so it wouldn't damage anything

author: ataradov
author_rank: Super Contributor
timestamp: August 30, 2022, 03:39:32 pm
content: Yes, it would work, but it is a horrible idea for a real product. Also, you will get messages from the OS that device can't enumerate.

author: pcprogrammer
author_rank: Super Contributor
timestamp: August 30, 2022, 03:40:12 pm
content: I doubt that when a 47 ohms resistor is placed in series the USB port gets damaged when lines are held low.But you are right that it is better to make sure both lines connected to the USB terminal are set to input, and only when the system is sure a valid configuration device is connected activate the transmission line as output. Not familiar with the NRF51 so don't know if it is possible to do this.Like langwadt says if needed use a higher value resistor.

author: langwadt
author_rank: Super Contributor
timestamp: August 30, 2022, 04:07:24 pm
content: Quote from: ataradov on August 30, 2022, 03:39:32 pmsure keep the pins low, unless you need to use the uart, so it doesn't try to enumerate, but the 1.5k would prevent damage in case you did set the output highmaybe you could detect that a uart and not USB is attached by looking at the RX pin going high

author: pcprogrammer
author_rank: Super Contributor
timestamp: August 31, 2022, 04:26:56 am
content: Another idea could be to just emulate a low speed USB device with the NRF51.Take a look here for some insights how it is done on an ATtiny85https://github.com/harbaum/I2C-Tiny-USB

author: magic
author_rank: Super Contributor
timestamp: August 31, 2022, 07:46:07 am
content: Use a different connectorOtherwise yes, it would be better to ensure that both lines are low until the debug interface is activated by some magic signal from your test gear.Normal USB host pulls both lines down with 15kΩ.https://beyondlogic.org/usbnutshell/usb2.shtml#SpeedIdentificationSeries protection resistors could be larger than 1k5 if USB cable is not too long and baud rate not too fast - check with a scope.Also, think what happens when somebody's USB cable has a short between data lines and 5V. Real USB devices are required to withstand such condition for 24 hours and "indefinitely" is recommended.

author: langwadt
author_rank: Super Contributor
timestamp: August 31, 2022, 09:27:03 am
content: Quote from: magic on August 31, 2022, 07:46:07 ama different connector makes it a hassle to power it from USB, 5V/1.5k is only 3mA even an output can probably handle that with a bit of care

author: janoc
author_rank: Super Contributor
timestamp: August 31, 2022, 09:57:32 am
content: Quote from: langwadt on August 31, 2022, 09:27:03 amDifferent connector could well still be USB-C but using the proper alternate mode pins for this sort of thing. That's what they are for.Messing with the D+/D- lines is a good way to confuse the hell out of whatever host this gets plugged into (and someone, somewhere will for sure do it at some point) and potentially fry something (e.g. USB chargers routinely short the data lines together to indicate they are a charger).Repurposing USB connectors like this is never a good idea.Also, OP, don't use the obsolete nRF51 series for a new design! Use nRF52 or the new nRF53 instead, they are much much better.

author: tooki
author_rank: Super Contributor
timestamp: September 03, 2022, 06:49:11 pm
content: Quote from: janoc on August 31, 2022, 09:57:32 amThis.Can’t you use an internal programming header to program the board before closing the case? Or find some other way of exposing the data lines to the outside, if closed-case calibration is needed?