Professional Documents
Culture Documents
Lab12 (Fir 필터 프로그램)
Lab12 (Fir 필터 프로그램)
FIR 필터 프로그램
Practical DSP methods
for FIR Filtering (1)
Input-output relationship for FIR Filtering
𝐾
𝑦 𝑛 = 𝑏𝑖 𝑥 𝑛 − 𝑖
𝑖=0
= 𝑏0 𝑥 𝑛 + 𝑏1 𝑥 𝑛 − 1 + ⋯ + 𝑏𝐾 𝑥 𝑛 − 𝐾
• 𝑏𝑖 : FIR filter coefficients
• 𝐾 + 1: FIR filter length (K: FIR filter degree)
𝑦 𝑛 = ℎ0 𝑥 𝑛 + ℎ1 𝑥 𝑛 − 1 + ⋯ + ℎ𝑀 𝑥 𝑛 − 𝑀
Impulse response, 𝒉 = ℎ0 , ℎ1 , ⋯ , ℎ𝑀
Internal states
– 𝑤0 (𝑛) = 𝑥(𝑛)
– 𝑤1 𝑛 = 𝑥 𝑛 − 1 = 𝑤0 (𝑛 − 1)
– 𝑤𝑀 𝑛 = 𝑥 𝑛 − 𝑀 = 𝑤𝑀−1 (𝑛 − 1)
𝑤0 = 𝑥
𝑦 = ℎ0 𝑤0 + ℎ1 𝑤1 + ⋯ + ℎ𝑀 𝑤𝑀
for 𝑖 = 𝑀, 𝑀 − 1, ⋯ , 1 do:
𝑤𝑖 = 𝑤𝑖−1
#include "LibDSP3x.h”
#include "LibPerip.h”
#include "LibEPP.h"
#define Da_Sel 5
#define Timer 1250
#define Order 40
Y = temp_cal;
ADdata=(int)temp_cal;
for(i=0;i<Order-1;i++)
X[Order-(i+1)] = X[Order-(i+2)];
for(i=0;i<Order;i++)
X[i] = 0;
while(1){
if(Da_Sel==5) {
if(IOcount == Data_siz){
asm(" LDI 0000h, IE "); //Disable Interrupt
-0.00056474350858,
.
.
}
Y=temp_cal;
ADdata=(int)temp_cal; // digital filter 출력
/* 다음 입력표본을 위해 입력 시퀀스를 한 sample delay 시킴 */
for(i=0;i<Order-1;i++)
X[Order-(i+1)]=X[Order-(i+2)];
/* 필터입력 시퀀스와 필터출력 시퀀스를 PC로 전송, Da_Sel=5 */
if (Da_Sel==5) {
Idata[IOcount]=((int)X[1]+0x800) ;
Odata[IOcount]=((int)Y+0x800);
IOcount++;
}
/* PC 전송이 아닌 경우의 처리 루틴 */
else {
ADdata+=0x800;
if (ADdata>0xfff) ADdata=0x0fff;
*DA_MUX=ADdata;//DA_MUX에서 지정한 DAC로 출력
IOcount=IOcount;
}
*ADC_RC=0;
}
}