Sign in

username:

password:



Not a member?

Search c54x



Search tips

Subscribe to c54x



c54x by Keywords

5409 | 5416 | AD5 | ADC | BIOS | Boot | Booting | Bootloader | C540 | C5402 | C5409 | C5416 | CCS | Codec | DMA | Dmad | DSK | DSKPlus | Dsplib | EVM | FFT | FIR | Flash | GPIO | HPI | Initialization | Interrupt | JTAG | LOG_printf | MCBSP | RFFT | RTDX | Sampling | STLM | UART | VC540

Ads

Discussion Groups

Discussion Groups | TMS320C54x | Problems whith a FIR implementation.

Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).

  

Post a new Thread

Problems whith a FIR implementation. - narcispr - Apr 7 11:07:00 2003



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]=DadesIn[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++;
...

}






(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )

Re: Problems whith a FIR implementation. - Doni Dewantono - Apr 7 15:44:00 2003

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]=DadesIn[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++;
> ...
>
> }




(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )

Re: Problems whith a FIR implementation. - Graham Trott - Apr 7 16:04:00 2003

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]=DadesIn[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++;
...

}

_____________________________________




(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )

Re: Problems whith a FIR implementation. - Sriranjan Bose - Apr 8 15:24:00 2003

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:

> _____________________________________ > ------------------------------------------------------------------------
>
> 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]=DadesIn[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++;
> ...
>
> } > ________________________________________________________________________
> ________________________________________________________________________ >

--
Never argue with idiots. They drag you down to their level, then
beat you with experience.





(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )