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.

UART-Keypad-lcd interfacing with 8051

Status
Not open for further replies.

bobparihar

New Member
i am doing a project in which there is a serial communication between two 8051 microcontroller.
at transmitting side there is a 4x4 keypad attached at one of the port of 8051
at receiving side there is a 16x2 LCD attached
i am simulating it on Proteus first... but there is an error as soon as i start the simulation of the program..
i am unable to understand this error.. ( see the attached screenshot of protues)

help me to get rid of this error

upload_2015-2-27_17-7-22.png


this is code of transmitting side.............................


C:
#include<reg51.h>

void serial(void);
void serial(void)
{
  TMOD=0x20;        //timer 1, mode 2(8-bit autoreload) to set baud rate
TH1=0xFD;        //-3 to TH1 for 9600 baud rate
SCON=0x50;        // 8 bit txion, 1 start 1 stop bit, REN enable for both txfr and rxve
TR1=1;         // start timer
}
void trans(unsigned char);
void trans(unsigned char a)
{
  SBUF=a;
  while(TI==0);
  TI=0;

}

void main()
{

unsigned int ar[]={0xE7,0xD7,0xB7,0x77,0xEB,0xDB,0xBB,0x7B,0xED,0xDD,0xBD,0x7D,0xEE,0xDE,0xBE,0x7E};

unsigned int a,b,c,i;

    serial();
while(1)
{
       P1=0x0F;
       while(P1==0x0F);
       a=P1;
       P1=0xF0;
       b=P1;
       c=a|b;
       for(i=0;i<16;i++)
         {
           if (ar[i]==c)
           trans(i);
         }
       }
}

now this is code of receiving side.................................................

C:
#include"lcd1.h"
void main()
{
int a;
init();
TMOD=0x20;        //timer 1, mode 2(8-bit autoreload) to set baud rate
TH1=0xFD;        //-3 to TH1 for 9600 baud rate
SCON=0x50;        // 8 bit txion, 1 start 1 stop bit, REN enable for both txfr and rxve
TR1=1;         // start timer
while(1)
{
  while(RI==0);      // check if all the bytes get received
  a=SBUF;        // place sbuf in a
  num(a);
  RI=0;          // clear RI so that another byte will recive
}
}



[B]header file code for lcd..[/B]
#include<reg52.h>
sbit rs=P3^2;
sbit rw=P3^3;
sbit en=P3^4;
void dat(unsigned char);
void cmd(unsigned char);
void delay(unsigned int); 
void print(unsigned char *);
void init();
void num(unsigned int);


void init()
{
 
   cmd(0x38);
   delay(100);
   cmd(0x0E);
   delay(100);
   cmd(0x06);
   delay(100);
   cmd(0x01);
   delay(100);
   cmd(0x80);
   delay(100);


 
}

void cmd(unsigned char x)
{
  P2=x;
   rs=0;
   rw=0;
   en=1;
   delay(1);
   en=0;
}
void dat(unsigned char y)
{
   P2=y;
   rs=1;
   rw=0;
   en=1;
   delay(1);
   en=0;
}
void delay(unsigned int z)
{
  int j,i;
   for(i=0;i<z;i++)
   {
     for(j=0;j<1275;j++);
   
   }
}
void print(unsigned char *p)
{
 
   while(*p!='\0')
   {
     dat(*p);
     p++;
   }

}
void num(unsigned int a)
{
   int b,c=1;
   b=a;
   while(b>9)
   { 
     b=b/10;
 
     c=c*10;
   }
 

   while(c!=0)
   {   delay(50);
     dat((a/c)+48);
     a=a%c;
     c=c/10;
   
   }
}
 
Last edited by a moderator:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top