This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

In while(1) loop, for receiving data we used UARTCharsAvail() function. but here without without typing any character in terminal window it keep on showing unknown charater. how to display the exact character that is in RX FIFO

Other Parts Discussed in Thread: TM4C123GH6PM

#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 .

  • Hi Rukmani,

    First can I ask why you used these functions with these parameters instead of macros?
    GPIOPinConfigure(0x00021801);//RX
    GPIOPinConfigure(0x00021C01);//TX


    Second, you are using the launchpad correct? How are you connecting your MCU to the computer?
  • Hello Rukmani,

    First check what is being received by the UART3 and then check what is the character map on the LCD Panel set as and what does the character mean?
    Another important thing is to check if the timings for LCD are being met by the bit-banging of the GPIOs.

    Regards
    Amit