⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fir_linear_addressing.c

📁 source code c54x FIR filter with linear addressing
💻 C
字号:
/*-----------------------------------------------------*/
/*            FIR filter - linear addressing            */
// filter type:    high pass
// freq:    2 kHz
// fs:      8kHz
// DSP:     TMS320C6455
/*-----------------------------------------------------*/

#include "tonecfg.h"			// configuration data from DSP/BIOS
#include "dsk6455.h"			// function DSK6455
#include "dsk6455_led.h"		// serving function LEDs
#include "dsk6455_dip.h"		// serving function LEDs switches
#include "dsk6455_CODEC.h"		// serving function LEDs switches codec AIC23

#define RAD	20		// stage filter

// codec settings
DSK6455_CODEC_Config config = {
    0x0017, 					// 0 DSK6455_CODEC_LEFTINVOL  Left line input channel volume
    0x0017, 					// 1 DSK6455_CODEC_RIGHTINVOL Right line input channel volume
    0x00ff, 					// 2 DSK6455_CODEC_LEFTHPVOL  Left channel headphone volume
    0x00ff, 					// 3 DSK6455_CODEC_RIGHTHPVOL Right channel headphone volume
    0x0011, 					// 4 DSK6455_CODEC_ANAPATH    Analog audio path control
    0x0000, 					// 5 DSK6455_CODEC_DIGPATH    Digital audio path control
    0x0000, 					// 6 DSK6455_CODEC_POWERDOWN  Power down control
    0x0053, 					// 7 DSK6455_CODEC_DIGIF      Digital audio interface format
   	DSK6455_CODEC_FREQ_8KHZ, 	// 8 DSK6455_CODEC_SAMPLERATE Sample rate control
    0x0001  					// 9 DSK6455_CODEC_DIGACT     Digital interface activation
};

// Declaration of impulse responses
Int16 hDP[RAD+1] = {0,7,0,-25,0,70,0,-176,0,637,1023,637,0,-176,0,70,0,-25,0,7,0,};

// main program
void main()
{
   	Int16 Vzorky[RAD+1];
	Uint16 Akt_Prvek = 0;
	Int32 Soucet;
	Uint32 i, Vzorek;

    DSK6455_init();

	DSK6455_CODEC_openCodec(&config);			// initialization McBSP and codek
	while(1)
		{

		Soucet=0;

		for (i=RAD; i>0;i--) Vzorky[i] = Vzorky [i-1];

		Vzorky[0] = (Int16)(Vzorek >> 16);

		for (i=0; i<RAD+1; i++) Soucet += hDP[i]*Vzorky [i-1]; // convolution

		Soucet /= 2048; // for H(0)=1

		if (Soucet > 32767) Soucet = 32767; // overflow

		if (Soucet < -32768) Soucet = -32768; // underflow

		Vzorek = (Vzorek & 0xFFFF0000) | (Soucet & 0x0000FFFF);
		// sample entry into the right channel
		while (!DSK6455_CODEC_write32(Vzorek));	// Zapis nacteny vzorek zpet do kodeku
		while (!DSK6455_CODEC_read32(&Vzorek));	// Pockej si na vzorek z kodeku
		}



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -