Serial 9 bit.

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Christer_A
 
Posts: 7
Joined: Wed Dec 05, 2018 5:33 am

Serial 9 bit.

Post by Christer_A »

I have a project where a server is using RS485. 1 start bit, 8 databita, 1 ’Parity’ bit and 2 stop bits.
But the Parity bit is a Command bit for special signal to a receiver. So it is more like 9 bits.
I need a way/library to be able to read the Parity bit.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Serial 9 bit.

Post by adafruit_support_bill »

But the Parity bit is a Command bit for special signal to a receiver. So it is more like 9 bits.
Most hardware UART implementations will swallow the parity bit and only give you an indication if the parity check fails. You will probably need to start with a software implementation and add some tweaks to allow you to read the parity directly. There are several software serial libraries out there. The best is probably PJRC's AltSoftSerial:
https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

User avatar
Christer_A
 
Posts: 7
Joined: Wed Dec 05, 2018 5:33 am

Re: Serial 9 bit.

Post by Christer_A »

HW Serial read on Feather M0 or Feather Huzzah32. Serial.begin(9600,SERIAL_8E2);
…. and in the void loop() use
If (Serial.available() >0…..

The transmitted data use 9600, ”parity”, 2 stopp bits. BUT ! The ”parity” bit is not used for parity but for a special control signal. So the detected data could have a correct or wrong parity bit.
Will the uart still present the 8 databits and be shown when reading by the code or will the data be ignored and not shown if the parity bit is considered as wrong

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: Serial 9 bit.

Post by adafruit_support_bill »

See section 26 of the M0 datasheet for details on the USART operation: https://ww1.microchip.com/downloads/en/ ... 01882F.pdf
It looks like a parity error on receive will set the error bit & the data will still be available.

User avatar
Christer_A
 
Posts: 7
Joined: Wed Dec 05, 2018 5:33 am

Re: Serial 9 bit.

Post by Christer_A »

Thank you !!!

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”