MCP2221A UART bus conundrum ...

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
For years I've been using the following circuit to connect MCU's UART I/Os in a parallel bus:
1693841123725.png
As can be seen, transmitting from the Master MCU to the peripheral MCU's is pretty straightforward. Normal Tx lines are idle high and logic low. TXa is a push-pull output that drives the RXb, RXc and RXd inputs directly. But transmitting from the slaves requires the use of schottky diodes at their outputs so that they don't crash with one another when they go low. R1 is needed to pull RXa high when the line is idle.

This arrangement has the advantage of keeping the circuit simple by not using an OR gate IC to feed the RXa input. And it has the added advantage that no extra power is needed to make things work. And that's important because the circuit is battery powered.

Enter the cursed MCP2221A ... this chip is a USB to UART converter that I use quite frequently in the configuration already shown. But the darn thing has the nasty habit of sinking current through its TXd pin when the chip is powered off. That is, when the chip is energized, its TXd pin behaves like a normally high ordinary push-pull output. But when power is removed, its TXd somehow draws current from the line. And this has the effect of not only wasting unnecessary battery power, but it also lowers the voltage at RXa to about 2.25V when idle instead of the required 3.3V. This has the consequence of sometimes causing the wrong characters being received at RXa when they're transmitted from the slaves due to the line being on the threshold of the minimum voltage level required to qualify as a logic high.

To try to remedy this situation, I implemented the following arrangement in my circuit:

Capture 01.PNG

USB_Pwr represents power being applied to the MCP2221A and TXd represents the chip's transmission line, which can source or sink current. As can be seen, the circuit does exactly what I'd like it to do when an ideal nFet is used. That is, voltage levels at RXa are nice and steady when USB_Pwr is high, and have no reaction to changes in TXd when USB_Pwr is off.

BUT ... when I tried to use a REAL nFet such as the 2N7002 things went haywire ...

Capture 02.PNG


And silly me, being the stubborn type as some people here are already aware of, I decided to build the circuit and test it using a DMG2302U nFet just to see how it behaved.

And misbehave it did ... have a look at this mess:

1.jpg


The yellow trace shows the level of the RXa line while attempting the transmission of an "n" character from the MCP2221A to the Master MCU at 115,000 bauds.

I've already tried using other Fets and even a BJT transistor to no avail...

Again, I need an arrangement to block the MCP2221A's TXd pin from sinking current when the chip is off. And said arrangement should consume zero power (or as little as possible) while the MCP2221A is not powered.

ANY IDEAS? :(
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
After noticing the overwhelmingly enthusiastic response to this thread by other members of this fine community, I have decided to change tactics.

My circuit makes use of a high-side pFet to turn the MCP2221A chip on and off. And yet, somehow current manages to creep through its TXd pin while it's powered off. And since all current supposedly flows from the positive side to ground, what I am going to do now is remove said pFet and install an a low-side nFet instead to switch the chip off. This will disconnect the chip from ground (instead of disconnecting it from Vcc as the pFet has been doing), hopefully preventing current from flowing into its TXd pin.
 

michael8

Joined Jan 11, 2015
431
Enter the cursed MCP2221A ... this chip is a USB to UART converter that I use quite frequently in the configuration already shown. But the darn thing has the nasty habit of sinking current through its TXd pin when the chip is powered off. That is, when the chip is energized, its TXd pin behaves like a normally high ordinary push-pull output. But when power is removed, its TXd somehow draws current from the line.

Sounds like it has a protection diode from the TXd pin to Vcc. When Vcc is 0 (power off) it tries to power the rest of the
circuit from the power input to TXd.
 

ElectricSpidey

Joined Dec 2, 2017
2,900
After noticing the overwhelmingly enthusiastic response to this thread by other members of this fine community, I have decided to change tactics.

My circuit makes use of a high-side pFet to turn the MCP2221A chip on and off. And yet, somehow current manages to creep through its TXd pin while it's powered off. And since all current supposedly flows from the positive side to ground, what I am going to do now is remove said pFet and install an a low-side nFet instead to switch the chip off. This will disconnect the chip from ground (instead of disconnecting it from Vcc as the pFet has been doing), hopefully preventing current from flowing into its TXd pin.
The issue you are facing has nothing to do with the direction current flows.

The issue involves continuity between the non-power pins to either rail when the power is removed from the chip.

Example:

You have a 4 pin chip, two power pins and two "input" pins numbers 1 and 2.

If pin 1 has continuity to the positive rail you must disconnect the negative pin to stop current flow.
If pin 1 has continuity to the negative rail you must disconnect the positive pin to stop current flow.
If pin 1 has continuity to the positive rail and pin 2 has continuity to the negative rail you will have to disconnect both power pins to stop current flow.
There are also possibilities such as pin 1 having continuity to pin 2 and so forth.

Perhaps in simpler terms...

Current will always flow when there is continuity between the positive rail and the negative rail irrespective of which direction the current flows.

Changing which power pin you switch may well solve your problem, but it has nothing to do with the direction of current flow.
 

michael8

Joined Jan 11, 2015
431
I think you have something like the following and the current path includes your PMOS power switch. You could use two PFETs
in opposite directions to block both directions of current flow. This leaves the "internal curcuit" still connected to TX and it might
draw current from TX. Or you could put two opposite facing PFETs in the TX line ahd tristate them when not using TX.

mcp222a.png
 

Attachments

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
I think you have something like the following and the current path includes your PMOS power switch. You could use two PFETs
in opposite directions to block both directions of current flow. This leaves the "internal curcuit" still connected to TX and it might
draw current from TX. Or you could put two opposite facing PFETs in the TX line ahd tristate them when not using TX.

View attachment 302260
Thank you for your input, but I forgot to mention that I'm powering the MCP2221A from the USB bus itself, through a 3.3V regulator that already blocks current in both directions when disconnected.

Thanks. I've just scoped MCP2221A's Tx output by itself. That is, disconnected from the rest of the circuit. And the waveform came out a-Ok ... that means that its output can't deal with the capacitive load from the diodes in parallel. So I've ordered a few buffer/isolators to deal with that issue. I hope that works, otherwise I don't know what I'm going to do to keep the circuit as simple as possible.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
Here's a more nuanced diagram of how things are arranged in my circuit.

1694105523147.png

And here's the interesting bit. All Tx lines are idle high outputs, and that's the reason why diodes D1-D3 are there. If I remove D1, voltage between Point A and ground reads as 3.3V and voltage between point B and ground also reads 3.3V. As it should be.

BUT, with diode D1 installed in the circuit, voltage between point B and ground is 3.3V, but voltage between point A and ground is 2.0v !!! ... what the fudge is going on? :oops:

I truly hope that the buffer/isolators that I ordered will take care of this mess.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
Nope ... the isolators did not work ... although the waveform did improve a tiny bit:

1694356677303.png

One thing I discovered, when I removed Slave 1 and Slave 2 from the circuit, and left only the Master MCU connected through the diode to MCP2221A the waveform stayed exactly the same. And when I bypassed D1 and shorted point A and point B, the waveform acquired a perfectly squared shape. My conclusion is that the diode's capacitance at its anode is the culprit. Things would probably improve if I were to use a better diode.

The next step now is that I'm going to get rid of the diode altogether and try to use a pFet connected as a diode instead... see what happens.

@nsaspook , I'm a little desperate here and I'd appreciate your input. I've seen you posting plenty of pics with nice and pretty square waves monitoring different devices. What I'm trying to do here is somehow implement a three input OR gate that draws zero current while it's not in use. That's why I'm using diodes and not a gate in a chip. Also, the diodes work fine at very low baud rates, but things go haywire when working at 115,200 bauds. I'd really appreciate your input. Is there such a thing as a high speed Schottky diode and would that do the trick?
 
Last edited:

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
Which diodes are you using?
I'm using BAT54 Shottky diodes.

In the meantime, I have tried using an nFet with its Gate and Source connected together to replace D1, and, although not perfect, things improved significantly.

schematic

Here's the result of my experiment:

4.jpg

Things got so much better that I am now getting reliable communications between the MCP2221A and the MCU. But I'm still not entirely satisficed. So I've ordered a few fast-recovery, low capacitance Schottky diodes to use them in my next circuit. They should be arriving the day after tomorrow. I truly hope they behave better than the nFet, because using said transistor resulted in a voltage drop of almost 400 mV, which is a non-trivial figure when working with 3.3V logic.
 

MrSoftware

Joined Oct 29, 2013
2,212
I skimmed so forgive me if I'm off a bit, but if the idea is to basically turn one pin on that chip on/off, look at some USB switch IC's. We use those on a product at work, we use it to choose which USB device is connected to a port, but I don't know why you couldn't use it as a single pin bi-directional on/off. I'm not at work at the moment and can't remember the part number, but search digikey for USB switch and you'll get several options. When that ports not in use, flip the switch and that pin will essentially be high Z.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,304
The "fast" diodes arrived at last ... and the result was much, much WORSE than I expected. They're so bad that indeed I consider them as being completely useless other than for general purpose applications.

What that means is that I do not really understand what "fast recovery" means as far as diodes are concerned.

5.jpg

No matter ... I've found the solution already. I'm going to use a non inverting open drain output buffer. The only drawback is that it consumes an itsy bit amount of current, instead of the zero that I would've liked. But it won't make a difference, since I plan to connect it to the same regulator that feeds the the MCP2221A, so it will be switched off along with it when power is removed. And it boasts a high-z input that prevents current back flow when the device is not energized.

Back to the shopping website ...
 
Last edited:
Top