Article View: comp.dsp
Article #43shar file, 300 baud fsk routines
From: Stephen L Moshier
Date: Sun, 01 Nov 1992 21:02
Date: Sun, 01 Nov 1992 21:02
624 lines
14524 bytes
14524 bytes
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: filter.asm modemr.asm modemt.asm stub.asm
# Wrapped by moshier@world on Sun Nov 1 11:49:04 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f filter.asm -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"filter.asm\"
else
echo shar: Extracting \"filter.asm\" \(1969 characters\)
sed "s/^X//" >filter.asm <<'END_OF_filter.asm'
X; filter.asm
X; IIR filter programs.
X
X org pl: ;this program is in on-chip memory.
X
X; The processing steps for a single pole pair involve a
X; sampled data input signal x(t), delay line w(t), and
X; output signal y(t).
X;
X; poles:
X; w(t) = x(t) + c1 w(t-1) + c2 w(t-2)
X; zeros:
X; y(t) = b0 w(t) + b1 w(t-1) + b2 w(t-2)
X; delay line:
X; w(t-2) = w(t-1)
X; w(t-1) = w(t).
X;
X; Enter with x(t) in accumulator a.
X; r4 enters pointing at w(t-2); next up is w(t-1).
X; r0 points to coefficients in the order c2, c1, b2, b1, b0.
X;
X; Program returns with filter output sample in a.
X;
X; Set processor to shift up 1 on alu output by the instruction
X; or #$08,MR. This means that all the coefficients should
X; be exactly half of the desired values, expressed as fixed
X; point fractional numbers.
X;
X; - Copyright 1987 by Stephen L. Moshier
X
X
X; 4th order IIR filter
X
Xfil4
X
X or #$08,MR
X; first filter section
X; c2 w(t-2)
X move x:(r0)+,x0 y:(r4)+,y1
X
X; c2*w(t-2) c1 w(t-1)
X mac x0,y1,a x:(r0)+,x0 y:(r4)-,y0
X
X; + c1*w(t-1) b2 w(t-2) = w(t-1)
X macr x0,y0,a x:(r0)+,x0 y0,y:(r4)+
X
X; b2*w(t-2) b1 w(t)
X mpy x0,y1,a x:(r0)+,x0 a,y1
X
X; +b1*w(t-1) b0 w(t-1) = w(t)
X mac x0,y0,a x:(r0)+,x0 y1,y:(r4)+
X
X; +b0*w(t) next c2 next w(t-2)
X mac x0,y1,a x:(r0)+,x0 y:(r4)+,y1
X; second filter section
X; c2*w(t-2) c1 w(t-1)
X mac x0,y1,a x:(r0)+,x0 y:(r4)-,y0
X
X; + c1*w(t-1) b2 w(t-2) = w(t-1)
X macr x0,y0,a x:(r0)+,x0 y0,y:(r4)+
X
X; b2*w(t-2) b1 w(t)
X mpy x0,y1,a x:(r0)+,x0 a,y1
X
X; +b1*w(t-1) b0 w(t-1) = w(t)
X mac x0,y0,a x:(r0)+,x0 y1,y:(r4)+
X
X; +b0*w(t)
X macr x0,y1,a
X and #$f7,MR
X rts
X
X; Second order filter
X
X org pl:
Xfil2
X or #$08,MR
X; c2 w(t-2)
X move x:(r0)+,x0 y:(r4)+,y1
X
X; c2*w(t-2) c1 w(t-1)
X mac x0,y1,a x:(r0)+,x0 y:(r4)-,y0
X
X; + c1*w(t-1) b2 w(t-2) = w(t-1)
X macr x0,y0,a x:(r0)+,x0 y0,y:(r4)+
X
X; b2*w(t-2) b1 w(t)
X mpy x0,y1,a x:(r0)+,x0 a,y1
X
X; +b1*w(t-1) b0 w(t-1) = w(t)
X mac x0,y0,a x:(r0)+,x0 y1,y:(r4)+
X
X; +b0*w(t)
X macr x0,y1,a
X and #$f7,MR
X rts
END_OF_filter.asm
if test 1969 -ne `wc -c <filter.asm`; then
echo shar: \"filter.asm\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f modemr.asm -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"modemr.asm\"
else
echo shar: Extracting \"modemr.asm\" \(5733 characters\)
sed "s/^X//" >modemr.asm <<'END_OF_modemr.asm'
X; 300 baud modem receiver program
X; Copyright (C) 1987 by Stephen L. Moshier
X
X
X; data memory storage
X; x memory space
X org xl:
X; 300 baud modem filter coefficients
X;
X; Order of presentation for each:
X; c2
X; c1
X; b2
X; b1
X; b0
X; All are for 8000 Hz sampling rate
X
X; Low band 1070 - 1270 Hz
X; Answer mode receive band
X; 4th order low pass, 2db ripple, pass 0-1270, stop 2025 Hz
X; dbdown 5.276226765e+01
X
Xlofilt
X
X; f0 1.23586097e+03 gain 8.4887e+00 DC gain 1.2324e+00
X dc -0.4286498
X dc 0.5229224
X; f0 2.11089275e+03 gain 0.0000e+00 DC gain 2.1740e+00
X dc -0.0693399
X dc -0.0120630
X dc -0.0693399
X; f0 5.99758599e+02 gain 5.0260e+00 DC gain 4.4780e+00
X dc -0.2882925
X dc 0.6766350
X; f0 3.02593762e+03 gain 0.0000e+00 DC gain 3.4427e+00
X dc -0.0693399
X dc -0.1000385
X dc -0.0693399
X
X; Low band discriminator
X;
X; Low pass 2nd order, 6db ripple, pass 1170, stop 1270
X; dbdown 1.271859559e+01
X
X; f0 1.04995006e+03 gain 7.0236e+00 DC gain 1.7030e+00
X dc -0.4031716
X dc 0.6095659
X; f0 1.46518847e+03 gain -5.0686e-17 DC gain 1.1844e+00
X dc -0.2492395
X dc 0.2032782
X dc -0.2492395
X
X; High pass, 2nd order, 6db ripple, stop 1070 pass 1170
X; dbdown 1.294969758e+01
X
X; f0 1.28875897e+03 gain 5.2572e+00 DC gain 1.1874e+00
X dc -0.3879321
X dc 0.4668458
X; f0 9.10671468e+02 gain 0.0000e+00 DC gain 4.9013e-01
X dc -0.3110093
X dc 0.4695843
X dc -0.3110093
X
X; High band filter 2025 - 2225 Hz
X; Originate mode receive band
X; High pass 4th order, 2db ripple, stop 1270 pass 2025
X; dbdown 5.276226765e+01
X
Xhifilt
X
X; f0 2.06313029e+03 gain 5.8917e+00 DC gain 5.2073e-01
X dc -0.4150302
X dc -0.0451549
X; f0 1.19907094e+03 gain 0.0000e+00 DC gain 8.2325e-01
X dc -0.1263355
X dc 0.1486654
X dc -0.1263355
X; f0 2.92524387e+03 gain 2.2305e+00 DC gain 4.4185e-01
X dc -0.2055801
X dc -0.4260223
X; f0 5.59875559e+02 gain 1.1815e-17 DC gain 1.9026e-01
X dc -0.1263355
X dc 0.2286340
X dc -0.1263355
X
X; High band discriminator */
X; Low pass 2nd order, 6db ripple, pass 2125, stop 2225
X; dbdown 1.203486237e+01
X
X; f0 1.99019333e+03 gain 4.1867e+00 DC gain 5.7218e-01
X dc -0.3805705
X dc 0.0067195
X; f0 2.42450965e+03 gain 0.0000e+00 DC gain 2.6545e+00
X dc -0.2872167
X dc -0.1879927
X dc -0.2872167
X
X; High pass 2nd order, 6db ripple, stop 2025, pass 2125
X; dbdown 1.200879571e+01
X
X; f0 2.26016187e+03 gain 4.3645e+00 DC gain 4.7143e-01
X dc -0.3830155
X dc -0.1775949
X; f0 1.81981553e+03 gain 0.0000e+00 DC gain 1.7179e+00
X dc -0.2783189
X dc 0.0785108
X dc -0.2783189
X; end of modem filter coefficients
X
Xband ds 1
Xwptr ds 1 ;debug output buffer pointer
X
X
X;y memory space address
X org yl:
Xdline ds 4 ;4th order modem band filter
X ds 2 ;2nd order high discriminator
Xhiband ds 1
X ds 2 ;2nd order low discriminator
Xloband ds 1
Xbaudcl dc 0 ;baud rate clock
Xmcursam ds 1
Xmlassam ds 1
X
X org yh:
Xbitctr ds 1
Xtemp ds 1
Xoutcod ds 1
Xmchar ds 1
Xbitchg ds 1
X
X
X
X org ph:
X; enter with PCM sample in A register
Xmodemr
X jsr mudec
X; Receive band filter
X; hifilt = originate mode
X; lofilt = answer mode
X move #hifilt,r0
X move #dline,r4
X jsr fil4
X move a,x:band
X; lower frequency (space) discriminator filter
X jsr fil2
X; Rectify and average the output
X; const 0.25 y:loband
X abs a x:(r0)+,x0 y:(r4),y0
X mpy -x0,y0,b a,x1
X mac x1,x0,b
X add y0,b
X; output
X move b,y:(r4)+
X
X; Higher frequency (mark) discriminator filter
X jsr fil2
X; Rectify and average the output
X; const 0.75 y:hiband
X abs a x:(r0)+,x0 y:(r4),y0
X; const 0.25
X mpy x0,y0,b x:(r0)+,x0 a,y1
X mac y1,x0,b
X; output
X move b,y:(r4)+
X; Update baud rate clock
X; baudcl increments each 13 1/3 samples
X; at 8 KHz sample rate
X;
X; clock increment clock value
X move x:(r0)+,x0 y:(r4),a
X add x0,a
X move a1,y:(r4)+
X; Get decision measurement
X move y:hiband,a
X move y:loband,y1
X sub y1,a y:mcursam,b
X move b1,y:mlassam
X move a1,y:mcursam
X; get clock and strip off bottom 16 bits
X move #>$ff0000,x0
X move y:baudcl,b
X and x0,b
X move b,x1
X; Bitctr counts as follows:
X; 0 waiting for start bit (a space)
X; 1 got start bit, waiting 3/2 baud to
X; middle of first data bit
X; 2-9 8 data bits
X; 10 stop bit (a mark)
X move y:bitctr,b
X; 1 to high byte of y1
X tst b #1,y1
X jne _z2 ; jump if( bitctr != 0 )
X; check carrier amplitude level
X
X; waiting for start bit (a space)
X tst a
X jge _z1 ; jump if( mcursam >= 0 )
X; bitctr = 1
X clr b y1,y:bitctr
X; baudcl = 0
X move b,x1 b,y:baudcl
X_z1
X jmp _nxts
X_z2
X; Waiting for first data bit
X cmp y1,b
X jne _z3 ; jump if bitctr != 1
X; baudcl
X tfr x1,a #3,x0
X cmp x0,a
X jge _newbit ; jump if baudcl >= 3
X jmp _nxts
X_z3
X; is baudcl >= 2?
X tfr x1,a #2,x0
X cmp x0,a
X jlt _nxts ; jump if baudcl < 2
X_newbit
X clr a y:mcursam,y0
X; baudcl = 0
X move a,x1
X move a,y:baudcl
X; if mcursam < 0 then temp (x0) = 0
X; else temp = 0200
X cmp y0,a
X jle _z6
X move #$80,x0
X_z6
X move a,x0
X; bitctr += 1
X move y:bitctr,a
X add y1,a
X move a,y:bitctr
X; bitchg = 128
X move #$80,y0
X move y0,y:bitchg
X move #$10,y0
X cmp y0,a
X jge _z9 ; jump if bitctr >= 10
X; shift data bits in from top down
X; (the least significant bit comes in first)
X
X; mchar = mchar >> 1 + temp
X move y:mchar,a
X lsr a
X or x0,a ;x0 = temp
X move a,y:mchar
X jmp _nxts
X_z9
X tfr x0,a
X tst a
X jne _z7 ;jump if temp != 0
X; framing error!
X; reset to stop bit postition
X; and set clock to wait 1/2 baud
X move #9,a
X move a,y:bitctr
X move #1,a
X move a,x1
X move a,y:baudcl
X jmp _nxts
X_z7
X; set up for next character
X clr a
X move a,y:bitctr
X; A character has been decoded.
X; put its code into the ring buffer
X move y:mchar,a
X jsr putring
X; flags |= 128
X bset #23,x:flags
X_nxts
X; set output code to 2 if any characters were detected
X btst #23,x:flags
X jcc _z8
X move #2,a
X move a,y:outcod
X_z8
X rts
END_OF_modemr.asm
if test 5733 -ne `wc -c <modemr.asm`; then
echo shar: \"modemr.asm\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f modemt.asm -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"modemt.asm\"
else
echo shar: Extracting \"modemt.asm\" \(2712 characters\)
sed "s/^X//" >modemt.asm <<'END_OF_modemt.asm'
X; modemt.asm
X; 300 baud modem receiver
X; Copyright (C) 1987 by Stephen L. Moshier
X
X org xl:
Xmbptr ds 1
Xmctr1 ds 1
Xmctr2 ds 1
Xmctr3 ds 1
Xmadata ds 1
X
X; Tone frequencies
X; for 300 baud modem
X; 1070.0,
X; 1270.0,
X; 2025.0,
X; 2225.0,
X
Xorfreq
X dc 0.0010449 ; originate mode space
X dc 0.0012402 ; originate mode mark
Xanfreq
X dc 0.0019775 ; answer mode space
X dc 0.0021729 ; answer mode mark
X
X org yl:
Xmbaudct ds 1
Xmphase1 ds 1
Xmphase2 ds 1
Xmfreq1 ds 1
Xmfreq2 ds 1
X
X org ph:
Xmodemt
X; if( mbaudct > 2 )
X; mbaudct = 0;
X; The integer part of the baud rate counter is the most
X; significant byte of the 24 bit word.
X move #2,x0
X clr b y:mbaudct,a
X cmp x0,a
X tgt b,a
X move a,y:mbaudct
X; Get tone frequencies
X move #orfreq,r0
X move #mfreq1,r4
X move x:(r0)+,y0
X move x:(r0)+,x0 y0,y:(r4)+
X move x0,y:(r4)
X; set buffer length counter
X move #BUFLEN,x0
X move x0,x:mctr1
X move #CHBBAS,x0
X move x0,x:mbptr
X_mttop
X; Check if a tone is in process.
X; mctr2 counts bits in the character
X; mctr3 counts samples of tone waveform.
X move x:mctr2,a
X tst a x:mctr3,b
X jgt _toncon
X tst b
X jgt _toncon
X; Get next character from ring buffer.
X jsr tstring
X jne _morton
X; If no unread characters in the buffer, then
X; send a character of all marks.
X move #-1,x0
X move x0,x:madata
X jmp _nxtchr
X; get code to send from ringbuffer
X_morton
X jsr getring
X; Insert start bit in bit 0
X; and stop bit in bit 9
X lsl a #>$100,x0
X or x0,a
X move a,x:madata
X
X_nxtchr
X; count 10 baud per character
X move #10,x0
X move x0,x:mctr2
X_baudlup
X; get the right frequency for this baud
X move x:madata,a
X tfr a,b #>1,x0
X and x0,a
X jeq _isspace
X move y:mfreq2,x0 ;mark
X jmp _setfreq
X_isspace
X move y:mfreq1,x0 ;space
X_setfreq
X lsr b x0,y:mphase1
X; shift in the next baud
X move b,x:madata
X; Make the average length of a baud
X; equal to 26 2/3 samples at 8 KHz
X move #255,x0 ;mask high byte
X move y:mbaudct,a
X and x0,a a,b
X tst a
X jgt _bgt
X move #26,a
X move #2,x1
X jmp _setbctr
X_bgt
X move #27,x0
X tfr b,a #1,x1
X sub x1,a ; baudct -= 1
X_setbctr
X move x0,x:mctr3
X move a,y:mbaudct
X; Fill waveform array with the tone for this baud
X move #$100,x0 ; ROM sine table
X move #mphase1,r4
X move #>$80,x1
X_tonlup
X; find sine wave at current phase
X tfr x0,a y:(r4)+,y0
X mac y0,x1,a y:(r4)-,y1
X tfr y0,b a,r0
X; update phase
X add y1,b x:mbptr,r6
X; get sine wave
X move x:(r0)+,a b,y:(r4)
X; jsr muenc ;uses r5
X move a,y:(r6)+
X move r6,x:mbptr
X; check the output buffer
X move x:mctr1,b
X sub x1,b
X move b,x:mctr1
X jle _mtdon
X; return here to continue processing
X_toncon
X; update loop counter
X move #1,x1
X move x:mctr3,a
X sub x1,a
X move a,x:mctr3
X jgt _tonlup
X; update baud loop counter
X move #1,x1
X move x:mctr2,a
X sub x1,a
X move a,x:mctr2
X jgt _baudlup
X jmp _mttop
X_mtdon
X rts
END_OF_modemt.asm
if test 2712 -ne `wc -c <modemt.asm`; then
echo shar: \"modemt.asm\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f stub.asm -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"stub.asm\"
else
echo shar: Extracting \"stub.asm\" \(509 characters\)
sed "s/^X//" >stub.asm <<'END_OF_stub.asm'
X; 300 baud modem fsk routines
X; this module contains I/O stubs
X
X org yh:$200
XBUFLEN equ 64
XCHBBAS ds 128
X
X org xl:$40
Xflags ds 1
X
X org yl:$40
X
X org ph:$200
X; convert mu-law pcm code to linear
Xmudec
X rts
X
X; convert linear to mu-law
Xmuenc
X rts
X
X; put decoded ASCII character into receive buffer
Xputring
X rts
X
X; return nonzero if there is a character in the transmit buffer
Xtstring
X rts
X
X; read character from transmit buffer
Xgetring
X rts
X
X include 'modemr.asm'
X include 'modemt.asm'
X include 'filter.asm'
X end
X
END_OF_stub.asm
if test 509 -ne `wc -c <stub.asm`; then
echo shar: \"stub.asm\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
Technical Details
Message-ID:
<Bx22Gp.7Ks@world.std.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!decwrl!world!moshierShow Full Headers
Complete Article Headers
Newsgroups: comp.dsp Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!world!moshier From: moshier@world.std.com (Stephen L Moshier) Subject: shar file, 300 baud fsk routines Message-ID: <Bx22Gp.7Ks@world.std.com> Summary: DSP56000 source code for 300 baud fsk Keywords: modem DSP56000 Organization: The World Public Access UNIX, Brookline, MA Date: Sun, 1 Nov 1992 21:02:48 GMT Lines: 625