
MOTOROLA
10-52
MAIN TIMER AND REAL-TIME INTERRUPT
M68HC11
REFERENCE MANUAL
Listing - Timer Examples
***
* TIMER EXAMPLE 10-5 Square wave using Output Compare
*
* Ex10-5 uses interrupts.
* Generate a square wave at the PA6 output pin using OC2
*
* This program runs on an EVB board. The half-cycle delay
* time is entered into the double byte variable "HDLY" at
* $D000,D001 with a memory modify before going to the program.
***
Sheet 9 of 16
c1e3 8e 00 47
c1e6 86 7e
c1e8 97 d0
c1ea ce c1 fd
c1ed df dd
c1ef ce 10 00
c1f2 86 40
c1f4 a7 20
c1f6 a7 23
c1f8 a7 22
c1fa 0e
c1fb 20 fe
[3]
[2]
[3]
[3]
[4]
[3]
[2]
[4]
[4]
[4]
[2]
[3]
TOP5
LDS
LDAA
STAA
LDX
STX
LDX
LDAA
STAA
STAA
STAA
CLI
BRA
# $0047
# $7E
PVOC2
#SV5OC2
PVOC2+1
#REGBAS
#%01000000
TCTL1,X
TFLG1,X
TMSK1,X
Top of User’s stack area on EVB
Jump (extended) Opcode
OC2 Pseudo Vector see manual
Address of OC2 service routine
Finish JMP inst to TOF routine
Point to register block
OM2:OL2 = 0:1
Setup OC2 to toggle on compares
Clear any pending OC2F
Enable OC2 interrupts
Enable Interrupts
Interrupt driven from here
*
***
* SV5OC2 - Output Compare 2 service routine
*
* Called at each OC2 interrupt.
***
SV5OC2
LDD
HDLY
ADDD
TOC2,X
STD
TOC2,X
BCLR
TFLG1,X $BF Clear OC2F
RTI
*
*****END Ex 10-5
c1fd fc d0 00
c200 e3 18
c202 ed 18
c204 1d 23 bf
c207 3b
[5]
[6]
[5]
[7]
[12]
Get delay time for 1/2 cycle
Add to last compare value
Update OC2 (schedule next edge)
**Return from OC2 service**
* TIMER EXAMPLE 10-6
* OC1, OC2, and OC3 used together to produce 2 PWM signals
*
* OC1 controls two pins of port A in conjunction with OC2 and OC3
* OC1 drives the period and the scheduling of OC2 and OC3
* OC2 & OC3 automatically control pins but don’t generate interrupts
* Set "PWMP1P", "PWMDC1" & "PWMDC2" manually before running this example
* "PWMP1P" sets size of a 1% segment of PWM period (cycles)
* min PWMP1P for this program is 2 (period = 200 cycles)
* "PWMDC1" sets Duty cycle for OC2 pin in % (0 to $64 hex)
* "PWMDC2" sets Duty Cycle for OC3 pin in % (0 to $64 hex)
* Duty cycle (%) will be translated into a # of cycles offset
* and period will be calculated as (100 * PWMP1P) at prog start
* PA4 pin will toggle at each OC1 compare as a scope reference signal