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
You are here: Home / Topics / Digital Clock using DS12C887

Digital Clock using DS12C887

|

Microcontroller › 8051 › Digital Clock using DS12C887

  • This topic has 4 replies, 4 voices, and was last updated 10 years, 4 months ago by anurudh tiwari.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • December 29, 2011 at 9:01 am #1477
    Shrimohan Ramchandra Jhawar
    Participant

    I have written the code in Assembly Language to build a Digital Clock using DS12C887…But I am facing a problem in getting the exact output…

     

    Initially as i set time i get output as (HH:MM:SS format)

     

    16:58:01

    16:58:02

    03:03:03

    58:58:04

    and so on

     

    The out put is very much unpredictable…please help me out

     

    The code for the program appears as below…

     

    I HAVE ALSO TRIED THE RTC CODE IN ENGINEERSGARAGE BUT IT ALSO DONT WORK AT MY END……

     

    #include<reg51.h>
    #include<absacc.h>

    #define port P3
    #define lcd_dataport P2  // lcd_dataport for lcd
    #define keypad P1  // Port for keypadpad
    #define timeport P0 // Port for RTC

    sbit rs = port^0;
    sbit rw = port^1;
    sbit en = port^2;

    sbit key0=keypad^0;
    sbit key1=keypad^1;
    sbit key2=keypad^2;
    sbit key3=keypad^3;
    sbit key4=keypad^4;
    sbit key5=keypad^5;
    sbit key6=keypad^6;
    sbit key7=keypad^7;

    int hr, min, sec;

    void delay(unsigned int msec) //Time delay function
    {
    int i,j ;
    for(i=0;i<msec;i++)
    for(j=0;j<1275;j++);
    }

    void lcdcmd(unsigned char item) //Function to send command to LCD
    {
    lcd_dataport = item;
    rs= 0;
    rw=0;
    en=1;
    delay(1);
    en=0;
    return;
    }

    void lcddata(unsigned char item) //Funtion to send data on LCD
    {
    lcd_dataport = item;
    rs= 1;
    rw=0;
    en=1;
    delay(1);
    en=0;
    }

    void lcddata_string(unsigned char *str) // Function to send string on LCD
    {
    int i=0;
    while(str!=’’)
    {
    lcddata(str
    );
    i++;
    delay(1);
    }
    }

    void lcd(unsigned char str[10])  // Funtion to Initialize LCD
    {
    lcdcmd(0x38);
    lcdcmd(0x0C);
    lcdcmd(0x01);
    lcdcmd(0x80);
    lcddata_string(str);
    }

    void check_key()
    {
    if(key0==0)
    lcd(“SET TIME”);
    if(key1==0)
    lcd(“Increment”);
    if(key2==0)
    lcd(“Decrement”);
    if(key3==0)
    lcd(“SET A”);
    if(key4==0)
    lcd(“SET B”);
    if(key5==0)
    lcd(“SET C”);
    if(key6==0)
    lcd(“SET BANGS”);
    if(key7==0)
    lcd(“SET GROUPS”);
    }

    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 main()
    {
            delay(220);
            XBYTE[10]=0x20;
            XBYTE[11]=0x82;
            lcd(“TIME:”);
            while(1)
            {
            lcdcmd(0x88);
            hr=XBYTE[4];
            bcdconv(hr);
            lcddata(‘:’);
            min=XBYTE[2];
            bcdconv(min);
            lcddata(‘:’);
            sec=XBYTE[0];
            bcdconv(sec);
            lcdcmd(0x02);
            }
    }

    December 30, 2011 at 10:20 am #6965
    nikhiljain
    Participant

    Change the delay is display..this may solve the problem..

    December 30, 2011 at 8:03 pm #6974
    Shrimohan Ramchandra Jhawar
    Participant

    tried but it did not work…..can u show the code ?

    April 1, 2012 at 11:15 am #7376
    sujan
    Participant

    i have need it’s hex code.

    April 1, 2012 at 6:11 pm #7377
    anurudh tiwari
    Participant

    type the program in any simulator kiel , win 8051…… then simulate it.. after the simulation 3-4 files is automatically generated depend on the simulator (such as .lst, abs .oj and .hex) then use the file .hex for the burning in microcontroller..

     

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

RSS Recent Posts

  • Neon Transformers for sale August 9, 2022
  • Can I use an SPDT 5 wire Relay in reverse? August 9, 2022
  • Add a low power indicator LED August 9, 2022
  • LTSpice DC-AC August 9, 2022
  • Is there a discord for this forum? August 9, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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