Maxim Integrated Secure Microcontroller User Manual

Page 169

Advertising
background image

Secure Microcontroller User’s Guide

169 of 187

lcall

OPEN

;Set up to read date/time.

mov

B

#8

;Set up to send 8 bytes.

F:
lcall

RBYTE

;Read a byte of date/time.

G:
jnb

TI,

G

;Wait for end of previous send.

clr

TI

;Clear transmitter.

mov

SBUF,

A

;Send out the byte.

djnz

B,

F

;Loop for 8 bytes.

sjmp

L

;Return to main loop.

H:
cjne

A,

#’W’, J

;Skip if not a write.

lcall

OPEN

;Set up to read date/time.

mov

B,

#8

; Set up to receive 8 bytes.

I:
jnb

RI,

I

;Wait to receive a byte.

jlr

RI

;Clear the receiver.

mov

A,

SBUF

;Bring in the byte.

lcall

WBYTE

;Write a byte of date/time.

djnz

B,

I

;Loop for 8 bytes.

sjmp

L

;Return to main loop.

J:
jnb

TI,

J

;If it is neither an R nor a W

clr

TI

;increment the character,

inc

A

;send it back out to the

mov

SBUF,

A

;serial port, and then

sjmp

L

;return to the main loop.

;
;
; SUBROUTINE TO OPEN THE CLOCK/CALENDAR (ECC)
;
; This subroutine executes the sequence of reads and writes which
; is required in order to open communication with the timekeeper.
; The subroutine returns with the timekeeper opened for data
; access with both the accumulator and B register modified.
;
OPEN:

LCALL

CLOSE

;Make sure it is closed.

MOV

B,#4

;Set pattern period count.

MOV

A,#0C5H

;Load first byte of pattern.

OPENA: LCALL

WBYTE

;Send out the byte.

XRL

A,#0FFH

;Generate next pattern byte.

LCALL

WBYTE

;Send out the byte.

SWAP

A

;Generate next pattern byte.

DJNZ

B,OPENA

;Repeat until 8 bytes sent.

RET

;Return.

;
;********************************
;*** SUBROUTINE TO CLOSE THE RTC
;********************************
;
; This subroutine insures that the registers of the timekeeper ; are closed
by executing 9 successive reads of the date and time ; registers. The
subroutine returns with both the accumulator ; and the B register modified.
;
CLOSE: MOV

B,#9

;Set up to read 9 bytes.

CLOSEA: LCALL

RBYTE

;Read a byte.

DJNZ

B,CLOSEA

;Loop for 9 byte reads.

RET

;Return.

;
;***********************************
;*** SUBROUTINE TO READ A DATA BYTE

Advertising