Hi Mac,
Thanks for your time.
No, I kept the initialization code up front, shortly after the M/P powers up:
mov #$30,t1sc ; temporarily stop the timer and clear the prescale bits
ldhx #0080 ; initial PWM duty 50%
sthx t1ch0h
bclr 5,t1sc ; re-enable timer
I also had included it in the pwminit routine. I checked it on the CodeWarrior simulator.
Her'es the code to initialize the pwm mode:
initpwm
ldx ctcss ; get ctcss value
lslx ; adjust word address
clrh
lda ctcss_tbl,x ; read high byte
sta freq ; store it
lda ctcss_tbl+1,x ; read low byte
sta freq+1 ; store it
mov #$08,ddsreg
clr ddsreg+1
clr ddsreg+2
clr track ; clear table entry
bset 5,t1sc ; stop timer
mov #$5A,t1sc0 ; unbuffered PWM, clear on compare
bclr 5,t1sc ; re-enable timer
cli
rts
and the code for the interrupt (along with your test code):
_toc0int
bclr 7,t1sc0
bil toc01
clr t1ch0l
rti
toc01
pshh
; Add FREQ value to DDSREG
lda ddsreg+2 ;
add freq+1 ;
sta ddsreg+2 ;
lda ddsreg+1 ;
adc freq ;
sta ddsreg+1 ;
and #$F0 ; Mask upper nybble
nsa ;
psha ;
lda ddsreg ;
adc #0 ;
sta ddsreg ;
and #$0F ; Mask lower nybble
nsa ;
ora 1,SP ; Combine nybbles
ais #1 ; Adjust stack pointer
tax ;
clrh ;
lda sin_tbl,x ; Fetch value from sine table
clr t1ch0h
sta t1ch0l ; Update TIM channel duty
BRSET 3,ddsreg,TOC02 ; Branch if phase output MSB is set
BCLR 6,prtb ; Clear test pin output
BRA *+4 ; Skip next always
TOC02:
BSET 6,prtb ; Set test pin output
inc track ; set up for next interrupt.
pulh
rti ; return
The reason for the non varying pulse was that the TAX instruction was somehow omitted (by me). Now the pulse varies (ramps up and ramps down), but the program is running way too slow.
It looks like I'm not going to be able to join the ranks of successful PWM'ers on the JL-16.
Any last thoughts??
Joe