Author Topic: UART-USB Bridge  (Read 1543 times)

0 Members and 1 Guest are viewing this topic.

Offline poflynnTopic starter

  • Newbie
  • Posts: 2
  • Country: ie
UART-USB Bridge
« on: August 30, 2022, 11:20:34 am »
Hi guys, first post so go easy ;D!

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.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: UART-USB Bridge
« Reply #1 on: August 30, 2022, 12:45:12 pm »
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.

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11725
  • Country: us
    • Personal site
Re: UART-USB Bridge
« Reply #2 on: August 30, 2022, 03:24:29 pm »
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.
« Last Edit: August 30, 2022, 03:27:14 pm by ataradov »
Alex
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
Re: UART-USB Bridge
« Reply #3 on: August 30, 2022, 03:37:21 pm »
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.

if 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
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11725
  • Country: us
    • Personal site
Re: UART-USB Bridge
« Reply #4 on: August 30, 2022, 03:39:32 pm »
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.
Alex
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: UART-USB Bridge
« Reply #5 on: August 30, 2022, 03:40:12 pm »
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.

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
Re: UART-USB Bridge
« Reply #6 on: August 30, 2022, 04:07:24 pm »
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.

sure 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 high

maybe you could detect that a uart and not USB is attached by looking at the RX pin going high
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 4305
  • Country: nl
Re: UART-USB Bridge
« Reply #7 on: August 31, 2022, 04:26:56 am »
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 ATtiny85 https://github.com/harbaum/I2C-Tiny-USB

Offline magic

  • Super Contributor
  • ***
  • Posts: 7184
  • Country: pl
Re: UART-USB Bridge
« Reply #8 on: August 31, 2022, 07:46:07 am »
Use a different connector ;)

Otherwise 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#SpeedIdentification

Series 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.
« Last Edit: August 31, 2022, 07:52:37 am by magic »
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4701
  • Country: dk
Re: UART-USB Bridge
« Reply #9 on: August 31, 2022, 09:27:03 am »
Use a different connector ;)

Otherwise 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#SpeedIdentification

Series 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.


a 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
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3871
  • Country: de
Re: UART-USB Bridge
« Reply #10 on: August 31, 2022, 09:57:32 am »
a 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

Different 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.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 12577
  • Country: ch
Re: UART-USB Bridge
« Reply #11 on: September 03, 2022, 06:49:11 pm »
Repurposing USB connectors like this is never a good idea.
This.

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?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf