Maxim Integrated Secure Microcontroller User Manual
Page 168

Secure Microcontroller User’s Guide
168 of 187
Programmer’s Note: In the Write subroutine at the end of this example program, there is one unusual
statement. The action of writing a byte to the RTC is actually done using a read instruction (MOVX A,
@DPTR). This is because a write instruction would write to the RAM under
CE2
if one were present.
Since the RTC uses A2 as a write enable and A0 as the data bit, this instruction is acceptable.
; Program DEMODS5T
;
; This program responds to commands received over the serial
; I/O port to send or receive the date/time information between
; the RTC in the DS5000T and the serial I/O port. This allows
; an external program or user to access the date/time information.
;
; The program first sets up the serial port for transmission at
; 9600 baud with eight data bits, no parity, and one stop bit.
;
; Next, the program begins execution of a loop waiting for an
; instruction from the serial port. Two valid instructions, R and W,
; are recognized.
;
; Receipt of the R character causes the DEMODS5T program
; to read eight bytes of date/time information from the RTC
; and send them out over the serial port.
;
; Receipt of the W character causes the DEMODS5T program
; to wait for eight bytes of date/time information from the serial
; port and write them to the RTC.
;
; Any other byte received from the serial port is incremented and
; then sent back out to the serial port.
;
;
PCON
equ
87H
MCON
equ
0C6H
TA
equ
0C7H
;
cseg
at 0
sjmp
START
cseg
at 30H
START: ;Initialization.
mov
TA,
#0AAH
;Timed
mov
TA,
#55H
;access.
mov
PCON,
#0
;Reset watchdog timer.
mov
MCON,
#0F8H
;Turn off CE2 for memory access.
lcall
CLOSE
;Close date/time registers.
mov
IE,
#0
mov
TMOD,
#20H
;Initialize the
mov
TH1,
#0FAH
;serial port
mov
TL1,
#0FAH
;for 9600
orl
PCON,
#80H
;baud using 11.0592MHz crystal.
mov
SCON,
#52H
mov
TCON,
#40H
L:
jnb
RI,
L
;Wait for character.
clr
RI
;Clear the receiver.
mov
A,
SBUF
;Load in the character.
cjne
A,
#’R, H
;Skip if not a read.