How to handle parity or frame errors with USART?


i'm using 8E1 serial conversation on UART0 of my Atmega328p (Arduino Nano). Everything works so far.
But now i wonder how to detect framing oder parity errors on the line?
I know that hardware UART has registers for this kind of errors, but can't find any hint if and how to use it in Arduino's "Serial" instance. Furthermore it has it's own ringbuffer for incomming data. So if i query the errorflags from the UART directly, i don't know which byte was wrong.

Any hints here?


is it possible to programm the Atmega328 USART directly, using Arduino Studio, or do i have to switch to anothet IDE to do this?

I’d like to handle incomming serial data myself, for learning and operating purposes (e.g. to handle parity errors).

I’ve tried to deal with the registers directly, but it interfere with the internal Arduino libs and nothing good happens…

Don’t split your question across different Threads - it just wastes time. I have asked the Moderator to merge them.

If you study the Atmel datasheet for the Atmega 328 you will get all the data necessary to access the USART directly.


Rather than implement your own solution, why not extend the existing one?

Because i don't know how :frowning:
My programming skills are too limited for that. Therefore i asked for help...

But now i wonder how to detect framing oder parity errors on the line?

If your programming knowledge is limited maybe it is worth considering another way to deal with data errors.

Your sending code could add a check sum into the data and your Arduino program could verify that the received data matches the included check sum. If it does not, then just discard the data and request another copy from the sender.

You may find the 2nd and 3rd examples in Serial Input Basics useful.