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.

Atmel AT89c51 interfacing with LCD and keypad

Status
Not open for further replies.

geethanjali.ms

Newbie level 3
Newbie level 3
Joined
Oct 22, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Salem, Tamilnadu
Visit site
Activity points
1,333
#include<reg51.h>
//Function declaration
void portinit(void);
void delay(unsigned int);
void lcdinit(void);
void lcdcmd(unsigned char);
void lcddata(unsigned char);
void ready(void);
char readswitch(void);
char getkey(void);
// Pin Description
sbit ROA=P1^0;
sbit ROB=P1^1;
sbit ROC=P1^2;
sbit ROD=P1^3;
sbit c1=P1^4;
sbit c2=P1^5;
sbit c3=P1^6;
sbit c4=P1^7;
sfr value=0xA0;
sbit BU=P2^7;
sbit RS=P0^0;
sbit RW=P0^1;
sbit E=P0^2;
//Display Messages
unsigned char mess1[]="Enter PIN number";
unsigned char mess2[]="1. Transaction";
unsigned char mess3[]="2. Check Account";
unsigned char mess4[]="Invalid PIN";
unsigned char mess5[]="Invalid entry";
unsigned char mess6[]="Try Again";
unsigned char mess7[]="Your Account";
unsigned char mess8[]="balance is 5000";
unsigned char mess9[]="Wait a minute";
unsigned char mess10[]="Thank You";
unsigned char PIN1[]="12345";
unsigned char PIN2[]="67890";
unsigned char key1,key[];
// Main function
void main()
{
unsigned int l,i;
portinit();
lcdinit();
entry: for(i=0;i<16;i++)
{
lcddata(mess1);
delay(10);
}
lcdcmd(0xC0);
l=0;
start: key[l]=getkey();
//value=key[l];
lcddata(key[l]);
l++;
if(l==4)
goto end;
else
goto start;
end: for(i=0;i<5;i++)
{
if(key==PIN1 || key==PIN2);
}
if(i==4)
{
lcdinit();
trans: for(i=0;i<14;i++)
{
lcddata(mess2);
delay(10);
}
lcdcmd(0xC0);
for(i=0;i<16;i++)
{
lcddata(mess3);
delay(10);
}
}
else
{
lcdinit();
for(i=0;i<11;i++)
{
lcddata(mess4);
delay(10);
}
lcdcmd(0xC0);
for(i=0;i<9;i++)
{
lcddata(mess6);
delay(10);
}
goto entry;
}
key1=getkey();
//value=key1;
//lcdcmd(0x01);
lcdinit();
delay(10);
lcddata(key1);
if(value==1)
{
for(i=0;i<13;i++)
{
lcddata(mess9);
delay(10);
}
}
else if(value==2)
{
for(i=0;i<12;i++)
{
lcddata(mess7);
delay(10);
}
lcdcmd(0xC0);
for(i=0;i<15;i++)
{
lcddata(mess8);
delay(10);
}
delay(1500);
lcdinit();
for(i=0;i<9;i++)
{
lcddata(mess10);
delay(10);
}
}
else
{
for(i=0;i<13;i++)
{
lcddata(mess5);
delay(10);
}
lcdcmd(0xC0);
for(i=0;i<9;i++)
{
lcddata(mess6);
delay(10);
}
goto trans;
}
}
void portinit()
{
P0=0x00;
P1=0xf0;
P2=0x00;
P3=0x00;
return;
}
void lcdinit()
{
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x80);
return;
}

void lcdcmd(unsigned char cmd)
{
ready();
value=cmd;
RS=0;
RW=0;
E=1;
delay(10);
E=0;
delay(10);
return;
}
void lcddata(unsigned char dat)
{
ready();
value=dat;
RS=1;
RW=0;
E=1;
delay(10);
E=0;
delay(10);
return;
}
void ready()
{
BU=1;
RS=0;
RW=1;
back: E=0;
delay(10);
E=1;
if(BU==1)
goto back;
return;
}
void delay(unsigned int init)
{
unsigned int j,k;
for(j=0;j<init;j++)
for(k=0;k<1250;k++);
}
char readswitch()
{
ROA=0; ROB=1; ROC=1; ROD=1;
if(c1==0) { delay(10000); while(c1==0) return '7'; }
if(c2==0) { delay(10000); while(c2==0) return '8'; }
if(c3==0) { delay(10000); while(c3==0) return '9'; }
if(c4==0) {delay(10000); while(c4==0) return '/'; }
ROA=1; ROB=0; ROC=1; ROD=1;
if(c1==0) { delay(10000); while(c1==0) return '4'; }
if(c2==0) { delay(10000); while(c2==0) return '5'; }
if(c3==0) { delay(10000); while(c3==0) return '6'; }
if(c4==0) {delay(10000); while(c4==0) return 'x'; }
ROA=1; ROB=1; ROC=0; ROD=1;
if(c1==0) { delay(10000); while(c1==0) return '1'; }
if(c2==0) { delay(10000); while(c2==0) return '2'; }
if(c3==0) { delay(10000); while(c3==0) return '3'; }
if(c4==0) { delay(10000); while(c4==0) return '-'; }
ROA=1; ROB=1; ROC=1; ROD=0;
if(c1==0) { delay(10000); while(c1==0) return 'c'; }
if(c2==0) { delay(10000); while(c2==0) return '0'; }
if(c3==0) { delay(10000); while(c3==0) return '='; }
if(c4==0) { delay(10000); while(c4==0) return '+'; }
return 'n';
}
char getkey()
{
unsigned char key;
key='n';
while(key=='n')
key=readswitch();
return key;
}

I have a error for this coding:
Error C249: 'DATA' SEGMENT TOO LARGE
Can anyone help me to overcome this error?
Thank you in advance for your answers.
 

128 bytes cannot hold that much long strings. Reduce your string size or directly put these strings in function calls.

Thank you for your replies. Can you suggest me anyother microcontroller which will support these much of bytes?

- - - Updated - - -

Thank you for your reply. Can you suggest me anyother microcontroller which will support these much of bytes?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top