Pages

Thursday, July 26, 2012

Graphical LCD interfacing with pic controller

Here is a sample code to Interface Graphical LCD to a PIC Controller


CODE

#define                KS0108
#include "LibraryHardware.h"
#include "LibraryChar.h"
#include "LibraryUniversalDisplay.h"
#include "LibraryData.h"

void pic_init(void);

void main()
{
int i,j;
pic_init();                                                                             //initialize PIC
glcd_init();                                                                          //initialize GLCD
for(;;){
                for(i=0;i<8;i++){
                                CHIP_LEFT();
                                glcd_goto(i,0,0);
                                for(j=0;j<=63;j++) glcd_write(img1[128*i+j]);
                                CHIP_RIGHT();
                                glcd_goto(i,0,0);
                                for(j=0;j<=63;j++) glcd_write(img1[128*i+j+64]);
                }
                delay(1000);

                for(i=0;i<8;i++){
                                CHIP_LEFT();
                                glcd_goto(i,0,0);
                                for(j=0;j<=63;j++) glcd_write(img2[128*i+j]);
                                CHIP_RIGHT();
                                glcd_goto(i,0,0);
                                for(j=0;j<=63;j++) glcd_write(img2[128*i+j+64]);
                }
                delay(1000);
}             
}

void pic_init(void)
{
TRISA=0b00101111;
TRISB=0b00000000;
TRISC=0b00000000;
TRISD=0b00000000;
TRISE=0b00000111;
set_digital();
PORTA=0b00010000;
PORTB=0b00000000;
PORTC=0b00000000;
PORTD=0b00000000;
PORTE=0b00000000;
}