
MOTOROLA
10-54
MAIN TIMER AND REAL-TIME INTERRUPT
M68HC11
REFERENCE MANUAL
Listing - Timer Examples
Sheet 11 of 16
*** Local subroutine to change duty cycle to offset cnt
* If duty < 50% ($32) change to 100-duty
* If duty >100% ($64) force to $64
* Finally mult by 1% of period (cyc)
* Enter with PWMDCx duty in A-reg, Return offset in D
CALOFF
CMPA
#50
Check for 0-49%
BHS
ARN6A
Around fixup
TAB
If <50% set to 100 - duty cycle
LDAA
#100
SBA
A-B to A
ARN6A
CMPA
#100
Check for > 100%
BLS
ARN6B
LDAA
#100
If > 100% - set to 100%
ARN6B
LDAB
PWMP1P
MUL
PWMP1P * adj’d duty cyc =OFFOCX
RTS
**Return from CALOFF**
*
***
c256 81 32
c258 24 04
c25a 16
c25b 86 64
c25d 10
c25e 81 64
c260 23 02
c262 86 64
c264 f6 d0 02
c267 3d
c268 39
[2]
[3]
[2]
[2]
[2]
[2]
[3]
[2]
[4]
[10]
[5]
***
* SV6OC1 - Output Compare 1 service routine
***
SV6OC1
LDX
#REGBAS
LDAA
OC1D,X
EORA
#%00010000
STAA
OC1D,X
LDD
TOC2,X
ADDD
PWMPER
STD
TOC2,X
LDD
TOC3,X
ADDD
PWMPER
STD
TOC3,X
LDD
TOC1,X
ADDD
PWMPER
STD
TOC1,X
BCLR
TFLG1,X $7F Clear OC1F
RTI
*
**** END Ex 10-6
c269 ce 10 00
c26c a6 0d
c26e 88 10
c270 a7 0d
c272 ec 18
c274 f3 d0 1f
c277 ed 18
c279 ec 1a
c27b f3 d0 1f
c27e ed 1a
c280 ec 16
c282 f3 d0 1f
c285 ed 16
c287 1d 23 7f
c28a 3b
[3]
[4]
[2]
[4]
[5]
[6]
[5]
[5]
[6]
[5]
[5]
[6]
[5]
[7]
[12]
Point to register block
Make PA4 flip @ nxt OC1 compare
Flips OC1D4 bit(PA4 pin contrl)
Update nxt OC1 auto pattern
Get last OC2 compare value
Add count equiv to period
Update OC2 (schedule next OC2)
Get last OC3 compare value
Add count equiv to period
Update OC3 (schedule next OC3)
Get last OC1 compare value
Add count equiv to period
Update OC1 (schedule next OCl)
Return from OC1 service
***
* TIMER EXAMPLE 10-7
* OC2 used alone to produce one PWH signal
*
* OC2 controls period and duty cycle of one port A pin
* Set “PWMP1P” & “PWMDC1” manually before running this
* example
* “PWMP1P” sets size of a 1% segment of PWM period
* (in cycles)
* “PWMDC1” sets Duty cycle for OC2 pin in % - NOTE: This
* program will not work properly with values of duty
* cycle too near 0 or 100%
* Refer to User’s Manual text for discussions
* Program calculates “OFFHI” and “OFFLO” at start