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.

LCD 12864 interface with TM4C1294 Launchpad

Other Parts Discussed in Thread: TM4C1294NCPDT

Hi Everyone !

I have re-wrote the code as per guidelines for LCD 12864B with TM4C Launchpad, but still nothing is being written to LCD, I do not know, what's wrong with the code

I am pasting my code , please help me .

I have connected many other devices and sensors with Launchpad, so just few GPIO pins left, that's why I am unable to use consecutive pins for LCD, I have to manage the interfacing with these pins as instructed. please help  me to debug with it.

LCD controller is ST7920. If anyone have already used this LCD , please let me know some sample code for it that help me identify my mistakes and misunderstandings as well.

following is link to lcd controller datasheet:


#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 with 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);

//Reset low to high delay
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_6,0);
//PSB- PARALLEL
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_3,1);
delay(4800000);
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_6,1);

//function set
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB0,DB1
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_1,0);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0);//DB3
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4,1);//DB4
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_5,1);//DB5
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB6, DB7
//RS/RW
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//RS|RW
//EN
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);
delay(16800);
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);

delay(12000);
//display-on-Off
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB0,DB1
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_0,0);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,1);//DB3
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB4&DB5
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB6, DB7
//rs-rw
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0);
//en
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);
SysCtlDelay(12000);
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);

SysCtlDelay(12000);
//display clear

GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,1);//DB0
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,0);//DB1
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_0,0);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0);//DB3
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB4&DB5
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB6, DB7
//RS-R/W
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0);
//EN
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);
delay(1200000);
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);

SysCtlDelay(1200000);

//ENTRY-MODE-SET
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,1);//DB0
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,1);//DB1
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_0,1);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0);//DB3
GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB4&DB5
GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_4|GPIO_PIN_5,0);//DB6, DB7
//RS-R/W
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_5,0);
//EN
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);
SysCtlDelay(2000000);
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);

SysCtlDelay(1200000);
//WRITING 0x41 "A" to DATA-bus DB0-DB7
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_4,1);//DB0
GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0);//DB1
GPIOPinWrite(GPIO_PORTH_BASE,GPIO_PIN_0,0);//DB2
GPIOPinWrite(GPIO_PORTM_BASE,GPIO_PIN_4,0);//DB3
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
//RS-R/W
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_4,1);//RS
GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_5,0);//R/W
//EN
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,0);
SysCtlDelay(12000);
GPIOPinWrite(GPIO_PORTK_BASE,GPIO_PIN_2,1);

while(1){
 GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,1);
 delay(period/2);
 GPIOPinWrite(GPIO_PORTN_BASE,GPIO_PIN_0,0);
 delay(period/2);
}

}

//delay function for accurate delay-
void delay(uint32_t num){

 TimerIntClear(TIMER0_BASE,TIMER_TIMA_TIMEOUT);
  TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
    TimerLoadSet(TIMER0_BASE,TIMER_A,num-1);

 TimerEnable(TIMER0_BASE, TIMER_A);
 while(!TimerIntStatus(TIMER0_BASE,false)){

 }




Thanks a lot for all of you .
Regards
Haroon