Level shifter between ESP32 and STM8S Uarts - Page 1
Forum section: electronics / general

author: mspider65
author_rank: Contributor
timestamp: April 14, 2020, 09:07:57 pm
content: Hi,i have realized a custom PCB board based on an ESP32 that connects to an external STM8S through a Wire to Board connector.The connection is between the UART ports (9800 baud) of the two microcontrollers and i have used the TXS0104 Level Shifter to adapt the 3.3V ESP32 logic levels to the 5V STM8S logic levels.The problem is that when i connect the STM8S signal connector to the board, the low logic level of the STM8 TX signal (Input for the TXS01040 B Port) is shifted to 0.7V instead of 0V.If i leave disconnected the STM8S connector, the low level is correct and is 0V.Obviously, the external STM8S board and my board share the same ground wire.It is the first time i use the TXS0104 and i can't understand what the problem is.Follows the board schematic and the scope screeenshot showing the issue.Thanks!

author: pwalther
author_rank: Contributor
timestamp: April 15, 2020, 06:07:03 pm
content: 0.7 volts sounds like the voltage across a diode. Probably one of the transistor PN-junction in the level shifter.But 0.7 volt is a acceptable CMOS low level voltage so it should be fine.

author: mspider65
author_rank: Contributor
timestamp: April 15, 2020, 06:10:14 pm
content: Quote from: pwalther on April 15, 2020, 06:07:03 pmYes, but txs0104 level shifter doesen't use cmos levels. The datasheet shows 0.15V as VIL.

author: pwalther
author_rank: Contributor
timestamp: April 15, 2020, 06:16:43 pm
content: It doesn't, you where looking at the input specification.The output low level is specified at 0.4 Volts, still lower than 0.7 but not .15.

author: pwalther
author_rank: Contributor
timestamp: April 15, 2020, 06:26:14 pm
content: What's the circuit on the other side? Any pullup/down resistors? Or just wire->connector->mcu input

author: mspider65
author_rank: Contributor
timestamp: April 15, 2020, 06:28:28 pm
content: The stm8s uart tx is an input for the txs0104.

author: pwalther
author_rank: Contributor
timestamp: April 15, 2020, 06:30:39 pm
content: Oh i missunderstood your question. I thought the 0.7V is after the level shifter not on the input.

author: fchk
author_rank: Frequent Contributor
timestamp: April 15, 2020, 06:33:15 pm
content: Quote from: mspider65 on April 14, 2020, 09:07:57 pmThe lesson you are about to learn is that you should not use level shifters with automatic direction control if there is no real need to do.These level shifters are very sensitive to the outside world, and they have weak driver strength. The automatic direction control is easy to fool.You should use level shifters with manual direction control instead - 74LVC1T45, 74LVC2T45, 74LVC8T245 are good choices and habe 24mA drivers. They are reliable.

author: mspider65
author_rank: Contributor
timestamp: April 15, 2020, 06:36:15 pm
content: The other side is a ebike controller based on a stm8s mcu.My board operates as "man in the middle" between ebike controller and the lcd.The same problem is faced also on the tx line coming from the lcd.Maybe the manufacturer have put a series resistor on the tx lines to prevent shorts.

author: pwalther
author_rank: Contributor
timestamp: April 15, 2020, 06:38:53 pm
content: That was my guess.Because ther's an internal pullup of 10k, if you have a 1400 Ohm resistor in series on the outputs / inputs of the other side you would get the 0.7V when the uC pulls low.But 1400 Ohm is kinda high for a series resistor...

author: mspider65
author_rank: Contributor
timestamp: April 15, 2020, 06:47:34 pm
content: Quote from: fchk on April 15, 2020, 06:33:15 pmYou are rigth. The problem is that i have a very limited footprint, (24x40mm) to put all the logic and the vqfn txs0104 saves a lot of space. I have to place a Step down converter from ebike 55v battery to 5V, the LDO to 3.3V, the ESP32 MCU, the antenna connector a temperature sensor, the level shifter and some connectors.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 15, 2020, 06:48:19 pm
content: Just use a resistor and clamp diode, or a single NMOS and pullup resistor.The baud is very low so the resistors can be quite large.Tim

author: mspider65
author_rank: Contributor
timestamp: April 15, 2020, 07:40:45 pm
content: Quote from: pwalther on April 15, 2020, 06:38:53 pmIn this case, since i have some PCBs already populated with the TXS0104, could be a solution substitute the TXS0104 with the TXB0104 that have the same package footprint ?

author: kripton2035
author_rank: Super Contributor
timestamp: April 15, 2020, 07:52:03 pm
content: I've tried this txs0104 and never succeded with thembetter use a small mosfet and two resistors, simple and easier.

author: fchk
author_rank: Frequent Contributor
timestamp: April 17, 2020, 05:33:14 pm
content: Quote from: mspider65 on April 15, 2020, 06:47:34 pmThe best way is to use two 74LVC2T45. Each handles to pins, so you need two of then for both directions. VSSOP8 is the smallest package unless you are capable of handling DSBGA with 0.5mm pitch.Forget all the bidirectional level shifters - you are guaranteed to run into further problems.

author: mspider65
author_rank: Contributor
timestamp: April 18, 2020, 01:31:28 pm
content: At the end for the final PCB i have chosen the 74LVC2G17 for the down conversion from 5v to 3.3v. It has two lines and a small SOT363 packge.Since i need Output Enable function, for the up conversion i have chosen the M74VHC1GT126, it has TTL input levels and it si possiblle to drive the 5V output from the 3.3V CMOS levels.Both components also costs a few cents.Thanks all for the suggestions.