Maxim Integrated Secure Microcontroller User Manual
Page 171

Secure Microcontroller User’s Guide
171 of 187
Application: Using the DS2251T/DS2252T RTC
The RTC of the DS2251T or DS2252T is accessed in a parallel fashion like a RAM. The user simply
writes to the registers to set the time and control functions. The following program is an example of how
to use this clock. It provides a serial port interface allowing an user to set and read the time of day. Note
that the serial port setup expects 9600-baud communication and an 11.0592MHz crystal. If a user’s
application uses different values, this setup must be modified. All of the timekeeping access is performed
in the code under Set Time and Tell Time. The remainder of this program concerns getting data in and out
of the serial port for display purposes and has nothing to do with timekeeper access.
;Program DS1283
;
; This program responds to commands received over the serial
; port to set the date and time information in the RTC
;
; The program first initializes the serial port for communication
; at 9600 baud with eight data bits, no parity, and one stop bit.
;
; After setting the date and time, the program begins execution
; of an infinite loop which sends back the date and time each
; time a character is received.
;
CR
EQU
0DH
LF
EQU
0AH
;
MCON
EQU
0C6H
TA
EQU
0C7H
CSEG
AT
0
;
MOV
TA,
#0AAH
; Timed
MOV
TA,
#55H
; access.
MOV
PCON,
#0
; Reset watchdog timer.
ANL
MCON,
#0FBH
; Turn off PES for memory access.
MOV
P2,
#0
; Clear high byte of address.
; for clock access
;
MOV
IE,
#0
MOV
TMOD,
#20H
; Initialize the
MOV
TH1,
#0FAH
; serial port
MOV
TL1,
#0FAH
; for 9600
ORL
PCON,
#80H
; baud, with 11.0522MHz crystal.
MOV
SCON,
#52H
MOV
TCON,
#40H
;Messages
MOV
DPTR,
#TEXT0
LCALL
TEXT_OUT
LCALL
CHAR_IN
LCALL
CHAR_OUT
PUSH
ACC
MOV
DPTR,
#TEXT3
LCALL
TEXT_OUT
POP
ACC
ANL
A,
#5FH
CJNE
A,
#’Y’,
TELL_TIME
;Set Time
CLR
A
MOV
R0,
#0Bh
LCALL
WBYTE
; Freeze the registers.
MOV
DPTR,
#YEAR