Page 1 of 1

9bit hardware serial is it possible

Posted: Thu Oct 04, 2018 12:39 pm
by tballam
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 9502 times
Thanks

Re: 9bit hardware serial is it possible

Posted: Fri Oct 05, 2018 7:40 am
by ESP_Sprite
The ESP32 UART supports hardware parity. See the UART driver for more info.

Re: 9bit hardware serial is it possible

Posted: Fri Oct 05, 2018 7:58 am
by WiFive
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.

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

Posted: Fri Oct 05, 2018 1:59 pm
by tommeyers
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

Re: 9bit hardware serial is it possible

Posted: Fri Oct 05, 2018 2:26 pm
by tommeyers
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

Re: 9bit hardware serial is it possible

Posted: Fri Oct 05, 2018 6:20 pm
by WiFive
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.

Re: 9bit hardware serial is it possible

Posted: Fri Oct 05, 2018 8:23 pm
by tballam
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

Re: 9bit hardware serial is it possible

Posted: Sat Oct 06, 2018 4:49 am
by ESP_Sprite
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.