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 / Replies /                   

                  

|

Microcontroller › 8051 › Digital Clock using 8051 and RTC DS12C887 ›                   

December 11, 2012 at 2:28 pm #8821
poovi
Participant

                                               I have checked the LCD separately using a sample code and it displays properly.  So I decided to check the RTC separately and gave the code as below. The code executed correctly on Kiel Simulator. (it constantly displayed 16:55:58) However when I burnt the same code into the microcontroller and connected the hardware, there was no output on Hyper terminal.. ( I am not exactly sure how to use Hyper terminal) .  PLease help me as I need to submit this as my project :(

 

       

 

//Program to interface RTC DS12C887 with 8051 microcontroller (AT89C51)
#include<reg51.h>
#include<absacc.h>
 char hr, min, sec;
 
void delay(int time)
{
    int i,j;
    for(i=0;i<time;i++)
    for(j=0;j<1275;j++);
}

serial(char x) // Function to transmit data serially using RS232
{
    
    SBUF=x;
    while(TI==0);
    TI=0;
}

void bcdconv(char mybyte) // Function to convert data into BCD format.
{
    char x,y;
    x=mybyte&0x0F;
    x=x|0x30;
    y=mybyte&0xF0;
    y=y>>4;
    y=y|0x30;
    serial(y);
    serial(x) ;
}

void main()
{
    TMOD=0x20;
    TH1=0xFD;
    SCON=0X50;                          
    TR1=1;
    delay(220);
    XBYTE[10]=0x20;
    delay(20);
    XBYTE[10]=0x30;
    XBYTE[11]=0x83;
    XBYTE[0]=0x55;
    XBYTE[2]=0x58;
    XBYTE[4]=0x16;
    XBYTE[7]=0x02;
    XBYTE[8]=0x02;
    XBYTE[9]=0x02;
    XBYTE[11]=0x03;
    while(1)
    {
        XBYTE[10]=0x20;
        delay(500);
        hr=XBYTE[4];
        bcdconv(hr);
        serial(‘:’);
        min=XBYTE[2];
        bcdconv(min);
        serial(‘:’);
        sec=XBYTE[0];
        bcdconv(sec);
        serial(0x0D);
        serial(0x0A);
    }
}

RSS Recent Posts

  • Oshon Basic, programing IF statements June 8, 2026
  • USBASP Programming problems June 8, 2026
  • What is the most suitable light source for making a book light like this? June 8, 2026
  • My Advanced Realistic Humanoid Robots Project June 7, 2026
  • Transistor K2 X T5 June 7, 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