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.

LCD12864 interfacing to TM4C1294

Other Parts Discussed in Thread: TM4C1294NCPDT, EK-TM4C1294XL

Hi everybody !

I wanna interface LCD 12864 with my launch pad, i am trying to interfacing, but something wrong with my code , could you please me to compile making operational with LCD. i am new with Tiva C Series Micros.

Here is my code:

//*****************************************************************************
//
// blinky.c - Simple example to blink the on-board LED.
//
// Copyright (c) 2013-2015 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 2.1.1.71 of the EK-TM4C1294XL Firmware Package.
//
//*****************************************************************************

#include <stdint.h>
#include "inc/tm4c1294ncpdt.h"
#include <stdbool.h>
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include"inc/hw_types.h"
#include"inc/hw_memmap.h"
#include"driverlib/timer.h"
#include"driverlib/interrupt.h"
#include"driverlib/systick.h"

//*****************************************************************************
volatile uint32_t period,SysClk;

void delay(void);
int
   main(void)
{
//port intialization
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);


//DATA-SIGNALS
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_5);//DB0,DB1
GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE,GPIO_PIN_1);//DB2
GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE,GPIO_PIN_4);//DB3
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5);//DB4&DB5
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5);//DB6, DB7

//CONTROL-SIGNALS
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5);//RS,R/W
GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE,GPIO_PIN_2);//EN

delay();

GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4,0);//RS
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5,0);//R/W
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);//EN
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0);//DB3					//Function Set 0x30 to Data-bus
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB0,DB1
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5,1);//DB4&DB5
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB6, DB7

delay();

GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);//EN						//low to high pulse

delay();




GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4,0);//RS
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5,1);//R/W


delay();
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);//EN

GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0);//DB3
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,1);//DB0,							//0x41 sent to data
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0);//DB1
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB4&DB5
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,1);//DB6,
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0);//DB7

delay();

GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4,1);//RS

GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);//EN

delay();

GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4,1);//RS

GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);//EN
}




void delay(void){
	SysClk=SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_CFG_VCO_480),
					  	  	  	  	  	  	  	  	  	  	  	  	  	 120000000);
	 SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);

 TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
  TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
  period=SysClk/2;
  TimerLoadSet(TIMER0_BASE,TIMER_A,period-1);
 //TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
 TimerEnable(TIMER0_BASE, TIMER_A);
 while(!TimerIntStatus(TIMER0_BASE,false)){
	}

}











ST7920.pdf
 i have also attached the lcd data sheet for reference , please.

 

thanks in advance

  • Hi,

    My strong suggestion for your code here is to re-write it from the beginning, but with more care and more organised - if you like to use a parallel port for LCD data, 4 or 8 bits, use consecutive bit numbers for port, corresponding to bit position into registers (i.e. use B7-B4 connected to D7-D4 on LCD, or a full port B7-B0 connected to full LCD data, D7-D0 - other wise you will spend more execution time with bit changing (B5 instead B4 and vice-versa) and debugging.

    Also, use the delay function provided in driverlib, instead of yours, since every time you call that function you also change/re-program the CPU clock. Same for timer. Use separated initialisation instruction, do not call them repeatedly.

    Useful also to search the internet for similar routine, there are plenty, understand one/several such postings and then try to write your own.

  • Hi Petrei,

    Poster is using a much newer LCD Controller (ST7920) than the ones you/I used in the past. And this one is superior - and may not share (all) of the (past) code "floating" w/in the net.

    We're told, "Something is wrong" by poster - but minus any needed specifics. (Poster is unguided - vendor believes "total lack of guidance works!" (might "something be wrong" w/vendor's (locked) belief?)

    Usually such displays include a contrast pin and that pin must be tied - or adjusted - as directed by the display's spec. Poster has supplied the controller spec - but not the display vendor's spec...
  • Haroon,

    As noted in the duplicate thread you created where you uploaded new code, it might be worth doing a search of the E2E for similar issues experienced by other users. Notably, this is a thread almost identical to your problem description: e2e.ti.com/.../1821571

    Also, for those that have already replied to Haroon, he has posted new/updated code in this thread, e2e.ti.com/.../1845345, that I have closed in part since it is a duplication of the topic and also since there has already been support offered in this thread which I do not want to lose.
  • Hi,

    Check your hardware - you have some pin(s) dedicated to configuration of your interface(8bits/4bits/serial) which must be set prior any software action. If you do not have enough pins, either look for a micro with more pins, either use 4 bits instead of 8 or even search internet for additional info about the serial interface (2 pins).

    Do not spread eight data bits over multiple independent pins - while for some commands you may write bit by bit, when you will need to write characters, you need a special function to split and distribute every bit of a character over different ports bits. This will increase the time to display something and may give you a flickering display.

    Also, pages 48 and 48 you your data sheet have a diagram of initialization sequence - read and respect that to have the display started. Write corresponding actions.

    Check also the hardware for mistakes,do not forget contrast adjustment, as suggested by cb1.

  • Hi Petrei !
    I have followed the diagram of initialization sequence given on page 28 for 8-bit interface : but still i am unable to get anything printed on LCD , please have a look my code that i wrote very according to manual instructions.
    The hardwrae is is ok.
    I have also connected all pins including contrast suggested by cb-1.
    i have also searched on google as well as looked on the other e2e posts regrading my problem, please help me to sort out that either i am coding wrong or where is problem if my hardware is ok.
    on internet , i have not found any sample code written for TM4C .
    here is my latest and updated code for LCD 12864 V2.0

    #include <stdint.h>
    #include "inc/tm4c1294ncpdt.h"#include <stdbool.h>
    #include "driverlib/sysctl.h"#include "driverlib/gpio.h"#include"inc/hw_types.h"
    #include"inc/hw_memmap.h"#include"driverlib/timer.h"
    #include"driverlib/interrupt.h"#include"driverlib/systick.h"
    #include "driverlib/rom.h"#include "driverlib/rom_map.h"
    //*****************************************************************************
    void delay(uint32_t num);volatile unsigned long long int clock,period;int
    main(void){//Clock Set
    clock=SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000);


    //Port Initialization-Used many ports, beacuse few pins left, i have not left any free
    //conscutive pins to connect with lcd, rest of all pins connected with sensors and other devices


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_0);period=clock;
    //Port Initialization-Used many ports, beacuse few pins left, i have not left any free
    //conscutive pins to connect witJh lcd, rest of all pins connected with sensors and other devices


    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

    //DATA-SIGNALS
    GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_5);//DB0,DB1
    GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE,GPIO_PIN_1);//DB2
    GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE,GPIO_PIN_4);//DB3
    GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5);//DB4&DB5
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5);//DB6, DB7

    //CONTROL-SIGNALS RS, R/W AND EN


    GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5);//RS,R/W
    GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE,GPIO_PIN_2);//EN//RESET-RST
    GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE,GPIO_PIN_6);//PSB
    GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE,GPIO_PIN_3);

    delay(12000);

    //PSB- PARALLEL
    GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_3,0x8);delay(4800000);//Reset Low-to-High
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_6,0x40);


    delay(4800000); //40-milisecond delay


    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_6,0x0)

    ;//FUNCTION SET
    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0x00);
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0x0);//DB0
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0x0);//DB1
    GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0x0);//DB2
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0x0);//DB3
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,0x10);//DB4
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,0x20);//DB5
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,0x0);//DB6
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0x0);//DB7


    delay(12000); //100-micro-second-delay


    //Again function-Set command according to manual page no-28


    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0x00);
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0x0);//DB0
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0x0);//DB1
    GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0x0);//DB2
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0x0);//DB3
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,0x10);//DB4
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,0x20);//DB5
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,0x0);//DB6
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0x0);//DB7

    delay(4800); //37-micro-second-delay//display on-off

    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0x00);
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0x0);//DB0
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0x0);//DB1
    GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0x0);//DB2
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0x10);//DB3
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,0x0);//DB4
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,0x0);//DB5
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,0x0);//DB6
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0x0);//DB7


    delay(12000); //100-micro-second-delay//display clear


    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0x00);
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0x10);//DB0
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0x0);//DB1
    GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0x0);//DB2
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0x0);//DB3
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,0x0);//DB4
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,0x0);//DB5
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,0x0);//DB6
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0x0);//DB7


    delay(1200000); //10-milliseond-delay//entry-mode


    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0x00);
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0x10);//DB0
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0x20);//DB1
    GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0x2);//DB2
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0x0);//DB3
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,0x0);//DB4
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,0x0);//DB5
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,0x0);//DB6
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0x0);//DB7


    delay(12000); //100-micro-second-delay//datawrite


    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4,0x10);//RS
    GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5,0x00);//R/W
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0x10);//DB0
    GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0x00);//DB1
    GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0x0);//DB2
    GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0x0);//DB3
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,0x0);//DB4
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,0x0);//DB5
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4,0x10);//DB6
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_5,0x0);//DB7

    delay(12000);

    while(1){
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,1); delay(period/2);
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,0); delay(period/2);}}
    void delay(uint32_t num){ TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
    TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
    TimerLoadSet(TIMER0_BASE,TIMER_A,num-1);
    // TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    TimerEnable(TIMER0_BASE, TIMER_A); while(!TimerIntStatus(TIMER0_BASE,false)){ }
    }

  • Hi,

    You do not read carefully the data sheet - every command should be as: a) set RS, RW as needed; b) set  Enable; c) write data; d) clear Enable pin.

    See also this site:  www.usedbytes.com/software/lcd_lib/ for an example how to organize and write lcd software. (Cannot insert link).

    Do not know if it is the best one, but it is a good starting point. Try to understand first, then apply specifics to your display.

  • Hello Petrei !

    i have updated my code but still my code is not working with my LCD 12864 , please let me know , whether my delay
    function is not working or what is wrong with my code . please highlight my faults. I am screwed up in writing the code for this simple LCD and
    please help me at least make me confirm my code is ok according to my lcd 1286 parameters like function set and timmings.

    here is my updated code

    // This is part of revision 2.1.1.71 of the EK-TM4C1294XL Firmware Package.
    //
    //*****************************************************************************

    #include <stdint.h>
    #include "inc/tm4c1294ncpdt.h"
    #include <stdbool.h>
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include"inc/hw_types.h"
    #include"inc/hw_memmap.h"
    #include"driverlib/timer.h"
    #include"driverlib/interrupt.h"
    #include"driverlib/systick.h"
    #include "driverlib/rom.h"
    #include "driverlib/rom_map.h"





    //*****************************************************************************
    #define LCD_data GPIOPinTypeGPIOOutput(GPIO_PORTK_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)

    #define LCD_RS GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE,GPIO_PIN_0)
    #define LCD_RW GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE,GPIO_PIN_1)
    #define LCD_EN GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE,GPIO_PIN_2)
    #define LCD_RST GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE,GPIO_PIN_3)
    #define LCD_PSB GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE,GPIO_PIN_4)
    #define LCD_RS_H GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_0,0x1)
    #define LCD_RS_L GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_0,0x00)
    #define LCD_RW_H GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_1,0x2)
    #define LCD_RW_L GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_1,0x00)
    #define LCD_EN_H GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2,0x4)
    #define LCD_EN_L GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_2,0x00)
    #define LCD_RST_EN GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_3,0x8)
    #define LCD_RST_No GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_3,0x00)
    #define LCD_PSB_EN GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_4,0x10)
    #define LCD_PSB_No GPIOPinWrite(GPIO_PORTL_BASE,GPIO_PIN_4,0x00)




    void LCDInit(void);
    void LCDWriteData();
    //void LCDWriteCommand(char dispcmd);
    void delay(uint32_t num);





    volatile unsigned long long int clock,period;
    int
    main(void)
    {

    clock=SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL
    |SYSCTL_CFG_VCO_480), 120000000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_0);
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,1);

    LCDInit();

    while(1){

    delay(12000);
    LCDWriteData();
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,0);
    delay(clock);
    GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,1);
    delay(clock);
    }



    }
    void delay(uint32_t num){

    TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
    TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
    TimerLoadSet(TIMER0_BASE,TIMER_A,num-1);
    //TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    TimerEnable(TIMER0_BASE, TIMER_A);
    while(!TimerIntStatus(TIMER0_BASE,false)){

    }

    }


    void LCDWriteData(){

    LCD_PSB_EN;
    LCD_RST_EN;
    LCD_RS_H;
    LCD_RW_L;

    LCD_data;

    GPIOPinWrite(GPIO_PORTK_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,0x67);
    LCD_EN_H;
    delay(12000);
    LCD_EN_L;
    delay(12000);


    }

    void LCDInit(void){
    //Reset
    LCD_RST_No;
    delay(4800000);
    LCD_RST_No;

    //function-set

    LCD_data;
    LCD_RST_EN;
    LCD_PSB_EN;
    LCD_EN_L;
    LCD_RS_L;
    LCD_RW_L;


    GPIOPinWrite(GPIO_PORTK_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,0x30);
    delay(12000);
    LCD_EN_H;
    delay(12000);
    LCD_EN_L;
    delay(12000);
    /////////////////////////////////////////////////////////////////////////
    LCD_EN_L;
    LCD_RS_L;
    LCD_RW_L;

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

    delay(12000);
    LCD_EN_H;
    delay(12000);
    LCD_EN_L;
    delay(12000);
    /////////////////////////////////////////////////////////////////////////////
    //display-on-off
    LCD_EN_L;
    LCD_RS_L;
    LCD_RW_L;

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


    delay(12000);
    LCD_EN_H;
    delay(12000);
    LCD_EN_L;
    delay(12000);

    /////////////////////////////////////////////////////////////////////////////////
    //display-clear
    LCD_EN_L;
    LCD_RS_L;
    LCD_RW_L;


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

    delay(1200000);
    LCD_EN_H;
    delay(1200000);
    LCD_EN_L;
    delay(1200000);
    ////////////////////////////////////////////////////////////////////////////////
    //display-clear
    LCD_EN_L;
    LCD_RS_L;
    LCD_RW_L;


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

    delay(12000);
    LCD_EN_H;
    delay(12000);
    LCD_EN_L;
    delay(1200000);


    }



    Please verfiy above code


    Regards
    HaroonAhmed
  • Have you actually verified that every signal line from a GPIO pin is connected  to the correct pin on the LCD display ?

    Have you actually verified that every signal transition can be seen on the LCD pins - as close to the LCD as possible, with proper levels, and matching the signal specification in the LCD datasheet ? You can single-step through your init code, and use a simple voltmeter for measurement.

    But as long as you have not verified your hardware, any software efforts are most probably moot.

  • Thanks for reply f.m !

    Yeah, i have verified the signal transitions on the pins of LCD, signals are Ok. have you found any bug in my software ?



    Regards
    haroon
  • Just wanted to make sure you don't try the third step before the first ...

    have you found any bug in my software ?

    I don't have such a display, so it would not be very effective to read through dry code. Have done it with other displays, though.

    The second step is (IMHO) to verify the correctness of the hardware access routines. Other graphics chips have ID registers - reading them out correctly would be a way. Skimming over the datasheet of your LCD driver, he doesn't seem to have one. Perhaps writing to a GRAM cell and reading back/comparing would do.

    And if you have a scope/logic analyzer, comparing your measured waveforms to the datasheet is better than a voltmeter.

    I think you are already aware of the long startup delays required by those graphics drivers.