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.

20*4 lcd interfacing with TM4C123Gh6PGE

Hai this is surendra.I have written the code for 20*4 LCD but it is not initialized please help me about this.

Here this is the code what i have written.port L pin 0,1,2 three belongs to rs,r/w,EN and the data ines are PORT N pn0 to pn7. 

#include <stdint.h>
#include <stdbool.h>
#include "driverlib/adc.h"
#include "inc/hw_memmap.h"
#include "driverlib/fpu.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "driverlib/pin_map.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "driverlib/gpio.h"

void tx(unsigned char *);
void lcdcmd(unsigned char );
void lcddata(unsigned char );


int main()
{

ROM_FPUEnable();

ROM_FPULazyStackingEnable();


SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);


ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);

ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

GPIOPinTypeGPIOInput(GPIO_PORTL_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2);

GPIOPinTypeGPIOOutput(GPIO_PORTN_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);

lcd_init();

}
void lcd_init()
{
lcdcmd(0x38);
SysCtlDelay(100000);
lcdcmd(0x01);
SysCtlDelay(100000);
lcdcmd(0x0E);
SysCtlDelay(100000);
lcdcmd(0x80);
SysCtlDelay(100000);
tx("suri");
}


void lcdcmd(unsigned char z)
{

GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_0 | GPIO_PIN_1 ,0x00); //rs=0,r/w=0

GPIOPinWrite(GPIO_PORTN_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, z);

GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2 ,0x04);

SysCtlDelay(100000);

GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2 ,0x00);

SysCtlDelay(100000);

GPIOPinWrite(GPIO_PORTN_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, 0);

SysCtlDelay(100000);

}

void lcddata(unsigned char x)
{


GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_0 ,0x01); //rs=1; r/w=0

GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_1 ,0x00);

GPIOPinWrite(GPIO_PORTN_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, x);

GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2 ,0x04);

SysCtlDelay(100000);

GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2 ,0x00);

SysCtlDelay(100000);

GPIOPinWrite(GPIO_PORTN_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, 0);

SysCtlDelay(100000);

}
void tx(unsigned char *m)
{
while(*m!='\0')
{
lcddata(*m);
m++;
}
}

  • Hi surendra,
    http://forum.stellarisiti.com/topic/275-very-basic-hd44780-driver-for-stellaris-launchpad/
    This link may help you.
    Regards
    Vikram
  • surendra malampati said:

    void lcdcmd(unsigned char z)
    {

    GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_0 | GPIO_PIN_1 ,0x00); //rs=0,r/w=0

    GPIOPinWrite(GPIO_PORTN_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, z);

    GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2 ,0x04);

    SysCtlDelay(100000);

     This doesn't respect setup time of RW and RS lines, so add small delay before strobing enable.

     Same for procedure writing to data.

    surendra malampati said:
    void lcd_init()
    {
    lcdcmd(0x38);

     set E strobe high then wait for reset time before to init, command 0x38 need to be sent 3 times to be sure of success and have interface set to 8 bit.

    surendra malampati said:
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);

     And this is a question: can your processor run at this speed???

     NEVER OVERCLOCK!!!!

     Is your xtal 16MHz? If so then read data sheet PLL section and see at which frequency is set and if it can run.

  • Is that program is correct.

  • I added the delays before strobe enable.Still i didn't get the data.so please help me
  • Processor CANNOT run @200MHz or higher, read PLL and how to set frequency, I assume a (SYSCTL_SYSDIV_5 for a 40MHz may be more appropriate to have processor running.... Than feeding processor @200MHz ...
    We know nothing about what are you doing and still you ask help without details.. PLEASE READ ALL FIRST STICKY ON THIS FORUM!!!!!
    and also this on necessary details:
    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/259930

    @Amit, I feel this is another post to add to sticky after last sentence of my porting issue from 129 to 123 but someone read this or we continuosly get this screaming of please help me (possibly ASAP)??? Where is gone Sue post? Can you rewrite and stick at first/second place?