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.