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.