Serial port 11 bit character

Hello

I'm just researching a project to communicate with a piece of serial equipment.
I hope to be using an ATTINY841 for the controller.
I know basic serial port usage with serial.begin(4800), serial.read() etc. as I have already used this library for another serial project.

With the new project the data packet involved is formatted as such:

1 start bit
8 data bits
1 command bit
1 stop bit

Can the serial library be used to read the serial frame dictated above or will I need to find another way of reading the data stream?

Are the start and stop bits dealt with by the USART automatically? If so I can discount them. There has been a suggestion the command bit could be exposed via the parity bit, but this would also depend on if the parity bit is passed into the data or processed by the UART.

Regards

IcarusBop

are you asking for 9N1 support ?

if you search for "arduino serial 9N1", you should see some comments for this

The hardware is capable of 9 data bits but at least the standard ATmega hardware serial library doesn't support more than 8 data bits, so I doubt that the developer of the core for the Tinys added that feature. Of course you can add that feature yourself (that's one of the benefits of Open Source software!) but I'm not aware of any ready-to-use library for the Tinys.

Yes, that hardware handles that automatically.

The parity bit is processed by the hardware, so you cannot use it as a replacement of the 9th bit.
The hardware has support for that 9th bit, you can find it in the UCSRnB register.

Hello All

Sorry for the delays - I've not been able to get back in to my account to respond, it turns out I was using an email address with a typo in it.
Again sorry.

Thanks to everyone for their Reponses:
I am trying to get 9N1 serial when the start & stop have been taken into account.

I've done some searching and found a few more suggestions that I am going to work through and piece together to get this working.
The library does not support it but I've found some suggestions that after using the library to initialise the serial, I can then set a flag to change serial to 9 bits. After the serial has indicated there is data there is a method of reading the 9th bit, which needs to be done before reading the 8but byte from the serial otherwise the 9th bit gets reset.

I'm going to work in this as an idea and see if I can get it working.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.