M68HC16 Z SERIES
INITIALIZATION AND PROGRAMMING EXAMPLES
MOTOROLA
USER’S MANUAL
E-17
STD
SCCR1
;enable SCI receiver and transmitter
LDAB
#$01
TBZK
;point ZK at bank 1 (the SRAM)
LDZ
#$0000
;for indexing the variables CNT and DLY
CNT
EQU
$0000
;loop counter
DLY
EQU
$0002
;delay counter
*****
Main Program
*****
MAIN:
LDAB
#$7F
;set clock speed to 16.777MHz
STAB
SYNCR
;w=0, x=1, y=111111
NOT_L:
BRCLR
SYNCR+1,#8,NOT_L
;wait until synthesizer lock bit is set
LDD
#$01B5
STD
SCCR0
;set baud rate to 1200
JSR
DELAY
;delay for modulus counter of SCI to flush
LDX
#STRING
;load address of string into IX
JSR
SEND_STRING
;subroutine to send string to dummy terminal
LDAB
#$05
;set up loop counter
STAB
CNT,Z
LOOP1:
LDX
#SEC_STR
;load address of string into IX
JSR
SEND_STRING
;subroutine to send string to dummy terminal
DEC
CNT,Z
;decrement loop counter
BNE
LOOP1
;loop 5 times
LDAB
#$4F
;change clock frequency to 4.194MHz
STAB
SYNCR
;w=0, x=1, y=001111
LOOP2:
BRCLR
SYNCR+1,#8,LOOP2
;wait until synthesizer lock bit is set
LDD
#$006D
STD
SCCR0
;set BAUD rate back to 1200
JSR
DELAY
;delay for modulus counter of SCI to flush
LDX
#STRING2
;load address of string into IX
JSR
SEND_STRING
;subroutine to send string to dummy terminal
LDAB
#$05
;set up # of loops for loop counter to 5
STAB
CNT,Z
LOOP3:
LDX
#SEC_STR
;load address of string into IX
JSR
SEND_STRING
;subroutine to send string to dummy terminal
DEC
CNT,Z
;decrement loop counter
BNE
LOOP3
;loop 5 times
LBRA
MAIN
;branch back to main
*****
Subroutines
*****
DELAY:
LDD
#$FFFF
;delay loop
STD
DLY,Z
LOOP4:
DEC
DLY,Z
BNE
LOOP4
RTS
SEND_STRING:
;subroutine to send out the entire ASCII
;string
LDAB
0,X
;get next byte in string as pointed to by IX
BEQ
STRING_DONE
;if B=00, then message is done