Is it possible to support 9-bit multi drop bus on UART?

Xavi92
Posts: 31
Joined: Thu Mar 28, 2019 2:26 pm

Is it possible to support 9-bit multi drop bus on UART?

Postby Xavi92 » Wed Apr 08, 2020 2:13 pm

Hello,

We are designing a device based on the ESP32 which acts as a bridge between devices using the MDB/ICP protocol. Tipically, a UART configured to support 9 data bits is used for this purpose, since the protocol defines a frame as:

Code: Select all

Start bit | Bits 0 to 7 | Mode bit | Stop bit
Where mode bit is 1 when address information is included and 0 for application data.
However, the ESP32 only supports up to 8 data bits, so it looks we are out of luck here. We have seen other devices which allow reusing the parity bit so it can be used as mode bit. Would that or other tricks be possible on the ESP32?

Thank you very much.

tommeyers
Posts: 107
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Is it possible to support 9-bit multi drop bus on UART?

Postby tommeyers » Wed Apr 08, 2020 5:09 pm

If I needed to do this I would find a software serial library and modify it.

I assume you have searched for existing code.

A scope will make development easier.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

Xavi92
Posts: 31
Joined: Thu Mar 28, 2019 2:26 pm

Re: Is it possible to support 9-bit multi drop bus on UART?

Postby Xavi92 » Thu Apr 09, 2020 9:23 am

Hello Tom,

You are completely right, a software-emulated UART would do the trick. I have been looking for implementations on the Internet, but most (if not all) are MCU-specific, so they would still need to be adapted to the ESP32.

Thanks a lot for your help,
Xavi

Xavi92
Posts: 31
Joined: Thu Mar 28, 2019 2:26 pm

Re: Is it possible to support 9-bit multi drop bus on UART?

Postby Xavi92 » Mon Apr 20, 2020 7:42 am

Another trick we came up that would allow a 9th data bit using the hardware UART is to reconfigure the parity on each byte. For example, if 9th bit == 1 and (data[0:7] & 1), odd parity is configured, and even parity is configured if !(data[0:7] & 1). A similar logic applies to 9th bit == 0.

While being more a hack than anything, is this method still valid for the ESP32? Should we expect any side effects because of configuring the parity bit so many times?

Thank you,
Xavi

Who is online

Users browsing this forum: No registered users and 23 guests