Interfacing GLCD using PIC16F873A

Thread Starter

abhaynayak

Joined Jul 2, 2012
1
Hey,
I am trying to interface GLCD 128*64(JHD12864E) using PIC16F873A. But I am not getting any display. Can anyone please point out my error.
Thank you.

#include <htc.h>
#define _XTAL_FREQ 20000000
#define data PORTC
#define RS RB0
#define RW RB1
#define EN RB2
#define CS1 RB3
#define CS2 RB4
#define RST RB5

void wrdata(unsigned char wr)
{
RS = 1;
RW = 0;
data = wr;
EN = 1;
__delay_ms(100);
EN = 0;
__delay_ms(100);
}

void wrcom(unsigned char cmd)
{
RS = 0;
RW = 0;
data = cmd;
EN = 1;
__delay_ms(100);
EN = 0;
__delay_ms(100);
}
void init()
{
RS = 0; //reset everything
RW = 0; //
EN = 0; //
CS1 = 0; //
CS2 = 0; //
__delay_ms(100);
CS1 = 1; //Activate both the chips
CS2 = 1;
//RST = 1;
wrcom(0x3F); //Display ON
CS1 = 1; //Activate the left chip
CS2 = 0;
wrcom(0x40); //Set Y adress
wrcom(0xB8); //Set X adress
wrcom(0xC0); //Set Display start line
}
void main()
{
unsigned int i;
TRISC = 0;
TRISB = 0;
init();
while(1)
{
while(i<64) //i<64, i.e. only left half is used
{
wrdata(0xF0); //write data pattern
__delay_ms(100);
i++;
}
i = 0;
}
}
/*I just wanted to use the left chip and display something, but i'm not getting any display.*/
 

ErnieM

Joined Apr 24, 2011
8,377
I believe it needs to be reset once via the (not) RST line, at least that's what I did when I ran one of these things. Bring it low then high.

Also your clock pulses are very long (100 mS), but I assume you're doing that for debugging.
 
Top