📄 fir16d.c
字号:
/* ==============================================================================
System Name: Generic FIR Filter Demo, This system uses FIRFILT_GEN module
File Name: FIRGD.C
Description: Primary System file for demonstrating the FIR Filter
Originator: Digital control systems Group - Texas Instruments
Target dependency: C28x
Description:
============
This software demonstrates the FIR Filter Usage
The frame work, for demonstrating the FILTER is given below
CH0 |--------------| |------------| |-----------|
---->| | | | | |
CH0 | | | | | |
---->| | input | | Output | EVMDAC |
CH0 | ADC04U_DRV |-----|---->| FIR |-------------->| PWMDAC |
---->| | | | FILTER | | DATALOG |
CH0 | | | | | |--->| |
--|->| | | | | | | |
|--------------| | |------------| | |-----------|
| |
|-----------------------------|
*/
#include <sgen.h>
#include <dlog4ch.h>
#include <fir.h>
/* Create an instance of Signal generator module */
SGENTI_1 sgen = SGENTI_1_DEFAULTS;
/* Create an instance of DATALOG Module */
DLOG_4CH dlog=DLOG_4CH_DEFAULTS;
/* Filter Symbolic Constants */
#define FIR_ORDER 50
/* Create an Instance of FIRFILT_GEN module and place the object in "firfilt" section */
#pragma DATA_SECTION(fir, "firfilt");
FIR16 fir= FIR16_DEFAULTS;
/* Define the Delay buffer for the 50th order filterfilter and place it in "firldb" section */
#pragma DATA_SECTION(dbuffer,"firldb");
long dbuffer[(FIR_ORDER+2)/2];
/* Define Constant Co-efficient Array and place the
.constant section in ROM memory */
long const coeff[(FIR_ORDER+2)/2]= FIR16_LPF50;
/* Finter Input and Output Variables */
int xn,yn;
void main()
{
/* Signal Generator module initialisation */
sgen.offset=0;
sgen.gain=0x7fff; /* gain=1 in Q15 */
sgen.freq=9830; /* freq = (Required Freq/Max Freq)*2^15 */
/* = (3000/10000)*2^15 = 5369 */
sgen.step_max=0x7FFF; /* Max Freq= (step_max * sampling freq)/65536 */
/* Max Freq = (32767*20k)/65536 = 10,000 */
/* DATALOG module initialisation */
dlog.iptr1=&xn;
dlog.iptr2=&yn;
dlog.trig_value=0x800;
dlog.size=0x400;
dlog.init(&dlog);
/* FIR Generic Filter Initialisation */
fir.order=FIR_ORDER;
fir.dbuffer_ptr=dbuffer;
fir.coeff_ptr=(long *)coeff;
fir.init(&fir);
/*---------------------------------------------------------------------------
Nothing running in the background at present
----------------------------------------------------------------------------*/
while(1)
{
sgen.calc(&sgen);
xn=sgen.out;
fir.input=xn;
fir.calc(&fir);
yn=fir.output;
dlog.update(&dlog);
}
} /* End: main() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -