#include<stdint.h>
#include<stdbool.h>
#include<hw_types.h>
#include<hw_memmap.h>
#include<sysctl.h>
#include<gpio.h>
#include<uart.h>
#include<tm4c123gh6pm.h>
#include<interrupt.h>
#define RS GPIO_PIN_1
#define RW GPIO_PIN_3
#define EN GPIO_PIN_2
void dly(unsigned int ms)
{
ms=(SysCtlClockGet()/3.0)*ms/1000;
SysCtlDelay(ms);
}
void lcd(unsigned char a, unsigned char b)
{
GPIOPinWrite(GPIO_PORTE_BASE, RS, a);
GPIOPinWrite(GPIO_PORTE_BASE, RW, 0);
GPIOPinWrite(GPIO_PORTB_BASE, 0xFF, b);
GPIOPinWrite(GPIO_PORTE_BASE, EN, 4);dly(2);
GPIOPinWrite(GPIO_PORTE_BASE, EN, 0);
}
void lcd_init()
{
lcd(0, 0x38);
lcd(0, 0x0E);
lcd(0, 0x01);
}
void main()
{
SysCtlClockSet(SYSCTL_SYSDIV_5| SYSCTL_USE_PLL| SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, 0xFF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, 0xFF);
SysCtlPeripheralReset(SYSCTL_PERIPH_UART3);//reset
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
GPIOPinConfigure(0x00021801);//RX
GPIOPinConfigure(0x00021C01);//TX
GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6|GPIO_PIN_7);
UARTFIFODisable(UART3_BASE);
UARTClockSourceSet(UART3_BASE,UART_CLOCK_SYSTEM);
UARTConfigSetExpClk(UART3_BASE, SysCtlClockGet(), 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));
UARTEnable(UART3_BASE);
lcd_init(); dly(100);
UARTFIFOEnable(UART3_BASE);
UARTCharPut(UART3_BASE, 'E');
while(1)
{
if(UARTCharsAvail(UART3_BASE)) {lcd(0,0xC0); char a=UARTCharGet(UART3_BASE); dly(10); lcd(2,a);}
//else if(!UARTCharsAvail(UART3_BASE)) {lcd(0,0x80); lcd(2,'Y');}// without receiving a single character it returns true and execute if condition
//lcd(2,UARTCharGet(UART3_BASE));
}
}
here i have attached my output .