Hello everyone!
How can I read the value of parity bit (ninth) in 8E1 serial mode (Arduino Due) of last received byte?
Thanks in advance!
Hello everyone!
How can I read the value of parity bit (ninth) in 8E1 serial mode (Arduino Due) of last received byte?
Thanks in advance!
How can I read the value of parity bit (ninth) in 8E1 serial mode (Arduino Due) of last received byte?
AFAIK you cannot read it but if the hardware doesn't return a parity error you can calculate the parity bit yourself, expect it to be correct. If you get an error from the hardware, the parity bit was wrong but you won't see the byte it received.
pylon:
AFAIK you cannot read it but if the hardware doesn't return a parity error you can calculate the parity bit yourself, expect it to be correct. If you get an error from the hardware, the parity bit was wrong but you won't see the byte it received.
Thank you for your answer! Actually I have the next question - how to read a parity error from hardware? What is the exact syntax of reading this using USART?
Thanks in advance!
You can get the information of a parity error with US_MR:
Page 827: US_MR (DSNACK/MAX_ITERATION)
E.g.: USART1->US_MR |= US_MR_DSNACK | US_MR_MAX_ITERATION(3);
You can poll US_CSR for PARE bit (page 837)
Or/and US_IER of USART peripheral:
Page 831: US_IER (PARE)
USART1->US_IER = US_IER_PARE; //Set interruption bit when a parity error occurs
NVIC_EnableIRQ(USART1__IRQn); // Enable interruption
void USART1_Handler()
{
.......................
}
ard_newbie:
Page 827:
.
.
Page 831:
It would probably be helpful if you specified "Page 827" of what? A clickable link would be even better.
It's obvious: datasheet.