A digital clock keeps track of the time and uses RTC(real Time Clock).The time is displayed on the LCD, which is connected to Port 2.The RTC used is DS12887 and the controller used is 89v51RD2.Three switches acts as a input for seconds, minutes and hours.
The above circuit is build on proteus and crystal frequency has been internally set. The connection of the RTC DS12C887 with the microcontroller is shown in the circuit diagram.It uses update interrupt to keep the track of the time. Every time the update interrupt comes, the clock is incremented by one second. The output is displayed on the LCD. The clock uses external interrupt 2 of the microcontroller AT89C51 for setting the time. A user can set time by pressing the switch connected to pin 13 of the microcontroller, which is interrupt 2. The hour and minutes can be set using pin 5 and pin 6 of the controller AT89C51 respectively. Once the time is set, the user needs to press the start pin (pin 8 of controller) to start the clock.
The component used are 8051
The main features of 8051 microcontroller are:
i. RAM – 128 Bytes (Data memory)
ii. ROM – 4Kbytes (ROM signify the on – chip program space)
iii. Serial Port – Using UART makes it simpler to interface for serial communication.
iv. Two 16 bit Timer/ Counter
v. Input/output Pins – 4 Ports of 8 bits each on a single chip.
vi. 6 Interrupt Sources
vii. 8 – bit ALU (Arithmetic Logic Unit) viii. Harvard Memory Architecture – It has 16 bit Address bus (each of RAM and ROM) and 8 bit Data Bus.
ix. 8051 can execute 1 million one-cycle instructions per second with a clock frequency of 12MHz.
DS12887 RTC
The real-time clock (RTC) is a widely used device that provides accurate time and date for many applications. It provides time components of hour, minute, and second, in addition to the date/calendar components of year, month, and day. The RTC chip uses an internal battery, which keeps the time and date even when the power is off. One of the most widely used RTC chips is the DS 12887 from Dallas Semiconductor/Maxim Corp. The DS 12887 supports both 12-hour and 24-hour clock modes with AM and PM in the 12-hour mode. It also supports the Daylight Savings Time option. The DS 12887 uses CMOS technology to keep the power consumption low and it has the designation DS12C887, where C is for CMOS. The DS12887 has a total of 128 bytes of nonvolatile RAM. It uses 14 bytes of RAM for clock/calendar and control registers, and the other 114 bytes of RAM are for general-purpose data storage.
Pins of DS12887
Vcc
Pin 24 provides external supply voltage to the chip. The external voltage source is +5V. When VC9 falls below the 3V level, the external source is switched off and the internal lithium battery provides power to the RTC.
GND
Pin 12 is the ground.
ADO-AD7
The multiplexed address/data pins provide both addresses and data to the chip. Addresses are latched into the DS 12887 on the falling edge of the AS (ALE) signal. ADO – AD7 of the DS 12887 are connected directly to the 8051 and there is no need for any 74xx373 latches, since the DS 12887 provides the latch internally.
AS (ALE)
AS (address strobe) is an input pin. On the falling edge it will cause the addresses to be latched into the DS 12887. The AS pin is used for demultiplexing the address and data and is connected to the ALE pin of the 8051 chip.
MOT
This is an input pin that allows the choice between the Motorola and Intel microcontroller bus timings. The MOT pin is connected to GND for the Intel timing. That means when we connect DS 12887 the 8051, MOT = GND.
DS
Data strobe or read is an input. When MOT = GND for Intel timing, the DS pin is called the RD (read) signal and is connected to the RD pin of the 8051.
R/W
Read/Write is an input pin. When MOT = GND for the Intel timing, the R/W pin is called the WR (write) signal and is connected to the WR pin of the 8051.
CS
Chip select is an input pin and an active low signal. During the read (RD) and write (WR) cycle time of Intel timing, the CS must be low in order to access the chip. It must be noted that the CS works only when the external Vcc is connected. In other words “when Vcc falls below 4.25V, the chip-select input is internally forced to an inactive level regardless of the value of CS at the input pin.” This is called the write-protected state. When the DS 12887 is in write-protected state, all inputs are ignored.
IRQ
Interrupt request is an output pin and active low signal. To use IRQ, the interrupt-enable bits in register B must be set high.
SQW
Square wave is an output pin. We can program the DS 12887 to provide up to 15 different square waves. The frequency of the square wave is set by programming register A RESET
Pin 18 is the reset pin. It is an input and is active low (normally high). In most applications the reset pin is connected to the Vcc pin. In applications where this pin is used, it has no effect on the clock, calendar, or RAM if it is forced low. The low on this pin will cause the reset of the IRQ and clearing of the SQW pin.
Address map of the DS12887
The DS12887 has a total of 128 bytes of RAM space with addresses 00 -7FH. The first ten locations, 00 – 09, are set aside for RTC values of time, calendar, and alarm data. The next four bytes are used for the control and status registers. They are registers A, B, C, and D and are located at addresses 10-13 (OA – OD in hex). Notice that their hex addresses match their names.
The next 114 bytes from addresses OEH to 7FH are available for data storage. The entire 128 bytes of RAM are accessible directly for read or write except the following:
1) Registers C and D are read-only.
2) D7 bit of register A is read-only.
3) The high-order bit of the seconds byte is read-only.