Help!! I could not find where i did mistakes interfacing an lcd with pic16f877a.

Status
Not open for further replies.

nirajd

Junior Member level 1
Joined
Jul 12, 2013
Messages
16
Helped
3
Reputation
6
Reaction score
3
Trophy points
3
Visit site
Activity points
154
Code:
#include <htc.h>
#define LCD_RS RD1
#define LCD_EN RD0
#define LCD_DATA PORTB


void init_io(void);
void delay(unsigned long data);
void send_config(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void send_string(const char *s);


void main(void)
{
	init_io();
	send_config(0b00001000); //off display
	send_config(0b00000001); //clear display at lcd
	send_config(0b00000010); //lcd return to home
	send_config(0b00000110); //entry mode set, cursor move right, display shift disable
	send_config(0b00001100); //display on, cursor off and cursor blink off
	send_config(0b00111000); //function set

	lcd_clr();
	lcd_goto(0);
	send_string("Welcome To");
	lcd_goto(20);
	send_string("my LCD");
	delay(2000000);
	for(;;)
	{
		}
}



void init_io(void)
{
	TRISB=0b00000000;
	TRISD=0b00000000;
	PORTB=0b00000000;
	PORTD=0b00000000;
}


void delay(unsigned long data)
{
	for(;data>0;data--);
}


void send_config(unsigned char data)
{
	LCD RS=0;
	LCD_DATA=data;
	LCD_EN=1;
	delay(50);
	LCD_EN=0;
	delay(50);
}

void send_char(unsigned char data)
{
	LCD_RS=1;
	LCD_DATA=data;
	LCD_EN=1;
	delay(10);
	LCD_EN=0;
	delay(10);
}

void lcd_goto(unsigned char data)
{
	if(data<16)
	{
		send_config(0x80+data);
	}
	else
	{
		data=data-20;
		send_config(0xc0+data);
	}
}

void lcd_clr(void)
{
	send_config(0x01);
	delay(600);
};

void send_string(const char *s)
{
	while(s&&*s) send_char(*s++);
}
 

i ammended the code,.. still not compiled. will you please attatch a simple code for interfacing the LM016L LCD with PIC16f877A written in C language. I m using hitech compiler for compilation purpose.
regards,
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…