9bit hardware serial is it possible

tballam
Posts: 2
Joined: Thu Oct 04, 2018 12:15 pm

9bit hardware serial is it possible

Postby tballam » Thu Oct 04, 2018 12:39 pm

I have an application where I need to implement 9 bit serial,
The device I'm trying to talk to uses 8 bit data with constantly changing parity as a method data validation.
I was looking at bit-banging but would rather hardware if possible due to more reliable comms.
I've attached an example of the serial stream I want to creat.
key1.JPG
key1.JPG (85.03 KiB) Viewed 8339 times
Thanks

ESP_Sprite
Posts: 9051
Joined: Thu Nov 26, 2015 4:08 am

Re: 9bit hardware serial is it possible

Postby ESP_Sprite » Fri Oct 05, 2018 7:40 am

The ESP32 UART supports hardware parity. See the UART driver for more info.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: 9bit hardware serial is it possible

Postby WiFive » Fri Oct 05, 2018 7:58 am

ESP_Sprite wrote:The ESP32 UART supports hardware parity. See the UART driver for more info.
It doesn't support "constantly changing parity" though. If you notice the first byte is odd parity and the next two are even. I don't know if you could use the UART_TXFIFO_EMPTY_INT to change the parity mid frame.

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

Re: 9 bit hardware serial is it possible (Yes)

Postby tommeyers » Fri Oct 05, 2018 1:59 pm

Constantly changing parity!?? Your example does show both odd and even parity in a single transmission.

OK, if that is what you want begin() with odd then send 1 char then begin() and change to even and send 1 char...

I suspect that the example is incorrect.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

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

Re: 9bit hardware serial is it possible

Postby tommeyers » Fri Oct 05, 2018 2:26 pm

9N1 has a history in Arduino.

I googled Arduino 9N1 and found a lot of information.

What I learned was that 9N1 is not uncommon and sometimes implemented in the UART so the first step could be to check the esp32 uart capability. Life will be easier if the UART has the capability.

The solution I suggested, above, still might work for sending 9bit data.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: 9bit hardware serial is it possible

Postby WiFive » Fri Oct 05, 2018 6:20 pm

It might work if you send one byte at a time but if the delay between bytes is too long the other device might consider it a framing error.

tballam
Posts: 2
Joined: Thu Oct 04, 2018 12:15 pm

Re: 9bit hardware serial is it possible

Postby tballam » Fri Oct 05, 2018 8:23 pm

Thanks for the replies so far

Yes the data is 100% correct and is not corrupt.

I've tried sending the data by sending 1 byte then changing parity then sending the next but framing errors occur as you predicted

ESP_Sprite
Posts: 9051
Joined: Thu Nov 26, 2015 4:08 am

Re: 9bit hardware serial is it possible

Postby ESP_Sprite » Sat Oct 06, 2018 4:49 am

FWIW, if you go the bitbanging route, you may be better off abusing the RMT peripheral as it'll handle all the timings for you.

Who is online

Users browsing this forum: No registered users and 240 guests