
MOTOROLA
INITIALIZATION AND PROGRAMMING EXAMPLES
M68HC16 Z SERIES
E-28
USER’S MANUAL
ANDA
#$01
;check only the TDRE flag bit
BEQ
SEND_CH
;if TDR is not empty, go back to check it
again
LDAA
#$00
;clear A to send a full word to SCDR ($FFC0E)
STD
SCDR
;transmit one ASCII character to the screen
TC_LOOP:
LDAB
SCSR+1
ANDB
#$80
;test the TC bit (transfer complete)
BEQ
TC_LOOP
;continue to wait until TC is set
RTS
;finish sending out byte
*****
The STRINGS
*****
STRING_IC1
DC.W
'Input capture 1 caught a transition',0a,0d,00
STRING_IC2
DC.W
'Input capture 2 caught a rising edge',0a,0d,00
STRING_IC3
DC.W
'Input capture 3 caught a falling edge',0a,0d,00
STRING_OC2
DC.W
0a,'Output compare 2 just toggled',0a,0d,00
STRING_PAOV
DC.W
0a,'Pulse Accum. has overflowed 10
times!',07,0a,0d,00
*****
Exceptions/Interrupts
*****
*
Note that every one of the GPT interrupt service routines clears
*
its flag bit at the end of the routine before the RTI instruction.
EVEN
IC1_ROUTINE:
;execute when IC1 senses a transition
LDX
#STRING_IC1
JSR
SEND_STRING
;print the message
BCLR
TFLG1,#$01
;clear the IC1 flag bit
RTI
IC2_ROUTINE:
;execute when IC2 senses a rising edge
LDX
#STRING_IC2
JSR
SEND_STRING
;print the message
BCLR
TFLG1,#$02
;clear the IC2 flag bit
RTI
IC3_ROUTINE:
;execute when IC3 senses a falling edge
LDX
#STRING_IC3
JSR
SEND_STRING
;print the message
BCLR
TFLG1,#$04
;clear the IC3 flag bit
RTI
OC2_ROUTINE:
;execute when OC2 does a toggle
LDX
#STRING_OC2
JSR
SEND_STRING
;print the message
BCLR
TFLG1,#$10
;clear the OC2 flag bit
RTI
PAOV_ROUTINE:
;execute on Pulse Accumulator Counter overflow
;if PAI pin tied PWMA, bell approx every 5 sec
;if PAI pin tied PWMB, bell approx every 10
min