; ; $Header: E:/HAM/EVM/RCS/tone.asm 1.5 1997/02/22 15:11:40 dbraun Exp $ ; ; $Log: tone.asm $ ; Revision 1.5 1997/02/22 15:11:40 dbraun ; Added SPYing of L or R input channels, or output channel ; (spyleft, spyright, or spyout runtime-patchable parameters). ; ; Revision 1.4 1997/02/21 23:03:29 dbraun ; Made spy output runtime selectable (dl tone spy=1) ; ; Revision 1.3 1997/02/21 22:59:28 dbraun ; Added: PTT control and second tone, both controllable with ; run-time parameters, and also SPY option. ; ; Revision 1.2 1996/12/28 15:57:26 dbraun ; Some improvements ; ; Revision 1.1 1996/12/06 09:32:16 dbraun ; Initial revision ; ; opt mu page 132 nolist include 'leonid' list scsjmp short ;force short jumps for .if/.endi, .while/.endw, etc. title 'Continous tone output' ;************************************************************************* ;compile-time constants SampleFreq equ 48000.0 DefaultFreq equ 1000 ;(integer) default output frequency in Hz DefaultFreq2 equ 1500 ;(integer) default output frequency in Hz DefaultRMS equ 0.35355 ;(float) default output level in RMS volts ;Note that the codec OLB parameter is set ;to give a maximum P-P output of 2.8 volts, ;or a RMS level of 1.0 volts. ; (default of 0.35355 = 1.0V p-p) TxAttenuate equ 0.0 ;[dB] attenuate the output CODEC's signal. BufLen equ 32 PTTRight macro mode ;PTT line: clr/set/chg b\mode #4,X:$FFE4 endm PTTLeft macro mode ;PTT line: clr/set/chg b\mode #0,X:$FFE4 endm ;************************************************************************* ;The actuall code (internal/external program RAM) LOMEM P:$0000 HIMEM P:$1FFF org p:user_code ;initialize registers, buffers, etc. ori #%00000100,omr ;enable the sine ROM table ;this is for the IQ routine ; N1OWU: Activate the relay that switches the analog I/O ; to the 9600 baud FSK port. It's connected to bit 9 of port B. ; This is correct for the IC-821 setup. It causes the radio ; to get line-level, not mike-level output. btst #0,X: bset #9,X:$ffe4 .endi ; Activate the transmitter(s) if desired btst #0,X: PTTLeft set .endi btst #0,X: PTTRight set .endi ; Calculate CarFreq from f (see below) ; Some trickiness is required to avoid overflow ; or rounding errors. Note that any change to sample ; frequency will require changing this a bit. move X: bclr #0,X: bclr #0,X: bclr #0,X:$80,x1 ;shift out 8 most significant bits mpy x0,x1,a #>$FF,x0 move x0,m0 and x0,a #>$100,x0 or x0,a #>$40,n0 move a1,r0 ;put the 8 most significant bits into r0 with offset = $100 move a0,y0 ;save the remaining bits in y0 jclr #23,y0,SinTable_lev2 move (r0)+ SinTable_lev2 move Y:(r0+n0),x0 ;x0 = coarse cosine move Y:(r0),x1 ;x1 = coarse sine mpyr x1,y0,a #PI/256.0,y1 tfr x0,a a,x1 macr -x1,y1,a ;a = fine cosine mpyr x0,y0,b Y:(r0),x1 tfr x1,b b,x1 macr x1,y1,b #PI*PI/2.0/65536.0,y1 ;b = fine sine mpyr y0,y0,a a,x0 move a,y0 mpyr y0,y1,a tfr x0,a a,y1 macr -x0,y1,a b,x1 ;a = super fine cosine macr -x1,y1,b ;b = super fine sine rts ;x,y are modified ;r0,m0,n0 are modified ;maximum error is about 0.7E-6 ;execution time 4+64+4 clock cycles ;including "jsr no spy request move a2,X: spy request ! move x0,Y:'S',a cmp x0,a ori #$01,ccr jne 'P',x0 putc move #>0,x0 ; send a 0 meaning non-complex data putc move #>512,a move a,X:'S',a cmp x0,a jne 'P',x0 putc move #>0,x0 ; send a 0 meaning non-complex data putc move #>512,a Spy_copy move #>1,x0 sub x0,a move a,X: