ss_blog_claim=726e70d7c87c20ae33aa7a61f06eb8aa

Tuesday, June 17, 2008

code snippet for LCD interfacing

code for interfacing LCD with PIC16F877A in CCS C compiler

//PIN CONFIGURATION: LCD DATA LINE(D4,D5,D6,D7) CONNECTED TO PORTD(3,4,5,6)PINS; CONTROL LINE(RS,RW,ENABLE) CONNECTED TO PORTD(0,1,2)PINS;

//THIS PROGRAM IS USED TO DISPLAY " welcome to LCD INTERFACING ";

//SEE THE FOLLOWING PROGRAM;

#include<16f877a.h> //HEADER FILE;

#use delay(clock=20000000) //CRYSTAL FREQUENCY IS 20MHZ;

#fuses HS,NOWDT,NOPROTECT,NOLVP //SETTING FUSES;

#include //LCD DRIVER FILE;

#byte portb=0x06 //SPECIFY PORTB ADDRESS;

#byte trisb=0x86

#byte portd=0x08 //SPECIFY PORTD ADDRESS;

#byte trisd=0x88

main()

{

lcd_init();

set_tris_d(0x00); //PORTD IS CONFIGURED AS A O/P;

portd=0x00;

while(1)

{

lcd_gotoxy(1,1);

printf(lcd_putc,"welcome to"); //IN 1ST ROW "welcome to";

delay_ms(3);

lcd_gotoxy(1,2);

printf(lcd_putc,"LCD INTERFACING"); //IN 2ND ROW "LCD INTERFACING";

delay_ms(3);

}

}

No comments: