cancel
Showing results for 
Search instead for 
Did you mean: 

Receive data from usart(Asynchronous) when parity bit is set

Muzahir Hussain
Associate III
Posted on January 23, 2018 at 18:55

I am using usart1 for asynchronous communication. Microcontroller is nucleo STM32F103RB.

Here's is how I am receiving data if parity bit is not set,

char USART1_Receive()

{

    if((USART1_SR & 0x00000020) == 0)    // no data available 

        return 0;

    return USART1_DR;

}

My question is, how should I receive data if parity error occurs? How should I handle parity error?

#stm32f103rb #serial #usart
5 REPLIES 5
Posted on January 23, 2018 at 19:00

On the F1 you need to read the DR to clear the parity error, reception will be stopped until you do so.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on January 23, 2018 at 19:02

How do I request data re-transmission?

Andrew Neil
Chief II
Posted on January 23, 2018 at 21:32

ST use XModem (or is it Zmodem?) in their IAP-over-UART examples...

https://en.wikipedia.org/wiki/XMODEM

 

https://en.wikipedia.org/wiki/ZMODEM

 

http://www.rogtronics.net/files/datasheets/micro_z80/xymodem.pdf

 
Posted on January 23, 2018 at 21:10

A UART doesn't work that way, it tells you if you had a reception error (parity, framing, overrun, etc), the protocol you layer on top would need to manage errors and retransmission of data.

X-MODEM is a relatively light-weight protocol.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on January 23, 2018 at 21:50

Crude form of Y-MODEM (1K packets with CRC)

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..