Unit 3 UART
Unit 3 UART
RV College world
of
Engineering
Course Code:CS344AI
IOT & Embedded Computing
UART Registers..
Register Description
UxRBR Contains the recently received Data
UxTHR Contains the data to be transmitted
UxFCR FIFO Control Register
UxLCR Controls the UART frame formatting(Number of Data Bits, Stop bits)
UxDLL Least Significant Byte of the UART baud rate generator value.
UxDLM Most Significant Byte of the UART baud rate generator value.
UxLSR Line status register, used to check transmitter is free / Receiver has data
RV College
of Go, change the
Engineerin
g world
BaudRate Calculation..
RV College
of Go, change the
Engineerin
g world
void uart_init(void)
{
//configurations to use serial port, UART0
PINSEL0 |= 0x00000005; // P0.0 & P0.1 ARE CONFIGURED AS TXD0 & RXD0
//programming the baud rate
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit & DLAB = 1 */
U0DLM = 0; U0DLL = 8; // 115200 baud rate, PCLK = 15MHz
U0LCR = 0x03; /* 8 bits, no Parity, 1 Stop bit & DLAB = 0 */
}
RV College
of Go, change the
Engineerin
g world
while((ch=msg[i++])!= '\0')
{
// Wait for Previous transmission to complete
while((U0LSR & (1u<<5))== 0x00){};
// Load the data to be transmitted
U0THR= ch;
}
}
RV College
of Go, change the
Engineerin
g world