Hi Mac,
Thanks for your help on this.
I’ve been trying to follow the theme on AN-1771, with just one tone, with DREG’s generated for each of the ctcss frequencies (not shown here). I did this on a separete spreadsheet.
I followed most everything in the code that you provided except for the value to be assigned to FREQ. Could you plase elaborate on that?
The initpwm routine to generate the CTCSS tones is accessed when the radio is in the transmit mode (IRQ = 0). To that end, I have the IRQ interrupt pin set on an ‘edge only’ basis as IRQ will be 0 for the duration of the transmission.
The initpwm routine is accessed on transmissions (IRQ=0), and the initial settings for Timer 1, Channel 0 are placed here.
The ‘looper’ instruction at the end of this routine is designed to provide an exit mechanism when the PTT switch is released (IRQ=1). I would assume that the Timer interrupt would be generated while the program is in this ‘loop’.
The problem is that the timer won’t generate any interrupts. I know this because I changed the vector to point to a piece of code that would provide an LCD indication to that effect. I must have screwed something up in the code.
Could you please give it the once over and let me have the benefits of your thoughts / suggestions.
Thanks, in advance, for your help.
Joe Burch
; CTCSS TONE GENERATOR ROUTINES
; PWM Initialization Routine
initpwm
; index into ctcss_tbl to get the DREG value for this tone
cli ; so that the interrupt will work
ldhx #ctcss_tbl ; point to table
lda ctcss ; get current ctcss value
tax ; load index register
lda ,x ; get DREG value
sta ddsreg ; store to ddsreg
; now we have the first part solved.
clr track
; tim1 status and control register
; t1sc
; b7 - TOF - Timer Overflow = 1 = Output
; b6 - TOIE - Tim Ovfl Int Enable = Input = 1
; b5 - TSTOP - Timer Stop = Input = 1
; b4 - TRST
; b3 - Unused
; b2 - Prescaler Bit 2 - Input
; b1 - Prescaler Bit 1 - Input
; b0 - Prescaler Bit 0 - Input
; stop the timer TSTOP = 1
mov #$30,t1sc ; reset counter and prescaler = TRST = 1
ldhx #$00ff ; set pwm period
sthx t1modh
ldhx #$0080 ; load initial duty cycle
sta t1ch0l ; store it
; set up for unbuttered output compare
mov #$20,t1sc0
bset 1, t1sc0 ; set toggle on overflow bit
; activate the output compare
bset 0,t1sc ; set prescale = 1
bclr 5,t1sc ; clear the TSTOP bit
; tim1, channel 0 status and control register
; t1sc0
; b7 - CH0F
; b6 - CH10E
; b5 - MS0A = 1 for unbuffered operation
; b4 - MS0B = 0 for unbuffered operation
; b3 - ELS0B = 1 = set output on compare
; b2 - ELS0A = 1 = set output on compare
; b1 - TOV0 = 1 = toggle on overflow
looper ; b0 - CH0MAX = 0 (no steady state)
bih qtrans
bra looper
qtrans
bset 5,t1sc ; set the TSTOP bit
jmp dnxmit ; all done transmitting
; interrupt service request
_tovint ; tovi sets the new fsamp rate and calculates
; the new sin_table pointers for the next
bclr 7,t1sc ; clear the overflow bit
; Add FREQ value to DDSREG
' 'BIG MAC Code follows...."
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
; counting starts again
inc track ; set up for next interrupt.
bih qtrans ; stop if PTT is released
rti ; return