Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Single wire UART to Microcontroller

+3
−0

I’m using an Infineon TLE4973 current sensor. It has a DCDI pin, which the datasheet describes as a single‑wire, open‑drain, UART‑based interface (master–slave). It specifies logic thresholds (LOW ≤ 1.0 V, HIGH ≥ 1.6 V) and recommends a pull‑up resistor between 433 Ω and 1320 Ω on the DCDI line. The sensor runs from 5 V (functional range 4.5–5.5 V).

My microcontroller uses 3.3 V logic. I plan to pull DCDI up to 3.3 V so the MCU can read it directly. Since DCDI is open‑drain and the sensor only pulls the line low, this should meet the high‑level threshold. Also, the datasheet says the DCDI pin voltage may range from –0.3 V to VDD, so 3.3 V on the pin should be within limits while the device is powered at 5 V.

Question:

What’s the cleanest way to connect this one‑wire, open‑drain UART to a standard MCU UART that has separate TX/RX pins?

History

0 comment threads

1 answer

+3
−0

Since the guaranteed logic high threshold is 1.6 V, passively pulling the line to 3.3 V will be fine. Unless you are operating from batteries or every mW otherwise matters, I would use a pullup towards the low end of the range since you are operating with less voltage margin than at 5 V.

With a pullup to 3.3 V, you should be able to connect the DCDI line directly to the microcontroller RX input.

The micro's TX line can't be directly connected if it actively drives in both directions. Some micros can route peripheral signals to different pins and can disable the high side driver. In that case you can connect the DCDI line to both the RX and TX pins directly.

If the micro can't be configured to only drive TX low, then you have to add external circuitry to achieve that. The simplest would be a Schottky diode in series. Check the TX line maximum possible logic low, add the diode drop to that, and make sure the result is still solidly below the 1.0 V threshold. If that doesn't work out, you can use transistors:

Something like this also necessary if the TX line can't sink enough current to solidly overcome the pullup. The values in this circuit are adjusted so that even with only a gain of 20 for Q2, it can still sink 13 mA. That times the worst case pullup of 433 Ω is 5.7 V, which is more than the voltage across the pullup can ever be.

Another advantage of this circuit is that the TX pin only needs to sink 260 µA, compared to the 7.6 mA required to drive low against a 433 Ω pullup.

If you can arrange the RX input of the micro to be 5 V tolerant, then you can pull DCDI to 5 V for greater noise immunity. The circuit above will still work without modification for driving DCDI from the TX pin.

With that circuit, I can connect MCU UART TX → your circuit → DCDI, and MCU RX directly to DCDI, and then use normal UART timing on the MCU, right?

Yes.

And on the firmware side, the only thing I need to manage is switching between transmit and receive at the right times?

Sortof. You don't "switch" between transmit and receive like you would with a RS-485 line, for example. The hardware isn't in one of transmit or receive mode. Both are simultaneously active. Electrically, anyone can pull the bus line low at any time.

The firmware needs to make sure that it is only causing the UART to send when that is allowed by the higher level protocol. Keep in mind that the UART probably has an outgoing FIFO of at least one but possibly several bytes. That means the UART will continue to send for a while after the firmware stops giving it characters. Hopefully the higher level protocol is designed to make this process easy.

Another issue is that all transmitted characters will be received by the UART too. The firmware will have to keep track of what it sent and discard those received characters. It could even do collision checking to make sure the sent characters got onto the wire correctly without something else pulling it low at the same time.

History

1 comment thread

Thanks again for the detailed explanation — it really helped clarify things. I now understand that bo... (1 comment)

Sign up to answer this question »