Go Down

Topic: Mixed Parity Odd and Even in Serial Protocol (Read 2 times) previous topic - next topic


Feb 14, 2013, 02:23 pm Last Edit: Feb 14, 2013, 02:25 pm by schmid01 Reason: 1

I have to send a Serial Command to a Device, that needs mixed Parity. So every Word contains:

1 Start Bit
8 Data Bits
1 Parity Bit (Odd or Even)
1 Stop Bit

The first 3 Words are Even Parity, the Following Words, including the Checksum is Odd.

How can I realise that?

My Command is for Example

01h 02h 03h 04h 05h FFh

Thanks for any help!


Feb 14, 2013, 03:41 pm Last Edit: Feb 14, 2013, 03:44 pm by Krodal Reason: 1
I think it is allowed to call Serial.begin() multiple times.
Receiving data is probably interrupted, but I assume that you are not receiving data at the same time.

Using Serial.end() stops the serial port.
So I would try this:
Use Serial.begin() with baudrate and SERIAL_8E1
Write the 3 bytes.
Wait until the 3 bytes are transmitted with Serial.flush().
Use Serial.begin() once more with SERIAL_8O1
Write the next 3 bytes.
And wait again for those bytes to be transmitted with Serial.flush().

Or do you use SoftwareSerial ?


Thanks Krodal.

That meight be a way to test sending words But I think every word is ended by a LF or CR with the println command.

The chalenge is also that I have to receive an answer in of the same kind too after every sent command.

Maybe software serial is a possibility, how must that be done?


Use 9-bit data, no parity, and create the 9th parity bit in software.
Do the same receiving - check the parity in software.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.


Serial.println will add a CR LF, but Serial.print and Serial.write don't.

If you set the last Serial.begin(), the data can be received. But only in the same format. So after you sent the last byte, the device starts responding and that data can be received in a normal way.

CrossRoads, 9-bit data ? Is that even possible ?

Go Up