Monday, 19 October 2015

PIC16F877A 8BIT LCD INTERFACE

#include<pic.h>
#include<htc.h>
#define __PIC16F877A_H
__CONFIG(WDTE_OFF & FOSC_HS & PWRTE_OFF & LVP_OFF & BOREN_OFF);

void delay(unsigned int i)
{
while(i--);
}
void cmd(unsigned char c)
{
PORTD=c;
PORTC=0x04;
delay(100);
PORTC=0x00;
}
void dat(unsigned char c)
{
PORTD=c;
PORTC=0x05;
delay(100);
PORTC=0x01;
}
void lcd_init()
{
cmd(0x01);
delay(100);
cmd(0x0e);
delay(100);
cmd(0x80);
delay(100);
cmd(0x38);
delay(100);
}
void string(unsigned char *p)
{
while(*p!='\0')
{
dat(*p);
p++;
}
}

void main()
{


TRISC=0x00;
TRISD=0X00;
lcd_init();
while(1)
{
string ("EMBEDDED LAB");
delay(100);
while(1);
}
}

No comments:

Post a Comment