Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD 4-bits Interface to AT89C51

Status
Not open for further replies.

leileicats

Newbie level 3
Joined
May 31, 2007
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
anupam dubey lcd

Anyone can help to check my coding?
I'm using S6A0069 driver base 16*2 Lumex LCM.

I refer to some program on the website and make some modification. But there is nothing displayed on my LCD screen. This staff is driving me crazy. I'm not sure whether it is the problem of my hardware or software?

My interface setting:
RS -> P2.6
RW -> P2.5
EN -> P2.4
DB04 -> P2.0
DB05 -> P2.1
DB06 -> P2.2
DB07 -> P2.3

Thanks a lot!
 

anupam dubey aims interactive

this code is using in the LCM driver by 44780 ,if your LCD is not driver by HD44780,then you should modify some code,refer to the datasheet of your LCM.
the Initial code is very important,and maybe it is different if your different typr LCD.
 

lcd 4 bits

try this code it works fine, just change the port setting and include files it orks in keil and sdcc,

// RS - bit0
// RD - bit1
// EN - bit2
// --- bit3
// D4 - bit4--P1_4
// D5 - bit5--P1_5

// D6 - bit6 P1_6
// D7 - bit7 P1_7



#include<at89x051.h>
#include<stdio.h>
#include<string.h>
#define LCDPORT P1
#define RS P1_0;
#define RW P1_1;
#define E P1_2;
bit status=0;
#define lcd_delay 100
void delay(unsigned int j)
{
unsigned int i,k;
for(i=0;i<j;i++)
{
for(k=0;k<50;k++);
}
}


void _lcd_init_write(unsigned char a)
{
P1_0 = 0;
P1_1 = 0;
LCDPORT=a;
P1_2=1;
delay(lcd_delay);
P1_2=0;
}





void lcd_com(unsigned char a){
unsigned char temp;
if(status){
status=0;
goto ___next123321;
}
P1_0=0;
___next123321:
P1_1=0;
temp=a;
temp&=0xF0;
LCDPORT&=0x0F;
LCDPORT|=temp;
P1_2=1;
delay(lcd_delay);
P1_2=0;
temp=a<<4;
temp&=0xF0;
P1&=0x0F;
P1|=temp;
P1_2=1;
delay(lcd_delay);
P1_2=0;
}

void lcd_data(unsigned char a){
status=1;
P1_0=1;
lcd_com(a);
}



void lcd_init(void){
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x30);
delay(lcd_delay);
_lcd_init_write(0x20);
delay(lcd_delay);
lcd_com(0x28);
delay(lcd_delay);
lcd_com(4);
delay(lcd_delay);
lcd_com(0x85);
delay(lcd_delay);
lcd_com(6);
delay(lcd_delay);
lcd_com(1);
delay(lcd_delay);
}


void lcd_puts(char *aaa){
unsigned int i=0;
for(;aaa!=0;i++)lcd_data(aaa);
}







void main(){
lcd_init();
lcd_com(0X0C);
lcd_com(0X80);
delay(4000);
delay(4000);
delay(4000);
lcd_puts("Anupam Dubey");
lcd_com(0XC0);
lcd_puts("Aims Interactive");

delay(4000);
delay(4000);
delay(4000);
while(1)
{
lcd_com(0X18);
delay(2000);
lcd_com(0X18);
delay(2000);
lcd_com(0X18);
delay(2000);
lcd_com(0X18);
delay(2000);
lcd_com(0X18);
delay(2000);
lcd_com(0X1C);
delay(2000);
lcd_com(0X1C);
delay(2000);
lcd_com(0X1C);
delay(2000);
lcd_com(0X1C);
delay(2000);
lcd_com(0X1C);
delay(2000);
}
}
 

lcd 4 bit keil c at89c51

Sorry, I'm using the Keil to compile:
can't open 'at89051.h';
'P1','P1_0','P1_2': undefined identifier

What's the problem with that?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top