#include #include #include "tm4c123gh6pm.h" void UART7_init(void); void UART7_write(char data); char UART7_read(void); void PortE_init(void); void LED_Control(char); int main(void) { char recievedchar; UART7_init(); // UART 7 Initialization PortE_Init(); // PORT E Initialization while(1) { recievedchar = UART7_read(); // Read a character from the UART UART0_Write(receivedChar); // Give the character back to UART LED_Control(receivedChar); // LED Control based on UART input } } void UART7_init(void) { SYSCTL_RCGCUART_R |= 0x80; // Enable clock to UART7 SYSCTL_RCGCGPIO_R |= 0x10 // Enable clock to Port E for UART7 // UART7 TX/RX on PE1/PE0 GPIO_PORTE_AFSEL_R |= 0x03; // Enable alt function on PE0, PE1 GPIO_PORTE_DEN_R |= 0x03; // Enable digital on PE0, PE1 GPIO_PORTE_PCTL_R |= 0x11; // Configure PE0 and PE1 for UART GPIO_PORTE_AMSEL_R &= ~0x03; // Disable analog on PE0, PE1 // UART7 initialization UART0_CTL_R &= ~0x01; // Disable UART0 UART0_IBRD_R = 104; // Baud rate = 9600, Integer Baud Rate Divisor UART0_FBRD_R = 11; // Fractional Baud Rate Divisor UART0_LCRH_R = 0x70; // 8-bit, no parity, 1-stop bit, enable FIFOs UART0_CTL_R |= 0x301; // Enable UART0, TX, RX } char UART0_Read(void) { while((UART0_FR_R & 0x10) != 0); // Wait until RXFE is 0 (receive FIFO not empty) return UART0_DR_R & 0xFF; // Read the received character } void UART0_Write(char data) { while((UART0_FR_R & 0x20) != 0); // Wait until TXFF is 0 (transmit FIFO not full) UART0_DR_R = data; // Transmit the data }