MOTOROLA
INITIALIZATION AND PROGRAMMING EXAMPLES
M68HC16 Z SERIES
E-24
USER’S MANUAL
E.2.3 QSM/SCI Programming Example
The following programming example involves using a port of the serial communication
interface (SCI), one of the serial interfaces of the queued serial module (QSM), to dis-
play a message on a dummy terminal.
or the SCI.
E.2.3.1 Example 6 - Using an SCI Port
*
Description : This program uses the SCI port to display
*
a shameless message on a dummy terminal.
It includes
*
a subroutine to print a single character to the SCI
*
and a subroutine that uses the single character
*
subroutine to print an entire string.
*
*************************************************************************
INCLUDE
'EQUATES.ASM'
;table of EQUates for common register
addresses
INCLUDE
'ORG00000.ASM'
;initialize reset vector
INCLUDE
'ORG00008.ASM'
;initialize interrupt vectors
ORG
$0200
;start program after exception vector table
*****
Initialize
*****
INIT:
INCLUDE
'INITSYS.ASM'
;initially set EK=F, XK=0, YK=0, ZK=0
;set sys clock at 16.78 MHz, disable COP
INCLUDE
'INITRAM.ASM'
;turn on internal SRAM at $10000
;set stack (SK=1, SP=03FE)
INCLUDE
'INITSCI.ASM'
;set the SCI baud rate to 9600 baud
;enable the SCI receiver and transmitter
LDAB #$00
TBXK
;set XK to bank 0 for STRING access
LDAB #$01
TBZK
;set ZK to bank 1 for delay counter access
LDZ
#$0000
;clear IZ for later use with delay counter
*****
Main Program
*****
MAIN
LDX
#STRING
;point to the beginning of ASCII string
JSR
SEND_STRING
;go output the ASCII string
BRA
MAIN
;branch back to main
*****
Subroutines
*****
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 goto delay between messages
JSR
SEND_CH
;go send out the byte