Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me solve this FIR digital filter problem

Status
Not open for further replies.

malik_123

Member level 4
Member level 4
Joined
May 14, 2007
Messages
68
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,784
i am using this code for FIR filter

****************************************
#define Ntap 31

#define DCgain 32768

__int16 fir(__int16 NewSample) {
__int16 FIRCoef[Ntap] = {
-40,
-44,
74,
79,
-141,
-143,
273,
257,
-548,
-452,
1169,
738,
-2767,
-1035,
10172,
17581,
10172,
-1035,
-2767,
738,
1169,
-452,
-548,
257,
273,
-143,
-141,
79,
74,
-44,
-40
};

static __int16 x[Ntap]; //input samples
__int32 y=0; //output sample
int n;

//shift the old samples
for(n=Ntap-1; n>0; n--)
x[n] = x[n-1];

//Calculate the new output
x[0] = NewSample;
for(n=0; n<Ntap; n++)
y += FIRCoef[n] * x[n];

return y / DCgain;
}
**********************************************

but when i divide the Y with Dcgain result is always 0 ,

i am using Mplab ide for simulation and CCS as compiler
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top