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.
Serial 9 bit.
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: Serial 9 bit.
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:But the Parity bit is a Command bit for special signal to a receiver. So it is more like 9 bits.
https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
- Christer_A
- Posts: 7
- Joined: Wed Dec 05, 2018 5:33 am
Re: Serial 9 bit.
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
…. 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
- adafruit_support_bill
- Posts: 88154
- Joined: Sat Feb 07, 2009 10:11 am
Re: Serial 9 bit.
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.
It looks like a parity error on receive will set the error bit & the data will still be available.
Please be positive and constructive with your questions and comments.