Let's begin with writing the main.c , msp.c, it.c from scratch to write hello-world using USART2.
Peripheral is collective name Uni Sync Asynch Receiver Transmitter but we use it in Asynch mode.
Introduction: It is just a piece of hardware (pins on micro-controller) that converts Parallel data into Serial Data.
It is used in conjunction with protocols like RS-232, RS-434, USB, etc.
In synchronous mode, the clock is sent separately and for asynchronous, it is not. Rather, start and stop bits are sent.
The communication is pretty sophisticated. The Request-To-Send (RTS) of one device is connected to Clear-To-Send (CTS) of another device. Whenever, the device 1 wants to reques the device 2 to send data, it makes its RTS low, so that the device-2 Tx is on.
Different protocols have their different frame formats ( TCP, UDP, etc). The UART packet format is as follows.
Although connected to APB1 and APB2 bus. If the controller is powered by 16 MHz RC Oscillator, then it will get only 16 MHz. (Max it will get is bus max).
The Transmit data register (TDR) is filled by the software. The shift register is loaded only when the stop bit is received from the last payload. The protocol
This is very interesting. It is same as transmitter till 5th.
6. If RXNE bit is set, it means the Frame1 is completely loaded in the shift register and can be read by the software into Receive Data Register (RDR).
7. The RXNE bit should be cleared on every complete RDR reception.
Instead of polling the Receive shift register, we can generate an interrupt for RXNE flag. The RX line keeps sampling the receiver line even when data is not there. We can some power over here by disabling the UART Rx after complete data reception.