我也是觉得很奇怪,只是将信号除以了一个4就出现杂声,我也试过乘以一个小数0.25或者0.5,也会出现杂声,FIR低通滤波我也尝试过,也是出现很大的杂声,当简单将滤波系数扩大为整数后杂声就变小了,但是还是有点大,这是程序,您帮忙看看是哪里的问题,万分感谢!因为以前用C6713(浮点DSP)做过类似的,没出过这些状况,改用DM642(定点DSP)就出现了,会是因为DSP是定点的原因吗?
#include <csl.h>
#include <std.h>
#include <math.h>
#include <csl_emifa.h>
#include <csl_i2c.h>
#include <csl_gpio.h>
#include <csl_irq.h>
#include <csl_chip.h>
#include "iic.h"
#include "seeddm642_aic23.h"
#define MUXL (*(volatile unsigned int *)(0x019c0004))
#define MUXH (*(volatile unsigned int *)(0x019c0000))
#define MAX_BUFFER_SIZE 44000
#define VOL_DELAY MAX_BUFFER_SIZE-100
/*SEEDDM642的emifa的设置结构*/
EMIFA_Config Seeddm642ConfigA ={
0x00052078,/*gblctl EMIFA(B)global control register value */
/*将CLK6、4、1使能;将MRMODE置1;使能EK2EN,EK2RATE*/
0xffffffd3,/*cectl0 CE0 space control register value*/
/*将CE0空间设为SDRAM*/
0x73a28e01,/*cectl1 CE1 space control register value*/
/*Read hold: 1 clock;
MTYPE : 0000,选择8位的异步接口
Read strobe :001110;14个clock宽度
TA:2 clock; Read setup 2 clock;
Write hold :2 clock; Write strobe: 14 clock
Write setup :7 clock
-- ---------------
\ 14c /1c
\----------------/ */
0x22a28a22, /*cectl2 CE2 space control register value*/
0x22a28a42, /*cectl3 CE3 space control register value*/
0x57115000, /*sdctl SDRAM control register value*/
0x0000081b, /*sdtim SDRAM timing register value*/
0x001faf4d, /*sdext SDRAM extension register value*/
0x00000002, /*cesec0 CE0 space secondary control register value*/
0x00000002, /*cesec1 CE1 space secondary control register value*/
0x00000002, /*cesec2 CE2 space secondary control register value*/
0x00000073 /*cesec3 CE3 space secondary control register value*/
};
/*SEEDDM642的IIC的设置结构*/
I2C_Config SEEDDM642IIC_Config = {
0, /* master mode, i2coar;采用主模式 */
0, /* no interrupt, i2cimr;只写,不读,采用无中断方式*/
(20-5), /* scl low time, i2cclkl; */
(20-5), /* scl high time,i2cclkh; */
1, /* configure later, i2ccnt;*/
0, /* configure later, i2csar;*/
0x4ea0, /* master tx mode, */
/* i2c runs free, */
/* 8-bit data + NACK */
/* no repeat mode */
(75-1), /* 4MHz clock, i2cpsc */
};
CHIP_Config SEEDDM642percfg = {
CHIP_VP2+\
CHIP_VP1+\
CHIP_VP0+\
CHIP_I2C+\
CHIP_MCASP0
};
I2C_Handle hSeeddm642i2c;
/*设置需打开的音频的句柄*/
SEEDDM642_AIC23_Handle dm642aic23handle0,dm642aic23handle1;
SEEDDM642_AIC23_Handle dm642aic23handle2,dm642aic23handle3;
/* Internal codec state used to simulate read/write functionality */
SEEDDM642_AIC23_Config codecstate = SEEDDM642_AIC23_DEFAULTCONFIG;
MCASP_Handle SEEDdm642codec;
/********************************************************************/
int jj;
#define FIRNUMBER 16
float fHnL[FIRNUMBER]={
-0.0033,-0.0016,0.0127,0.0118,-0.0468,-0.0547,0.1526,0.4294,0.4294,0.1526,
-0.0547,-0.0468,0.0118,0.0127,-0.0016,-0.0033 }; //1K低通滤波参数
/*int fHnL[FIRNUMBER]={
-33,-16,127,118,-468,-547,1526,4294,4294,1526,
-547,-468,118,127,-16,-33 }; */
float fXn[FIRNUMBER]={ 0.0 };
int i,ii=0,bCode=1;
void InputWave(float);
float FIRL();
/********************************************************************/
extern far void vectors();
int jj,Count_interrupter=0; //测试中断的响应
float codecdata0;
/*此程序可将四个采集口的数据经过Video Port0送出*/
void main()
{
int i;
jj=0;
for(i=0;i<FIRNUMBER;i++)
fXn=0.0;
/*-------------------------------------------------------*/
/* perform all initializations */
/*-------------------------------------------------------*/
/*Initialise CSL,初始化CSL库*/
CSL_init();
CHIP_config(&SEEDDM642percfg);
/*----------------------------------------------------------*/
/*EMIFA的初始化,将CE0设为SDRAM空间,CE1设为异步空间
注,DM642支持的是EMIFA,而非EMIF*/
EMIFA_config(&Seeddm642ConfigA);
/*----------------------------------------------------------*/
/*中断向量表的初始化*/
//Point to the IRQ vector table
IRQ_setVecs(vectors);
CSR=CSR&0xfffffffe;
MUXL =0x18bd;
MUXH =0; //使能MCASP0的接收中断为四号中断
ICR=0xff;
CSR=CSR|1;
IER=0x13;
/*IRQ_nmiEnable();
IRQ_globalEnable();
IRQ_map(IRQ_EVT_VINT1, 11);
IRQ_map(IRQ_EVT_VINT0, 12);
IRQ_reset(IRQ_EVT_VINT1);
IRQ_reset(IRQ_EVT_VINT1); */
/*----------------------------------------------------------*/
/*AIC23B的初始化*/
hSeeddm642i2c = I2C_open(I2C_PORT0,I2C_OPEN_RESET);
I2C_config(hSeeddm642i2c,&SEEDDM642IIC_Config);
/*配置第一路到第四路音频输入*/
/*第一通路AIC23工作在主模式*/
// codecstate.regs[SEEDDM642_AIC23_DIGIF] = 0x13;
dm642aic23handle0 = EVMDM642_AIC23_open(hSeeddm642i2c,0,&codecstate);
/*其它三路工作在从模式*/
/*codecstate.regs[SEEDDM642_AIC23_DIGIF] = 0x13;
dm642aic23handle1 = EVMDM642_AIC23_open(hSeeddm642i2c,1,&codecstate);
dm642aic23handle2 = EVMDM642_AIC23_open(hSeeddm642i2c,2,&codecstate);
dm642aic23handle3 = EVMDM642_AIC23_open(hSeeddm642i2c,3,&codecstate);*/
/*----------------------------------------------------------*/
/*MCASP的初始化*/
SEEDdm642codec = SEEDDM642_AIC23_openCodec();
/*----------------------------------------------------------*/
/*音频的采集与回放*/
for(;;)
{
}
}
void rxvoice(void)
{
if(MCASP_FGETH(SEEDdm642codec,RSTAT,RDATA))
{
codecdata0 = MCASP_RGETH(SEEDdm642codec,RBUF1);
InputWave(codecdata0);
codecdata0=FIRL();
MCASP_RSETH(SEEDdm642codec,XBUF0,codecdata0);
}
else
{
asm(" nop");
}
Count_interrupter++;
}
void InputWave(float a)
{
for ( i=FIRNUMBER-1;i>0;i-- )
fXn=fXn[i-1];
fXn[0]=a;
}
float FIRL()
{
float fSum;
fSum=0;
for ( i=0;i<FIRNUMBER;i++ )
{
fSum+=(float)(fXn*fHnL);
}
return(fSum);
}
/*----------------------------------------------------------*/
//ISR to service TIMERINT1.
// vecs_RINT.asm must be modified to include c_int04 entry.
interrupt void c_int04(void)
{
rxvoice();
return;
} |