Hardware Reference
In-Depth Information
Start
1. Set OC5 pin action to pull
high
2. Clear C5F flag
3. Start OC5 operation with
delay value equal to 10
Pull the PT5 pin to high
quickly
No
C5F = 0?
Yes
No
HiorLo = 0?
Yes
1. Set OC5 pin action to toggle
2. Set HiorLo flag to 0
3. Start a new OC5 operation
with delay equal to HiCnt
1. Start a new OC5 operation
With LoCnt as delay
2. HiorLo = 1
Continue to perform other
operations
1. Start a new OC5 operation
With HiCnt as delay
2. HiorLo = 0
Return from interrupt
Figure 8.20 The program logic flow for digital waveform generation
The following assembly program implements this algorithm using the OC5 function:
#include
“c:\miniide\hcs12. inc”
HiCnt equ
1200
; delay count for high interval of the waveform
LoCnt equ
1800
; delay count for low interval of the waveform
org
$1000
HIorLO ds.b
1
; flag to select HiCnt (1) or LoCnt (0)
org
$1500
lds
#$1500
; establish stack pointer
movw
#OC5ISR,UserTimerCh5
; set up OC0 interrupt vector
movb
#$90,TSCR1
; enable TCNT and fast timer flag clear
movb
#$03,TSCR2
; set TCNT clock prescaler to 8
bset
TIOS,BIT5
; enable OC5
movb
#$0C,TCTL1
; configure the OC5 pin action to pull high
ldd
TCNT
; start OC5 with delay count equal to 10 and
addd
#10
; pin action to pull high
std
TC5
brclr
TFLG1,C5F,*
; wait until C5F is set to 1 and PT5 pin pulled high
ldd
TC5
; start another OC5 operation with
addd
#HiCnt
; delay count set to HiCnt
std
TC5
; “
Search WWH ::




Custom Search