mainlogo.jpg (16286 bytes)

AN513

Product: Domino 2

Real Time Clock

Date: 2/13/99

Introduction: DOMINO 2 incorporates a coprocessor for additional I/O capabilities. Another added function is a real-time clock/calendar (RTC). The RTC feature of the Domino 2 is available through firmware within the coprocessor. This application note demonstrates how to set, start, stop, and read the RTC of the Domino 2.
 

Background: A 32khz low power oscillator provides a time base for the coprocessor to keep track of seconds, minutes, hours, etc., while the system is powered. For low power applications, the user may choose to turn off the system power to conserve system batteries. To prevent the Domino 2 from losing time and date, a dedicated external power pin is provided for battery backup.

 

How it works: The following program asks you to enter the second, minutes, hour, the date, and the day of the week. The clock is a 24 hour clock.

 

Program Listing:

10 REM *** This program allows you to set and run the real time

20 REM *** clock for the Domino 2.

30 ?"Please select from the following menu."

40 ?"1 = Set the clock."

50 ?"2 = Read the clock."

60 ?"3 = Stop the Clock."

70 ?"4 = Start the clock."

80 INPUT E

90 IF E=1 THEN GOTO 250

100 IF E=2 THEN GOTO 690

110 IF E=3 THEN GOTO 140

120 IF E=4 THEN GOTO 190 ELSE GOTO 30

130 REM *** Stop the Clock.

140 R = 70h

150 DT = 0

160 GOSUB 1110

170 GOTO 30

180 REM *** Start the clock.

190 R = 70H

200 DT = 1

210 GOSUB 1110

220 GOTO 30

230 REM *** Set the Clock Routine.

240 REM *** Input the Seconds

250 ?"Please enter the seconds.(0-59)"

260 INPUT DT

270 REM *** R=The seconds register.

280 R = 71H

290 GOSUB 1110

300 REM *** Input the Minutes

310 ?"Please enter the minutes.(0-59)"

320 INPUT DT

330 REM *** R=the minutes register

340 R = 72H

350 GOSUB 1110

360 REM *** Input the Hour.

370 ?"Please enter the hour.(24 HR)"

380 INPUT DT

390 REM *** R=hours register.

400 R=73H

410 GOSUB 1110

420 REM *** Input the month.

430 ?"Please enter the month.(1-12)"

440 INPUT DT

450 REM *** R=Month register

460 R=76H

470 GOSUB 1110

480 REM *** Input the day of the month

490 ?"Please enter the day of the month.(1-31)"

500 INPUT DT

510 REM *** R=Day of the month register.

520 R=75H

530 GOSUB 1110

540 REM *** Input the year.

550 ?"Please enter the year.(00-99)"

560 INPUT DT

570 REM *** R=year register.

580 R=77H

590 GOSUB 1110

600 REM Input the Day of the week.

610 ?"Please enter the day of the week.(1=SUN,7=SAT)"

620 INPUT DT

630 REM *** R=day of the week register.

640 R=74H

650 GOSUB 1110

660 GOTO 30

670 REM *** Read the Clock 4 times.

680 REM *** Read the seconds and store it in SE.

690 FOR A=1 TO 4

691 REM *** Setting the Processors real time clock function

700 CLOCK0

710 TIME=0

720 CLOCK1

730 PUSH 2071H

740 CALL 0F12CH

750 POP SE

760 REM *** Read the minutes and store it in MI.

770 PUSH 2072H

780 CALL 0F12CH

790 POP MN

800 REM *** Read the hour and store it in HR.

810 PUSH 2073H

820 CALL 0F12CH

830 POP HR

840 REM *** Read the month and store it in MO.

850 PUSH 2076H

860 CALL 0F12CH

870 POP MO

880 REM *** Read the day of the month and store it in DA.

890 PUSH 2075H

900 CALL 0F12CH

910 POP DA

920 REM *** Read the year and store it in YR.

930 PUSH 2077H

940 CALL 0F12CH

950 POP YR

960 REM *** Read the day of the week and store it in WD.

970 PUSH 2074H

980 CALL 0F12CH

990 POP WD

1000 REM *** Using the processors real time clock to set the delay

1010 REM *** for printing every second.

1020 IF TIME=1 THEN GOTO 1030 ELSE GOTO 1020

1030 PRINT USING(##)

1040 PRINT WD," ",MT,"/",DA,"/",YR," ",HR,":",MN,":",SE

1050 NEXT A

1060 GOTO 30

1070 REM

1080 REM ***************************************************

1090 REM Coprocessor Write Routine

1100 REM

1110 PUSH 2000h + R,DT

1120 CALL 0F128h

1130 POP DT

1140 IF DT>255 THEN PRINT "Communications error !!!"

1150 Return

1160 REM

1170 REM ***************************************************