Hello people! I'm very new in DSP programing and I need to implement a FIR filter with 5409 DSP. I try to do with C source (see at the bottom of the document) but this solution is very slow. How can I do a simple passBand or highBand filter? I see a fir function in some examples. Where can I find documentation or examples about fir function? Thank you for all!! A portion of my filter function: void Filtrar() { int index = -1; int inici = -1; int i; int sum; int index2; while (1) { while (NMostresADCNoves<=0); //Hope new data folling ADC Interruption // CODI DEL FILTRE index++; if(index>=NCoeff) index=0; MeuBuf[index]esIn[MostraActualIn]; sum = 0; inici++; if(inici>=NCoeff) inici = 0; index2 = inici; for(i=0; i<NCoeff; i++) { index2++; if(index2>=NCoeff) index2 = 0; sum = sum + MeuBuf[index2]*Coeff[i]; } DadesOut[MostraActualOut] = sum; MostraActualIn++; MostraActualOut++; ... } |
|
Problems whith a FIR implementation.
Started by ●April 7, 2003
Reply by ●April 7, 20032003-04-07
Hi, If you absolutely want to code FIR in C, I suggest you to use DSPLIB. There's a function called fir() which might be helpful for your case. Please refer to SPRU518 for more details. Otherwise, you need to do implement "circular buffer" in assembly. But, if your objective is to implement a simple lowpass or highpass filter, you can use IIR instead of FIR as it can reduce drastically the number of operations required per sample. A good starting link to design your IIR filter is: http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html Hope it helps. --- In , "narcispr" <u1034199@c...> wrote: > Hello people! > > I'm very new in DSP programing and I need to implement a FIR filter > with 5409 DSP. > > I try to do with C source (see at the bottom of the document) but > this solution is very slow. How can I do a simple passBand or highBand > filter? > > I see a fir function in some examples. Where can I find documentation > or examples about fir function? > > Thank you for all!! > A portion of my filter function: > > void Filtrar() > { > int index = -1; > int inici = -1; > int i; > int sum; > int index2; > > while (1) > { > while (NMostresADCNoves<=0); //Hope new data folling > ADC Interruption > > // CODI DEL FILTRE > index++; if(index>=NCoeff) index=0; > MeuBuf[index]esIn[MostraActualIn]; > sum = 0; > inici++; if(inici>=NCoeff) inici = 0; > index2 = inici; > for(i=0; i<NCoeff; i++) > { > index2++; if(index2>=NCoeff) index2 = 0; > sum = sum + MeuBuf[index2]*Coeff[i]; > } > > DadesOut[MostraActualOut] = sum; > > MostraActualIn++; > MostraActualOut++; > ... > > } |
Reply by ●April 7, 20032003-04-07
I had much the same problem for a filter to downsample audio from 32kHz
to 16kHz; here's my solution for C5402. The result runs about 14 times faster than the original C. Hope it helps. -- GT ; filters.asm .mmregs .def _init_a .def _tx_lpf_a .def _rx_lpf_a .def lpf_in .def lpf_out .def indx_in .def indx_out .ref _qmfbuf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The filter buffers must each start on a 64-word boundary ; as that's the next power of 2 higher than the buffer size. .sect ".data" .align 64 lpf_in: .space 60*16 .align 64 lpf_out: .space 60*16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Other variables. .bss indx_in,1 .bss indx_out,1 .sect ".text" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Initialise the filter sample buffers _init_a: stm lpf_in,ar7 rpt #59 st #0,*ar7+ stm lpf_out,ar7 rpt #59 st #0,*ar7+ st #0,*(indx_in) st #0,*(indx_out) ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Implements a 7kHz lowpass filter which inputs 4 ; 16-bit samples at 32kHz and outputs 2, 14-bit samples at 16kHz ; Register usage: ; AR3 the input pointer ; AR4 the buffer pointer ; AR6 the qmfbuf pointer ; AR7 the 'k' loop counter _tx_lpf_a: ssbx frct ssbx ovm ; Set up the input pointer (passed in A). stlm a,ar3 ; Check the index and reset if necessary. ld *(indx_in),a sub #4,a bc $1,agt ld #60,a $1: ; Resave the index stl a,*(indx_in) ; Set up the buffer pointer add #lpf_in,a stlm a,ar4 ; Set up the circular address size buffer stm #60,bk ; Set up the qmf pointer stm _qmfbuf,ar6 ; Set up the 'K' loop counter stm 1,ar7 $2: ; Copy two values from the input pointer to lpf_in. ; The first instruction is a dummy to decrement the pointer. ld *ar4-%,a ld *ar3+,a stl a,*ar4-% mvdd *ar3+,*ar4 ; Do the multiply-accumulate ld #0,a rpt #59 macp *ar4+%,tx_lpf_coeff,a ; Iterate K. Save the qmf values as we go. banzd $2,*ar7- sth a,-1,*ar6+ nop ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Low-pass filter coefficients for tx. tx_lpf_coeff: .word xx, xx, xx... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Low-pass filter coefficients for rx. ; These are the same coefficients but reorganized ; to permit circular addressing. rx_lpf_coeff_a: .word xx, xx, xx... rx_lpf_coeff_b: .word xx, xx, xx... ----- Original Message ----- From: "narcispr" <> To: <> Sent: Monday, April 07, 2003 12:07 PM Subject: [c54x] Problems whith a FIR implementation. Hello people! I'm very new in DSP programing and I need to implement a FIR filter with 5409 DSP. I try to do with C source (see at the bottom of the document) but this solution is very slow. How can I do a simple passBand or highBand filter? I see a fir function in some examples. Where can I find documentation or examples about fir function? Thank you for all!! A portion of my filter function: void Filtrar() { int index = -1; int inici = -1; int i; int sum; int index2; while (1) { while (NMostresADCNoves<=0); //Hope new data folling ADC Interruption // CODI DEL FILTRE index++; if(index>=NCoeff) index=0; MeuBuf[index]esIn[MostraActualIn]; sum = 0; inici++; if(inici>=NCoeff) inici = 0; index2 = inici; for(i=0; i<NCoeff; i++) { index2++; if(index2>=NCoeff) index2 = 0; sum = sum + MeuBuf[index2]*Coeff[i]; } DadesOut[MostraActualOut] = sum; MostraActualIn++; MostraActualOut++; ... } _____________________________________ Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. _____________________________________ About this discussion group: To Join: Send an email to To Post: Send an email to To Leave: Send an email to Archives: http://www.yahoogroups.com/group/c54x Other Groups: http://www.dsprelated.com ">http://docs.yahoo.com/info/terms/ |
Reply by ●April 8, 20032003-04-08
Look around in the following URL. It's site providing various software implementations of simple DSP applications. http://www.ti.com/sc/docs/general/dsp/programs/shareware/level_c5000.htm Cheers! Bose. On 7 Apr 2003 wrote: > _____________________________________ > Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group. > > _____________________________________ > About this discussion group: > > To Join: Send an email to > > To Post: Send an email to > > To Leave: Send an email to > > Archives: http://www.yahoogroups.com/group/c54x > > Other Groups: http://www.dsprelated.com > > There is 1 message in this issue. > > Topics in this digest: > > 1. Problems whith a FIR implementation. > From: "narcispr" < > ________________________________________________________________________ > ________________________________________________________________________ > > Message: 1 > Date: Mon, 07 Apr 2003 11:07:34 -0000 > From: "narcispr" <> > Subject: Problems whith a FIR implementation. > > Hello people! > > I'm very new in DSP programing and I need to implement a FIR filter > with 5409 DSP. > > I try to do with C source (see at the bottom of the document) but > this solution is very slow. How can I do a simple passBand or highBand > filter? > > I see a fir function in some examples. Where can I find documentation > or examples about fir function? > > Thank you for all!! > A portion of my filter function: > > void Filtrar() > { > int index = -1; > int inici = -1; > int i; > int sum; > int index2; > > while (1) > { > while (NMostresADCNoves<=0); //Hope new data folling > ADC Interruption > > // CODI DEL FILTRE > index++; if(index>=NCoeff) index=0; > MeuBuf[index]esIn[MostraActualIn]; > sum = 0; > inici++; if(inici>=NCoeff) inici = 0; > index2 = inici; > for(i=0; i<NCoeff; i++) > { > index2++; if(index2>=NCoeff) index2 = 0; > sum = sum + MeuBuf[index2]*Coeff[i]; > } > > DadesOut[MostraActualOut] = sum; > > MostraActualIn++; > MostraActualOut++; > ... > > } > ________________________________________________________________________ > ________________________________________________________________________ > > ">http://docs.yahoo.com/info/terms/ -- Never argue with idiots. They drag you down to their level, then beat you with experience. |