M68HC16 Z SERIES
INITIALIZATION AND PROGRAMMING EXAMPLES
USER’S MANUAL
E-21
LDAA SCCNT,Z
ADDA #$01 ;increment # of seconds
DAA ;decimal adjust A
CMPA #$60 ;compare # of seconds to 60
BEQ MINUTES ;if # of sec=60, then branch to minute routine
STD SCCNT,Z ;if # of sec<60, store new # of sec
JSR DISPLAY ;send new time to dummy terminal for display
RTI ;return to main loop & wait for next interrupt
MINUTES: ;advance counter for minutes
CLR SCCNT,Z ;set # of seconds to 0
LDAA MNCNT,Z
ADDA #$01 ;increment # of minutes
DAA ;decimal adjust A
CMPA #$60 ;compare # of minutes to 60
BEQ HOURS ;if # of min=60, then branch to hours routine
STD MNCNT,Z ;if # of min<60, then store new # of min
JSR DISPLAY ;send new time to dummy terminal for display
RTI ;return to main loop & wait for next interrupt
HOURS: ;advance counter for hours
CLR MNCNT,Z ;set # of minutes to 0
LDAA HRCNT,Z
ADDA #$01 ;increment # of hours
DAA ;decimal adjust A
STD HRCNT,Z ;store new # of hours
CMPA #$24 ;compare # of hours to 24
BNE RETURN ;if # of hours < 24, then display new time
CLR HRCNT,Z ;if # of hours=24 then clear # of hours
RETURN: JSR DISPLAY ;send new time to dummy terminal for display
RTI ;return to main loop & wait for next interrupt
***** Send Time to Dummy Terminal Routine *****
DISPLAY: ;this routine takes what is stored in sccnt,
;mncnt and hrcnt, converts them to ASCII
;characters, and then sends them to a dummy
;terminal.
SEND_HR: ;output the hours
LDAB HRCNT,Z
JSR HEXTOASC ;convert hex number into ASCII and print
SEND_COL: ;output a colon
LDAB #$3A ;ASCII number for a colon
JSR SEND_CH ;send character to terminal
SEND_MIN: ;output the minutes
LDAB MNCNT,Z
JSR HEXTOASC ;convert hex number to ASCII and print
SN_COLON: ;output another colon
LDAB #$3A ;ASCII number for a colon
JSR SEND_CH ;send character to terminal
SEND_SEC: ;output the seconds
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..