
MOTOROLA
10-50
MAIN TIMER AND REAL-TIME INTERRUPT
M68HC11
REFERENCE MANUAL
Listing - Timer Examples
c151 ce d0 18
[3]
c154 a6 00
[4]
c156 bd ff b8
[6]
c159 86 2e
[2]
c15b bd ff b8
[6]
c15e 08
[3]
c15f a6 00
[4]
c161 bd ff b8
[6]
c164 8c d0 1e
[4]
c167 26 f5
[3]
c169 ce c4 04
[3]
c16c bd ff ca
[6]
c16f 20 a3
[3]
Sheet 7 of 16
LDX
LDAA
JSR
LDAA
JSR
INX
LDAA
JSR
CPX
BNE
LDX
JSR
BRA
#DBUFR+1
0,X
.OUTA
#’.’
.OUTA
Start at 2nd digit (1st is 0)
Seconds digit
Print
ASCII period
Print
Advance pointer to next digit
get digit
Print it
Was that the last
If not continue
Point at rest of display line
Print “Seconds”
Goto top of main & repeat
DUMPLP
0,X
.OUTA
#DBUFR+7
DUMPLP
#MSGSEC
.OUTSTO
PER24T
*
* END of Main Program Portion
***
* SV3TOF - Timer Overflow service routine
*
* Called whenever any timer overflow is detected. if
* the IC1 period measurement is in progress (IC1MOD
* positive) then the overflow counter (upper 8-bits of
* period) is incremented.
***
SV3TOF
TST
IC1MOD
if 0 or 1 IC1 active-count TOFs
BMI
OU3TOF
if neg, IC1 not active
INC
OVCNT1
increment IC1 overflow count
OU3TOF
LDAA
# $80
STAA
REGBAS+TFLG2Clear overflow flag
RTI
**Return from TOF service**
c171 7d d0 06
c174 2b 03
c176 7c d0 07
c179 86 80
c17b b7 10 25
c17e 3b
[6]
[3]
[6]
[2]
[4]
[12]
***
* SV3IC1 - Input Capture 1 service routine
*
* Called first when a rising edge is detected and again
* when another rising edge is detected.
***
SV3IC1
LDX
#REGBAS
point at top of register block
INC
IC1MOD
$FF->0 at 1st edge; 0->1 at 2nd
BNE
NO1ST3
if not 0, this is second edge
c17f ce 10 00
c182 7c d0 06
c185 26 13
[3]
[6]
[3]
* Process first edge of period
CLR
LDD
STD
BMI
LDAA
BPL
DEC
* decrement OVCNT1 to -1....
* TOF svc routine will inc back to zero
BRA
OU3IC1
c187 7f d0 07
c18a ec 10
c18c fd d0 08
c18f 2b 27
c191 a6 25
c193 2a 23
c195 7a d0 07
[6]
[5]
[5]
[3]
[4]
[3]
[6]
OVCNT1
TIC1,X
RES1
OU3IC1
TFLG2,X
OU3IC1
OVCNT1
Zero the overflow count
Read time of first edge
Save till next capture
Done if IC was before any TOF
Check for TOF in MSB
If no overflow, you’re done
This TOF shouldn’t count
c198 20 1e
[3]
Done processing first edge