Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

i try connected LCD with Pic18F452 but LCD not display

Status
Not open for further replies.

SeP

New Member
i try connected LCD with Pic18F452 but LCD not display.
but i can complie my code. i don't know what's wrong in my code.


here is my code

HTML:
#include<18f452.h>
#include<stdio.h>
#include<htc.h>


#define LCD_RS	RA0;
#define LCD_E  	RA1;
#define LCD_Data PORTD;

__CONFIG(1,HS);
__CONFIG(2,BORDIS & WDTDIS);
//__CONFIG(3,PBDIGITAL);
__CONFIG(4,DEBUGDIS & LVPDIS & STVRDIS);
__CONFIG(5,UNPROTECT);


void delay (int i)
{
	int x;
	for(x=0;x<i;x++);
}

void enable()
{
	RA1 = 1; //e=1;
	delay(500);
	RA1 = 0;//e=0;
	delay(500);
}

void write(char data, int add)
{
	//address locate
	RA0=0; //rs=0
	PORTD=add;
	enable();
	//write data to LCD
	RA0=1;  //rs=1
	PORTD=data;
	enable();
}

void init()
{
	//LCD 16*2
	delay(20000);
	RA0=0;
	PORTD=0x38;
	enable();
	//clear
	RA0=0;
	PORTD=0x01;
	enable();
	//cursor shift right
	RA0=0;
	PORTD=0x06;
	enable();
	//Display LCD
	RA0=0;
	PORTD=0x0c;

}
	

void main()
{
        TRISA = 0b00000000;
	TRISB = 0b11111111; 
	TRISC = 0b00000000;
	TRISD = 0b00000000;
	init();
	while(1)
	{
		write('M',0x80);
		write('A',0x81);
		write('D',0x82);
		write('-',0x83);
		write(' ',0x84);
		write('3',0x85);
		write('f',0x86);
		write('4',0x87);
		write('M',0x89);
		write('M',0x8A);
		while(1);
	}
}





Thank for your help!!~
 

Attachments

  • asas.JPG
    asas.JPG
    311.8 KB · Views: 330
  • project.c
    1.1 KB · Views: 142
Status
Not open for further replies.

Latest threads

Back
Top