Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

Clock using RTC DS12C887 & 8051 microcontroller (AT89C51) with alarm set function


Developed By: 
Himanshu Choudhary

DS12C887 is a real time clock (RTC) IC from Dallas Semiconductors. The RTCs provide precise time and date information. This article explains the making of a digital clock with alarm setting functionalities. RTC has been interfaced with AT89C51 to perform desired operations. This project is an improvement over Digital clock using RTC DS12C887 and 8051 microcontroller (AT89C51) with time set and has the alarm setting function also. The alarm setting function allows user to set the alarm. The clock time is displayed on the LCD.  The free source code for the program is available in C.



Alarm Clock using RTC DS12C887 & 8051 microcontroller (AT89C51)



The circuit for interfacing the RTC and 16x2 LCD with the microcontroller 8051 is shown in the circuit diagram. Port P2 is set as data port for LCD to send the data on the LCD while port P0 is set as data port for the RTC DS12C887. This is used to extract the time, date and other information from the RTC. The pins of port P1 and P3 of the controller AT89C51 are used to provide the input signals for setting the time, alarm etc. They also provide control signals for the RTC and the LCD.

This project is an improved version of Digital clock using RTC DS12C887 and 8051 microcontroller (AT89C51) with time set with only difference that we can set alarm in it. It helps in understanding the concept of setting alarm in the RTC 12C887.  The program uses the two external interrupt 0 and 1 for setting the time and alarm respectively. For setting the time the pin P3^2 of the microcontroller 8051 is made low, which is the external interrupt 0. For alarm setting the pin P3^3 of the microcontroller is made low which is the external interrupt 1.
When any of the interrupts occur, the microcontroller stops its current operation and gets ready to set the time or alarm depending on the interrupt activated. The alarm can be set by using the pins digalarm_hr1 and digalarm_min1. The time can be set by using the pins dig_hr1 and dig_min1. When the alarm time matches the clock time, ‘Alarm’ is displayed on the LCD and the alarmport pin is set high for 10 sec. This pin can further be connected to a speaker or buzzer to sound the alarm.


Circuit Diagram



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



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 (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...

Browse 4m+ Electronic Products

Pick the right product for your next design project with "Mouser Store". Mouser Electronics brings broadest range of semiconductors and electronic components from over 500 industry leading suppliers. 
Mouser specializes in the rapid introduction of new products and technologies for design engineers and buyers that includes semiconductors, interconnects, passives, and electro-mechanical components. Providing the best possible service with the flexibility of not requiring a minimum order and same-day shipping, Mouser has it all.
When you need the right part right now, think of Mouser
Thank you
Team EG


You are here