UART detecting a mark/space parity bit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
        I'm trying to detect a UART data that uses a mark/space as parity bit, I tried the following code but it doesn't seem to work for me. temp = UART_GetChar() if(temp != 0) { If(UART_ReadRxStatus() & UART_RX_STS_MARKSPS) { while(USB_CDCIsReady() == 0); USB_PutChar('M') } else { while(USB_CDCIsReady() == 0); USB_PutChar('S') } } The usb always returns an S regardless of the parity bit and the data that is being received. The data is being received correctly though I just can't detect whether the parity bit is high or low.   
0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Did you already try UART_SpiUartReadRxData() API which returns a 32bit value. Datasheet says:

   

uint32: Next data element from the receive buffer.
The amount of data bits to be received depends on Data bits selection (the data bit counting starts from LSB of return value).

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        I figured out the problem, I can detect the parity bit but when increasing the buffer size of the UART block it all fails and I can't detect the parity bit anymore, why can't I detect it when the buffer size is higher than 4 and the internal interrupt is enabled? I still manage to get the rest of the data correctly though.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The buffer only holds byte data, no extras, no status, no 9th bit. So you'll need your own interrupt handler (which is not too difficult) to implement a circular buffer algorithm.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        Since the buffer doesn't hold any parity bits shouldn't I be able to detect the parity regardless of the buffer size?   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I don't see how to. Where to save that extra bit to?

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        All I need is to detect the parity bit and add it to the received data Basically detecting a 9 bit data but the parity seems to do me some problems   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As I already said: You need to do it yourself, a nine bit UART is something rare. Not too difficult.

   

 

   

Bob

0 Likes