Digital clock using RTC DS12C887 and 8051 microcontroller (AT89C51) with time set

Summary

Real time clock (RTC) is widely used in many application to provide accurate time. This article explains the making of a simple digital clock using RTC DS12C887 and 8051 microcontroller (AT89C51). The output is displayed on an LCD. This clock also has a provision of setting time at any instant. The clock uses the concept of our earlier articles of interfacing RTC DS12C887 with microcontroller. The clock described here uses the method of polling for running. For further details on interfacing RTC DS12C887 with AT89C51 using polling, refer RTC interfacing.  The free source code for the program is available in C.

 
 
Digital clock using RTC DS12C887 and 8051 microcontroller (AT89C51) with time se

Description

 

The circuit diagram shows the connection of RTC with the microcontroller. Port P2 is used as data port for LCD; port P0 of the microcontroller is used as data port of RTC DS12C887.  The pins P1^0, P1^1, P1^2, P1^3, P1^4, P1^5, P1^6 of controller AT89C51 are configured as reset, rs, rw, e, dig_hr1, dig_min1, start pins respectively.

 
In this clock the RTC is used in 24 hour mode which gives accurate time and can be displayed on LCD through microcontroller. Firstly oscillator is set, than RTC is set in 24 hour mode by setting 0X20 in register A. For more details, refer RTC interfacing with AT89C51.
 
The microcontroller continuously reads the data from the RTC. The algorithm processes the data and displays the data in correct order on the LCD screen. Interrupt 2 of the microcontroller is used to set time. Whenever P3^3 pin is made low (0), interrupt2 comes and set_time function is called for setting the time. Hours can be set by using the dig_hr1 pin. Minutes can be set with the dig_min1 pin. After setting the time, start pin is made high and the clock starts with the time set by user.  
 
 

 

Circuit Diagram

Video

Code

This Code is only visible to Registered users. Please Login/Register

 

Components

AT89C51 Microcontroller, Atmel 89C51 Controller Image
AT89C51 Microcontroller

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (...

16 x 2 LCD | 16x2 Character LCD Module
LCD

 

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments...

RTC DS12C887 Image
RTC DS12C887

RTC DS 12C887 is widely used to provide exact time and date in many applications such as x86 IBM PC. This RTC provides time components hour, minute and second in addition to the date/calendar components of year, month and day. This chip uses an internal lithium battery, which keeps the time and da...