EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / i m making project for digital clk with digi calendar,can any1 please tell me the difference btwn AT89C51 and 52?????????

i m making project for digital clk with digi calendar,can any1 please tell me the difference btwn AT89C51 and 52?????????

|

Projects › Projects › i m making project for digital clk with digi calendar,can any1 please tell me the difference btwn AT89C51 and 52?????????

  • This topic has 1 reply, 2 voices, and was last updated 14 years, 6 months ago by neha sharma.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 16, 2011 at 11:19 am #1319
    Rahul
    Participant

    please tell me also whether the code is correct or not….:-(…much needed…pls heLp

     

     

    PROGRAM
    #include <stdio.h>
    #include<reg51.h>
    #include <absacc.h>
    #define COL P3
    #define ROW P1
    sbit rs=P1^5;
    sbit rw=P1^6;
    sbit en=P1^7;
    #define ldata P2
    void lcdinit();
    void rtcinit();
    void lcddata(unsigned char);
    void lcdcmd(unsigned char);
    void lcddelay(int);
    void lcdoption();
    void lcdhr();
    void lcdmin();
    void lcdmonth();
    void lcdday();
    char KEYPD();
    void bcdconv(unsigned char);
    unsigned char keypad[4][4]={‘0’, ‘1’, ‘2’, ‘3’,4′, ‘5’, ‘6’, ‘7’, ‘8’,
    ‘9’, ‘A’, ‘B’,’C’, ‘D’, ‘E’, ‘F’};
    void rtcinit(void)
    { lcddelay(250);
    XBYTE[10]=0x20;
    XBYTE[11]=0x83;
    XBYTE[0]=0x30; //sec
    XBYTE[2]=0x30; //min
    XBYTE[4]=0x13; //hour
    XBYTE[7]=0x27;
    XBYTE[8]=0x02;
    XBYTE[9]=0x08;
    XBYTE[11]=0x03;
    }
     
    void bcdconv(unsigned char mybyte)
    {
    unsigned char x,y;
    x=mybyte & 0x0F;
    x=x|0x30;
    y=mybyte&0xF0;
    y=y>>4;
    y=y|0x30;
    lcddata(y);
    lcddata(x);
    }
    void lcddelay(int k)
    { int i,j;
    for (i=0; i<=k;i++)
    for (j=0; j<=1275;j++);
    }
    void lcdcmd(unsigned char value)
    { ldata=value;
    rs=0;
    rw=0;
    en=1;
    lcdelay(1);
    en=0;
    return;
    }
    void lcddata(unsigned char value)
    { ldata=value;
    rs=1;
    rw=0;
    en=1;
    lcddelay(1);
    en=0;
    return;
    }
    void lcdinit()
    { lcdcmd(0x38);
    lcdcmd(0x0E);
    lcdcmd(0x01);
    lcdcmd(0x06);
    lcdcmd(0x80);
    }
    void lcdoption()
    { lcddata(‘1’);
    lcddata(‘:’);
    lcddata(‘2’);
    lcddata(‘:’);
    lcddata(‘3’);
    lcddata(‘ ‘);
    lcddata(‘:’);
    }
    void lcdhr()
    { lcddata(‘E’);
    lcddata(‘N’);
    lcddata(‘T’);
    lcddata(‘ ‘);
    lcddata(‘H’);
    lcddata(‘R’);
    lcddata(‘:’);
    }
    void lcdmin()
    { lcddata(‘ ‘);
    lcddata(‘E’);
    lcddata(‘N’);
    lcddata(‘T’);
    lcddata(‘ ‘);
    lcddata(‘M’);
    lcddata(‘I’);
    lcddata(‘N’);
    lcddata(‘:’);
    }
    void lcdmonth()
    { lcddata(‘E’);
    lcddata(‘N’);
    lcddata(‘T’);
    lcddata(‘ ‘);
    lcddata(‘m’);
    lcddata(‘o’);
    lcddata(‘n’);
    lcddata(‘:’);
    }
    void lcdday()
    { lcddata(‘E’);
    lcddata(‘N’);
    lcddata(‘T’);
    lcddata(‘ ‘);
    lcddata(‘d’);
    lcddata(‘a’);
    lcddata(‘y’);
    lcddata(‘:’);
    }
    char KEYPD()
    {
    char colloc, rowloc;
    COL=0xFF;
    while(1)
    {
    do
    {
    ROW=0x00;
    colloc=COL;
    colloc&=0x0F;
    }
    while(colloc!=0x0F);
    do
    {
    do
    { lcddelay(1);
    colloc=COL;
    colloc &= 0x0F;
    }
    while(colloc==0x0F);
    lcddelay(1);
    colloc=COL;
    colloc&=0x0F;
    }
    while(colloc==0x0F);
    while(1)
    {
    ROW=0xFE;
    colloc=COL;
    colloc&=0x0F;
    if (colloc != 0x0F)
    {
    rowloc=0;
    break;
    }
    ROW=0xFD;
    colloc=COL;
    colloc&=0x0F;
    if (colloc != 0x0F)
    {
    rowloc=1;
    break;
    }
    ROW=0xFB;
    colloc=COL;
    colloc&=0x0F;
    if (colloc != 0x0F)
    {
    rowloc=2;
    break;
    }
    ROW=0xF7;
    colloc=COL;
    colloc&=0x0F;
    if (colloc != 0x0F)
    {
    rowloc=3;
    break;
    }
    }
    if (colloc== 0x0E)
    return(keypad[rowloc][0]);
    else if(colloc==0x0D)
    return(keypad [rowloc][1]);
    else if(colloc==0x0B)
    return(keypad [rowloc][2]);
    else
    return(keypad [rowloc][3]);
    }
    }
    void userintface(void) interrupt 0
    { char ch, ch_hr[2], ch_min[2], HOUR, MINUTE,MONTH,DAY;
    IE=0x80;
    lcdcmd(0x01);
    lcdoption();
    ch=KEYPD();
    lcddata(ch);
    lcddelay(200);
    if(ch== ‘1’)
    { lcdcmd(0x01);
    lcdhr();
    lcddelay(25);
    ch_hr[1]=KEYPD();
    lcdcmd(0x01);
    lcdcmd(0x80);
    lcddata(ch_hr[1]);
    ch_hr[0]=KEYPD();
    lcddata(ch_hr[0]);
    lcddelay(15);
    lcdcmd(0x01);
    lcdcmd(0x80);
    lcdmin();
    lcddelay(25);
    lcdcmd(0x01);
    lcdcmd(0x80);
    ch_min[1]=KEYPD();
    lcddata(ch_min[1]);
    ch_min[0]=KEYPD();
    lcddata(ch_min[0]);
    lcddelay(15);
    HOUR= ch_hr[0] & 0x0F;
    ch_hr[1]=ch_hr[1] & 0x0F;
    ch_hr[1]= ch_hr[1]<<4;
    HOUR=HOUR | ch_hr[1];
    MINUTE= ch_min[0] & 0x0F;
    ch_min[1]=ch_min[1] & 0x0F;
    ch_min[1]=ch_min[1]<<4;
    MINUTE=MINUTE | ch_min[1];
    }
    if(ch==’2’)
    { lcdcmd(0x01);
    lcdmonth();
    lcddelay(25);
    ch_hr[1]=KEYPD();
    lcdcmd(0x01);
    lcdcmd(0x80);
    lcddata(ch_hr[1]);
    ch_hr[0]=KEYPD();
    lcddata(ch_hr[0]);
    lcddelay(15);
    lcdcmd(0x01);
    lcdcmd(0x80);
    lcdday();
    lcddelay(25);
    lcdcmd(0x01);
    lcdcmd(0x80);
    ch_min[1]=KEYPD();
    lcddata(ch_min[1]);
    ch_min[0]=KEYPD();
    lcddata(ch_min[0]);
    lcddelay(15);
    MONTH= ch_hr[0] & 0x0F;
    ch_hr[1]=ch_hr[1] & 0x0F;
    ch_hr[1]= ch_hr[1]<<4;
    MONTH=MONTH | ch_hr[1];
    DAY= ch_min[0] & 0x0F;
    ch_min[1]=ch_min[1] & 0x0F;
    ch_min[1]=ch_min[1]<<4;
    DAY=DAY | ch_min[1];
    }
    switch(ch)
    { case ‘
    1′: XBYTE[4]=HOUR; //min
    XBYTE[2]=MINUTE;
    case ‘2’:XBYTE [8]=MONTH;
    XBYTE[7]=DAY;
    }}
    main()
    {
    unsigned char HR, MIN, SEC,day,month,year;
    IE=0x81;
    lcdinit();
    rtcinit();
    while(1)
    {
    HR=XBYTE[4];
    bcdconv(HR);
    lcddata(‘:’);
    MIN=XBYTE[2];
    bcdconv(MIN);
    lcddata(‘:’);
    SEC=XBYTE[0];
    bcdconv(SEC);
    lcdcmd(0xc2);
    day=XBYTE[7];
    bcdconv(day);
    lcddata(‘/’);
    month=XBYTE[8];
    bcdconv(month);
    lcddata(‘/’);
    year=XBYTE[9];
    bcdconv(year);
    lcddelay(45);
    lcdcmd(0x01);
    lcdcmd(0x82);
    IE=0x81;
    }
    }
     
      
    October 18, 2011 at 7:41 am #6726
    neha sharma
    Participant

    first post your circuit diagram …

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Why aren’t the power windows in my 2006 Volkswagen Polo 2006 working despite repairing the control unit circuit board? May 10, 2026
  • Voltage comparator circuit verification May 10, 2026
  • What is this??? May 9, 2026
  • infiniBand Layer 1 specifications testing question May 8, 2026
  • block RF May 8, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise