How to prevent a USB-TTL cable from latching the MCU pins? - Page 1
Forum section: electronics / projects

author: pBoev
author_rank: Contributor
timestamp: February 04, 2016, 10:30:27 am
content: Hello,So I came across an uncomfortable event. I'm using a USB-TTL cable for serial communication via UART. Whenever I switch off my device, the USB cable supplies power to the Rx and Tx pins and they are held at 2.5V. When I switch the device on again, the code does not run. Currently I can run the code if I remove the debug cable, switch the device on, plug the cable and hit the reset button. It'd be pain to remove the debug cable everytime I switch off. Also, I'd like to avoid powering up the GPIOs while the MCU is off.I've looked through the settings of various terminals but I couldn't find an option which would remove power form the Rx and Tx pins. Can I prevent this from happening without modifying the PCB?

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 11:09:55 am
content: Do you have the device Vdd supply available on its TTL level UART connector?

author: pBoev
author_rank: Contributor
timestamp: February 04, 2016, 11:12:48 am
content: No, the connector has GND, Rx and Tx only.

author: retrolefty
author_rank: Super Contributor
timestamp: February 04, 2016, 11:21:31 am
content: You could try using series resistors on the tx and rx pins to prevent latch up, maybe 1k ohms or more. That is how the Arduino interface tries and isolate the serial usb chip from it's micro.

author: langwadt
author_rank: Super Contributor
timestamp: February 04, 2016, 11:34:10 am
content: try a pull up on the MCU rx and a diode in series with the usb cable tx, so that the USB cable can only pull lowrx shouldn't matter on the USB cable, it is an input so it can't power the mcu, though you'd be receiving breaks when the MCU is off

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 11:41:34 am
content: If it doesn't work with a 10K resistor in series with the cable's TX line (the one that outputs a high level with the target device disconnected), you are probably pretty much FUBARed, as TTL level RS232 framing serial lines idle high.You could try sending a continuous Break, which will take TX low, and if you've got source code level control of the PC software you could do that if you receive a break (and clear it at the end of the received break).Alternatively there's a real kludge in hardware - trigger a monostable off the RX line to get you a signal that goes low if the line is low for more than a second or so, and use that to gate the TX line.

author: AndyC_772
author_rank: Super Contributor
timestamp: February 04, 2016, 12:05:44 pm
content: I agree, there's no hardware-free solution, since UARTs idle high and your MCU is getting powered through its input pin.Perhaps you could make a small device to sit in between the debug cable and the board, which has a series diode in the TX line, and a pull-up resistor to the board's own VCC supply on the MCU side. Then, the debug cable can pull TX low, but not high because of the diode. When the TX signal goes high, the resistor pulls up the MCU input pin, but only if the board has power.

author: mich41
author_rank: Regular Contributor
timestamp: February 04, 2016, 12:08:32 pm
content: You may also need similar circuit on RX path as UARTs leak some small current to RX as well.BTW, I wonder if one of those generic single-mosfet "bidirectional level shifter" modules wouldn't work here if you connected MCU to the low voltage side.edit: I think it would.

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 12:14:40 pm
content: That depends on the technology - a normal CMOS input will have negligible leakage current but a TTL input acts as if it has a pullup. Most TTL compatible CMOS does *NOT* have a pullup, and is only level compatible. I wouldn't expect a pullup on a USB<=>logic level serial adaptor unless it was specifically designed for interfacing tio 'retro' systems that used real TTL.

author: mich41
author_rank: Regular Contributor
timestamp: February 04, 2016, 12:43:29 pm
content: Nice speculation about something you can easily measureProlific PL2303 - <1uAFTDI FT232RL - 23uAPL2303 knockoff - 14mAIOW,you never know.

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 01:26:58 pm
content: Was that measured at the fake PL2303 pin, and the absence of any external pullup confirmed? Is there any possibility it had suffered ESD damage?If the answers were yes and no respectively, its yet another reason for the fake Prolific PL2303 chips to have a bad rep. 14mA of pullup current would exceed the abs max current sinking ratings of some CMOS device outputs.

author: mich41
author_rank: Regular Contributor
timestamp: February 04, 2016, 01:51:53 pm
content: No, I measured outputs from complete USB-UART converters. The first two are wired directly to IC pins, but the fake PL2303 dongle has an LED between VCC and RX which probably sourced majority of this current. Braindamaged idea, but there you have it.

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 02:04:50 pm
content: Yes, that is pretty dumb, cheap and nasty. I've got LEDs on various serial devices, but they are either buffered or run at under 1 mA. If it isn't potted/fully welded, I'd crack that open and fix it, or at least put a sane resistor in series with the LED.

author: mich41
author_rank: Regular Contributor
timestamp: February 04, 2016, 03:28:20 pm
content: WTF, it's actually coming from the chip. There's a series resistor behind the LED and I checked that it only sources 3.3mA, i.e. it's 1k5 (the whole thing runs at 5V). I didn't find anything else connected to RX pin.It's one of those "bare PCB in clear heatshrink tube" dongles you can buy for $1 from eBay. I got one for testing, don't beat me

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 03:39:44 pm
content: I *assume* that you've tried it loopbacked to confirm it actually works, because that does suspiciously resemble the typical symptoms of a blown upper ESD diode in the chip.A picture would be nice to help others avoid a totally crap product.

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 03:59:19 pm
content: The O.P. hasn't got a power pin on the target UART connector to power any buffers or the converter's I/O domane (if separate) so the options to fix the problem in hardware are very limited.

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 04:05:24 pm
content: Yes, but how are the hardware solutions going to detect the target is powered?

author: Ian.M
author_rank: Super Contributor
timestamp: February 04, 2016, 04:26:36 pm
content: Quote from: blueskull on February 04, 2016, 04:13:17 pmReply #2 above from the O.P:Quote from: pBoev on February 04, 2016, 11:12:48 amSo there is *NO* target Vcc available.

author: TheSteve
author_rank: Unknown
timestamp: February 04, 2016, 07:39:37 pm
content: Series resistors on the tx/rx lines are very common on your type of device. I see them used all the time.

author: pBoev
author_rank: Contributor
timestamp: February 12, 2016, 11:58:53 am
content: Thank you for the suggestions. It seems there's no getting around it without a hardware change. FTDI have a utility which allows reprogramming their serial cables. Inverting the TTL levels results in idling the output low which is what I need. However, it's not possible to invert the UART signals on the MCU so it's either using USART or buffering the power from the TTL cable.

author: macboy
author_rank: Super Contributor
timestamp: February 13, 2016, 03:09:06 pm
content: Does you microcontroller have brownout detection? This is a good use for that.