Design of Calendar Clock Based on DS12C887 Chip

The research is supported by the Basic Research Program (Natural Science Foundation) of Jiangsu Province, China (No. BK2007601) and the Natural Science Foundation of Jiangsu Higher Education Institutions of China (No. 06KJB510048). (Sponsoring information) Abstract The digitization of clock has brought us enormous conveniences and the development of the special-purpose clock chip would extend the traditional functions of clock. In this article, we design a new calendar clock based on DS12C887 chip and AT89C52 SCM. The system includes 5 parts: the AT89C52 SCM module, the calendar clock module, the LED display module, serial communication module and the C51 program. The SCM can get real-time information through the correct operations of addressing and the register. Users can set up initial time through serial communication between the PC and SCM. The LED unit is used to display real-time clock information.


Introduction
The clock has had hundreds years' history, and the digitization of clock has brought us enormous conveniences and extended the traditional function of clock such as telling time.Many new functions such as automatic timing alarming, automatic bell on schedule, automatic control of time program, timing broadcasting, automatic street lamp, timing switch oven, automatic drive equipment break, and even automatic start of various timing electric appliances are based on the digitization of clock.Therefore, it is very significant to study the digital clock and extend its applications.
With the developments of computer and SLSI technology, the technology of professional digital clock chip is more and more mature, and the technology of SCM has gradually entered into the design of electric clock (Tian, 2005, p.61-63 & Xiehui, 2005, p.34-38).The function of digital clock has been extended significantly, for example, when the data is collecting, for some important information, not only the contents but also the concrete time that this event happens should be recorded, and for another example, the display screen of interest rate or exchange rate used in the bank hall should display information of calendar clock such as information of year, month, day, week, hour, minute and second, except displaying interest rate and exchange rate.
In this article, we design a real-time calendar clock display system based on DS12C887 chip, which can display second, minute, hour, week, day, month and year, and possesses the function of leap year rehab, and for the time display, it can select 24 hours mode or 12 hours mode with "AM" and "PM" indications, and the time, calendar and clock have two sorts of form such as binary code and BCD code, and it can work for a long time when the exterior power supply conks out.

Design ideas
The real-time display can be realized through software programming, but this method needs complex program, and the codes are numerous, and the spending of SCM software is high, and the time information is difficult to be stored for a long term.The special real-time clock chip can avoid these problems, and it can save time information chronically nonvolatile.Therefore, we can use special clock chip DS12C887 to implement the real-time calendar clock system.This chip can offer detailed information including year, month, day, week, hour and minute for the system.The interior of DS12C887 has information memorizers of clock, week and date, and the real-time time information is in these nonvolatile information registers.In the same way as 51SCM, DS12C887 also adopts 8 bits address/data reuse bus, which also has interior control register and the interior time information register reading DS12C887.Various registers of DS12C887 have corresponding fixed addresses in the interior space, so SCM can get time information needed through correct addressing and register operations.
According to the partition of function module, the hardware structure of system includes 5 following parts which are seen in Figure 1.
(1) The module of 51 SCM.Its function is to communicate with exterior clock chip, control the data transfer process, collect and dispose time information.
(2) The module of calendar clock.It is composed by special real-time clock chips.And it is the core module of the system, and it can offer real-time calendar clock information.
(3) The module of LED display.It is used to display calendar clock.Its function is to display output data and state.So, as typical exterior parts, the LED display unit is the effective part to reflect system output and operation input.
(4) The module of serial communication.The user can set initial time information through the series communication between PC and SCM.
(5) The C51 program.It includes the interface program (it can realize the data transfer process between SCM and clock chip) and display program that SCM controls clock chip.

Design of hardware
The hardware of the system includes 4 parts.They are the module circuit of calendar clock chip DS12C887, module circuit of 51 SCM AT89C52, the module circuit of serial communication, and the module circuit of LED display output.Figure 2 is the structure of circuit principle of the system.The user can set initial time information through the serial communication between PC and SCM, and after the initial time information is set up, the system begins to work, and the calendar clock chip DS12C887 would offer real-time calendar clock information which will implement data transfer with SCM AT89C52.The SCM AT89C52 communicates with the calendar clock chip DS12C887, and controls the data transfer process, and collects and dispose time information.Finally, AT89C52 will transfer time information to the display system, and the real-time time information is displayed through 4 bits dynamic display circuit.
U1 is the SCM chip AT89C52 of Atmel Company, and it works in the clock of 11.0592MHz (Horenstein, 1996, p.24-57).P0 port is used as the address/data reuse bus AD [0, 1 …7] which is connected with the AD [0, 1 …7] of calendar clock chip DS12C887.The P1 port is used as the interface of LED display, and because the display in the article has not decimal, we only use a, b, c, d, e, f and g, and don't use the segment of dp (decimal).The P2.1/P2.4 of P2 port are used as the digit code interfaces of LED, and they need to control the digit code selection of 13 bits LED through 4-16 decoding circuit and drive circuit.The P2.0 of P2 port offers patch selection signals for the calendar clock chip DS12C887 after reverse phase, because the patch selection signals are effective on the low level.The series lead feet of SCM P3.0 (RxD) and P3.1 (TxD) will realize serial communication with PC through the serial level switch circuit.The SCM lead feet P3.7 (/RD) and P3.6 (/WR) are directly connected with the write and read pins of calendar clock chip DS12C887, and both them are effective on the low level.The ALE lead foot of SCM is directly connected with the memory latch pin of real-time clock chip, and it is used as the memory address latches which can realize the time reuse of data and address.
U2 is 6 bits phase inverter 74LS04, which implements reverse phase to P2.0 of SCM and transfer it to the patch selection pin of DS12C887.
U3 is the calendar clock chip DS12C887.In the design, its MOT lead foot needs to be grounding, and the Intel bus time sequence mode is selected.When U3 works in the mode of Intel bus time sequence, it completely allows the interface of 51 SCM, so its address/data reuse lines AD0-AD7, latch input ALE, read input DS and write input R/W are completely connected with corresponding lead feet of the interface of 51 SCM.The square wave output SQW of DS12C887 and interrupt application /IQW are needed in the design, so its lead feet can be hang in the air.
The serial communication adopts the serial port of SCM to communicate by the mode of RS232.The hardware of data communication adopts 3 lines system which is to respectively connect three lead feet (RxD, TxD, GND) between SCM and PC, i.e. across connecting the TxD line and RxD line between PC and SCM, and directly connecting both GND lines, and using no other signal lines, and adopting the mode of software handclasp.In this way, it can not only realize scheduled rash, but simplify the circuit design.Because the TTL logic level of SCM has different electric character with RS232, so the MAX232 chip must be used to switch the level.
Because the system needs display year, month, day, weak, hour, minute and second, i.e. 13 bits effective information, so 4 LED are needed.The 4 bits 7 segments common-cathode LED is selected and the LED are connected with SCM in parallel and dynamically display the time information.Following aspects should be noticed, the confirmation of word digit port address and word type port address, how to realize the data display of LED through word bit code and word type code and realize dynamical display through timing interrupt.
The connections between SCM and various module pins are shown as follows.

Design of software
The emphasis of software design is how SCM control calendar clock chip and read time information through the operation setup of register.The program flow of the real-time calendar clock display system designed in this article is shown in Figure 3.

Conclusions
The calendar clock chip DS12C887 can offer complete time information from year, month, day and weak to hour, minute and second, and it is broad applied in the SCM system which needs getting or displaying real-time calendar clock information.In this article, we design a sort of real-time calendar clock based on DS12C887 chip and AT89C52 SCM.The whole clock display system sets up the initial time information through the series communication of PC and SCM, and at the same time SCM exchanges data with the calendar clock chip DS12C887, and finally the real-time calendar clock information implement digital display through the digital display module.
TxD: The lead foot11 and the TTL level input lead foot of MAX 232 respectively connect with series input signals TXD and TTL of SCM.RxD: The lead foot 12 and the TTL level output lead foot of MAX 232 respectively connect with series input signals RxD and TTL of SCM.SER-IN: The lead foot 14 and the RS-232 level output lead foot of MAX 232 respectively connect with series output signals RxD and RS232 of RS-232.SER-OUT: The lead foot 13 and the RS-232 level input lead foot of MAX 232 respectively connect with series output signals RxD and RS232 of RS-232.

Figure
Figure 2. The Structure of Circuit Principle Figure 3. Program Flow