Unit 3 UART
Unit 3 UART
Unit 3 UART
RV College of world
Engineering
Course Code:CS344AI
IOT & Embedded Computing
RS 232 Interface
RV College of
Engineering Go, change the world
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
Engineering Go, change the world
BaudRate Calculation..
RV College of
Engineering Go, change the 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
Engineering Go, change the 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
Engineering Go, change the world