Let's start with a program that sends and receives a single character (1 byte) serially.
Insert delay_ms(100) in the main function to make it a 100 ms cycle infinite loop.
Whether a character is input or not is checked by polling the flag USART_FLAG_RXNE of USART_GetFlagStatus() every 100ms.
When a reception is received, USART_ReceiveData() stores one character in the variable RxData.
The character stored in the variable RxData is sent by USART_SendData(). This communication is called echo back. The same character continues to be displayed every cycle (100ms) until the next character is received.
Serial communication conditions:
- Baud Rate: 9600
- Data lentgh: 8 bits
- Stopbit: 1
- Parity: None
- Flow control: None