How to use parity space and mark


I am using Arduino Uno to send serial data to another device which requires the data to be in serial parity space and mark, but I can't find an alternative to serial parity space and mark,How can i do?

Arduino Uno has only configures the data, parity, and stop bits. The default is 8 data bits, no parity, one stop bit.

If anyone is aware of such issue and how it can be handled properly, could you please let me know so that I can proceed further.


Welcome to the Arduino forum. Good place to learn and get help.
But what you have written makes no sense. Can you please quote exactly the specifications for serial data for the device? OR provide a link to it's technical specifications.

Me2, I cannot interpret that requirement. It may be a translation mistake for odd or even parity.

Protocol adjustments can be added to the Serial.begin(), see the Arduino Reference.

but i don't find parity space and mark. thank

What are you saying ?

Serial.begin(speed, config)


Serial: serial port object. See the list of available serial ports for each board on the Serial main page.
speed: in bits per second (baud). Allowed data types: long.
config: sets data, parity, and stop bits. Valid values are:
SERIAL_8N1 (the default)
SERIAL_5E1: even parity
SERIAL_5O1: odd parity

Saying the same like me in #4:

is not part of that table.

I'm use rs232

I'm need a "mark" is a 1-bit (or logic 1) and a "space" is a 0-bit (or logic 0).
For mark parity, the parity bit is always a one-bit. For space parity
it's always a zero-bit.

MARK and SPACE are terms used on the old telegraph system that used a pencil to write on a moving paper tape. MARK drew a line and SPACE raised the pencil so no line.
What machine are you using?

There is an old ‘weird’ spec. that defines parity a fixed mark or space, but I’ve never seen it used.

OP, perhaps you can post or link to your protocol requirement here, because I’m sure we can figure out what you need.

I don’t believe I’ve ever seen gear that enforces that unusual parity requirement, despite specifying it.
It may SEND with that fixed parity but, but you can ignore i when receiving.

That "weird" spec found it's way to mechanical teletype machines that used a mechanical distributor and was controller by an electromagnet. When held in, or "mark", the rotating distributor was held in position. On "space", the magnet released the distributor. All this to mechanically select a letter to be printed.

Attempts to detect errors added one more bit to the code and distributors and this was the mark/space parity bit. This made 8 bits total per character.

I need to implement a custom serial protocol where the parity bit is used as a "message start" identifier... that's it, the parity bit needs to be set (1) only for the first byte to be sent then it needs to be cleared (0) for every subsequent byte of that message (the parity bit is not used for CRC purpose as intended by the 232 standard).

How many data bits?

Communication between the client and server occurs through a serial data link operating at 19.2 K in a "wakeup" mode,eight data bits, a ninth ‘wakeup’ bit, and one stop bit.
According to this protocol, the server needs to read the 9th bit (the parity one) and to decide by itself if that's the start byte of a new message (parity bit is "1") or (parity bit is "0").

Can we see the protocol definition from your device…
i.e. how o you know it’s static parity ?
Any serial command reference ?

The '328 has a 9 bit data mode which is not supported by most libraries. With some register massaging it should work for your protocol.

Here's a 9-bit SoftwareSerial library I found with a little Googling:

The 328P hardware UART doesn't support Mark or Space parity. However, as @DrDiettrich pointed out the 328P does have a 9-bit mode. The 328P datasheet I have has a section on "Multi-processor Communication Mode" - it's section 20.9 for me but may be different for you if you have a newer/older datasheet.

I suspect that you can use that to achieve the Mark & Space parity you need for your messages.

Is it an asynchronous serial data communication? If so, the TXD line is always at HIGH state and it gets pull-down for 1-bit period to indicate the START of a new frame and then comes the 8-data bit with LSB first and then the Parity Bit (Even or Odd) and then the STOP Bit. The following diagram of Fig-1 shows an asyn frame of 11-bit length with even parity option. This frame will be automatically generated with Bd = 9600 when the following code is included in a sketch.

Serial.begin(9600, SERIAL_8E1);//1 START Bit, 8 Data Bits, 1 Even Parity Bit, 1 STOP Bit.