hi,
I want to interface JHD204A LCD to my controller(TM4C123GH6PGE). LCD is of 5x8 dots. I configured this LCD with my controller using parallel communication with 8-bit data. After i given power i'm getting block boxes in fisrt and third lines. Sometimes i got cursor at first line. could plese tell me what was the problem with my code. I posted code below.
int
main(void)
{
ROM_FPULazyStackingEnable();
//
// Set the system clock to run at 50MHz from the PLL
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
////////////////////////////////////////////////////// DATA PINS ///////////////////////////////////////////////////////////////////////
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_0);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_1);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_2);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_3);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_4);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_5);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_6);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_7);
////////////////////////////////////////////////////OTHER PINS /////////////////////////////////////////////////////////////////////////////////
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_0); //RS
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_1); //R/W
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_2); //En
lcdinit();
commandsend(0x01);
commandsend(0x80);
datastring("hello");
commandsend(0xC0);
datastring(" world");
commandsend(0x80);
while(1)
{
}
}
void lcdinit()
{
commandsend(0x38);
commandsend(0x38);
commandsend(0x38);
commandsend(0x06);
commandsend(0x0F);
//commandsend(0x0E);
commandsend(0x01);
commandsend(0x80); //80
}
void commandsend(unsigned char a)
{
char temp;
//higher nibble
ch=a;
temp=a;
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_2,0X00);
GPIOPinWrite(GPIO_PORTJ_BASE,GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , a);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_0,0X00); //rs=0;
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_1,0X00); //r/w
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_2,0X04); //en=1
SysCtlDelay(100000);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_2,0X00); //en=0
SysCtlDelay(100000);
}
void datasend(unsigned char a)
{
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_2,0X00);
GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , a);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_0,0X01); //rs=1;
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_1,0X00); //r/w
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_2,0X04); //en=1
SysCtlDelay(100000);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_2,0X00); //en=0
SysCtlDelay(100000);
}
void datastring(unsigned char *str)
{
while(*str)
{
datasend(*(str++));
commandsend(0x0C);
}
}