dsp试验程序Word下载.docx

上传人:b****6 文档编号:21952273 上传时间:2023-02-01 格式:DOCX 页数:14 大小:19.22KB
下载 相关 举报
dsp试验程序Word下载.docx_第1页
第1页 / 共14页
dsp试验程序Word下载.docx_第2页
第2页 / 共14页
dsp试验程序Word下载.docx_第3页
第3页 / 共14页
dsp试验程序Word下载.docx_第4页
第4页 / 共14页
dsp试验程序Word下载.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

dsp试验程序Word下载.docx

《dsp试验程序Word下载.docx》由会员分享,可在线阅读,更多相关《dsp试验程序Word下载.docx(14页珍藏版)》请在冰豆网上搜索。

dsp试验程序Word下载.docx

.bssx,6

.bssy,1

.globalstart

.data

TABLE.WORD1,1,1,1,1,1

.WORD1,2,3,4,5,6

.text

AMOV#(stack+stack_size),XSP

MOV#(sysstack+stack_size),SSP

AMOV#h,AR1

AMOV#TABLE,AR2

RPT#11

MOV*AR2+,*AR1+

CALLSUM

HERE:

BHERE

SUM:

MOV#0000h,AC1

AMOV#h,AR3

AMOV#x,AR4

RPT#5

MACM*AR3+,*AR4+,AC1

MOVHI(AC1<

RET

Shiyan3

.mmregs

.global_asmfunc

_asmfunc:

ADD*AR0,T0,T0

RET

.END

#include"

stdio.h"

externintasmfunc(int,int*);

intgvar;

voidmain()

{inti=8;

gvar=200;

i=asmfunc(i,&

gvar);

while

(1);

}

volume.c

#include<

stdio.h>

csl.h>

csl_pll.h>

csl_chip.h>

csl_irq.h>

csl_gpt.h>

/*DefineandinitializetheGPTmoduleconfigurationstructure*/

GPT_ConfigMyGptConfig={

0,//Emulationmanagementregister

0,//GPIOinterruptcontrolregister

0,//GPIOenableregister

0,//GPIOdirectionregister

0,//GPIOdataregister

0xB9EF,//Timerperiodregister1(主频为1525MHZ)

0x05F5,//Timerperiodregister2

0,//Timerperiodregister3

0,

0x0088,

0x0003,//Timerperiodregister4

/*GPT_GPTCTL1_RMK(//Timercontrolregister1

GPT_GPTCTL1_TIEN_NOT_GATED,//Timer没选通

GPT_GPTCTL1_CLKSRC_VBUS,//外部时钟源驱动TINP引脚

GPT_GPTCTL1_ENAMODE_CONTINUOUS,//定时器不断激活模式

GPT_GPTCTL1_PWID_INACTIVE_1CYCLE,//在定时器到达周期后TSTAT停止计数时钟

GPT_GPTCTL1_CP_CLOCK_MODE,//时钟模式

GPT_GPTCTL1_INVIN_DONT_INVERT_OUTPUT,//不反相TINP驱动定时器

GPT_GPTCTL1_INVOUT_DONT_INVERT_OUTPUT//不反相的TSTAT驱动TOUT

),

GPT_GPTCTL2_RMK(//Timercontrolregister2

GPT_GPTCTL2_TIEN_NOT_GATED,

GPT_GPTCTL2_CLKSRC_VBUS,

GPT_GPTCTL2_ENAMODE_CONTINUOUS,

GPT_GPTCTL2_PWID_INACTIVE_1CYCLE,

GPT_GPTCTL2_CP_CLOCK_MODE,

GPT_GPTCTL2_INVIN_DONT_INVERT_OUTPUT,

GPT_GPTCTL2_INVOUT_DONT_INVERT_OUTPUT

GPT_GPTGCTL1_RMK(//Globaltimercontrolregister

GPT_GPTGCTL1_PSC34_DEFAULT,

GPT_GPTGCTL1_TIMMODE_DEFAULT,//64bit普通模式

GPT_GPTGCTL1_TIM34RS_NOT_IN_RESET,

GPT_GPTGCTL1_TIM12RS_NOT_IN_RESET

)*/

};

/*Function/ISRprototypes*/

interruptvoidTimer0Isr(void);

/*Referencestartofinterruptvectortable*/

/*Thissymbolisdefinedinfile,vectors.s55*/

externvoidVECSTART(void);

/*CreateaTIMER_HandleobjectforusewithTIMER_open*/

GPT_HandlehGpt;

/*Definethepower-offtimelengthofLED*/

#defineTIMECONST60000

Uint16EventId0;

//定时器0所对应的事件ID号

Uint16LEDMARK=0;

//设置指示灯的开关标志

Uint16i=0;

Uint16j=0;

/*通过定义宏来控制两个外围存储器映射的寄存器,从而实现对GPIO口的控制*/

#defineGPIODIR(*(volatileioportUint16*)(0x3400))

#defineGPIODATA(*(volatileioportUint16*)(0x3401))

voidmain(void)

{

/*InitializeCSLlibrary-ThisisREQUIRED!

!

*/

CSL_init();

/*PLLconfigurationstructureusedtosetupPLLinterface*/

//主频为300Mhz

PLL_setFreq(1,0xF,0,1,3,3,0);

/*SetIVPH/IVPDtostartofinterruptvectortable*/

IRQ_setVecs((Uint32)(&

VECSTART));

/*Temporarilydisableallmaskableinterrupts*/

IRQ_globalDisable();

/*OpenTimer0,setregisterstopowerondefaults*/

/*AndreturnhandleofTimer0*/

hGpt=GPT_open(GPT_DEV0,GPT_OPEN_RESET);

/*GetEventIdassociatedwithTimer0,forusewith*/

/*CSLinterruptenablefunctions.*/

EventId0=GPT_getEventId(hGpt);

/*ClearanypendingTimerinterrupts*/

IRQ_clear(EventId0);

/*Placeinterruptserviceroutineaddressat*/

/*associatedvectorlocation*/

IRQ_plug(EventId0,&

Timer0Isr);

/*WriteconfigurationstructurevaluestoTimercontrolregs*/

GPT_config(hGpt,&

MyGptConfig);

/*EnableTimerinterrupt*/

IRQ_enable(EventId0);

/*Enableallmaskableinterrupts*/

IRQ_globalEnable();

/*StartTimer*/

GPT_start(hGpt);

/*ConfigGPIO7inordertoigniteledD5*/

GPIODIR=0x80;

//configtheGPIO7asoutputpin

for(;

{

/*Entersystemloopandwaitingforinterrupt*/

}}

/*定时器0的中断程序*/

interruptvoidTimer0Isr(void)

if(LEDMARK==0)

{GPIODATA=0x00;

/*关闭指示灯D5*/

LEDMARK=1;

/*在此行设置短点*/

}

else

{

GPIODATA=0x80;

/*打开指示灯D5*/

LEDMARK=0;

/*在此行设置短点*/

for(i=0;

i<

TIMECONST;

i++)

{

for(j=0;

j<

100;

j++)

{

CHIP_FSET(ST1_55,XF,0);

/*关指示灯D1*/

}}}}

/*注意:

(1)关闭指示灯D1只是临时的,共计100*TIMECONST个指令周期*/

/*这种临时性主要体现在关闭指示灯D1的操作是在中断处理子程序中进行的*//*而且是对CPU控制寄存器的操作,由于DSP的中断保护和恢复机制*/

/*一旦退出中断处理子程序,关闭指示灯D1的操作自动失效,即指示灯D1又自动点亮*/

*Endof5502_LED.c

#include"

volume.h"

/*Globaldeclarations*/

intin1_buffer[BUFSIZE];

//BUFSIZE=100

intin2_buffer[BUFSIZE];

/*处理数据缓冲器*/

intout1_buffer[BUFSIZE];

intout2_buffer[BUFSIZE];

intout3_buffer[BUFSIZE];

intout4_buffer[BUFSIZE*2];

intsize=BUFSIZE;

intain=MINGAIN;

//ain=1

intzhy=0;

intsk=64;

/*sk代表所开的bufsize的大小.输入文件sine.dat为32点,sine11.dat,

sin22.dat,sin33.dat,sin44.dat为64点的输入波形.*/

/*Functions*/

staticintstep1(int*output1,int*output2);

staticintstep2(int*output2,int*output3);

staticintstep3(int*input1,int*output2,int*output4);

staticintstep4(int*input2,int*output1);

staticvoiddataIO1(void);

staticvoiddataIO2(void);

voidmain()

int*input1=&

in1_buffer[0];

int*input2=&

in2_buffer[0];

int*output1=&

out1_buffer[0];

int*output2=&

out2_buffer[0];

int*output3=&

out3_buffer[0];

int*output4=&

out4_buffer[0];

puts("

volumeexamplestarted\n"

);

/*loopforever*/

while(TRUE)

{

/**读输入数据使用一个probe-point使与一个连接主机文件。

写输出数据一个图形连通过一个probe-point。

*/

dataIO1();

//breakpoint

dataIO2();

step4(input2,output1);

step1(output1,output2);

step2(output2,output3);

step3(input1,output2,output4);

}}

/*函数声明:

卷积的四个步骤*/

/*功能:

申请信号处理改造输入信号。

参数:

地址的输入和输出调整系统缓冲参数。

/*step4对输出的input2buffer波形截取m,然后把生成的波形上的各点*/

/*的值存入以output1指针开始的一段地址空间中*/

staticintstep4(int*input2,int*output1)

intm=sk;

//m=64

m>

=0;

m--)//截取65点

*output1++=*input2++*ain;

(size-m)>

0;

m++)//65点以后清零

output1[m]=0;

return(TRUE);

}

/*step1对输入的output1buffer波形进行截取m点,再以零点的Y轴为对*/

/*称轴进行翻转,把生成的波形上的值存入以output2指针开始的*/

/*一段地址空间中*/

staticintstep1(int*output1,int*output2)//怎么反转的?

{intm=sk-1;

m--)

*output2++=*output1++*ain;

/*step2对输出的output2buffer波形进行作n点移位,然后把生成的波形*/

/*上的值存入以output3指针开始的一段地址空间中*/

staticintstep2(int*output2,int*output3)

{intn=zhy;

//n=0

size=BUFSIZE;

(size-n)>

n++)

*output3++=output2[n];

/*step3对输入的output2buffer波形和输入的input1buffer作卷积运算*/

/*然后把生成的波形上的各点的值存入以output4指针开始的一段*/

/*地址空间中*/

staticintstep3(int*input1,int*output2,int*output4)//计算卷积

{

inty=zhy;

//y=0

intz,x,w,i,f,g;

(m-y)>

{i=y;

x=0;

z=0;

f=y;

i>

i--)

{g=input1[z]*output2[f];

x=x+g;

z++;

f--;

*output4++=x;

y++;

m=sk;

y=sk-1;

w=m-zhy-1;

{y--;

i=y;

z=sk-1;

f=sk-y;

i--,z--,f++)

g=input1[z]*output2[f];

out4_buffer[w]=x;

w++;

}

dataIO*/

读输入信号,写处理输出信号。

staticvoiddataIO1()

/*dodataI/O*/

return;

staticvoiddataIO2()

Hfir2

math.h"

tms320.h"

dsplib.h"

//#include"

#definePI3.1415926

#defineNX300

#defineNH80

shortx[NX];

#pragmaDATA_SECTION(h,"

.coeffs"

DATAh[NH]={

-7,46,146,-144,-1283,6456,-894,-337,49,48,

-18,20,204,162,-1222,5618,-297,-371,-43,33,

-24,-24,187,476,-562,4142,261,-268,-97,11,

-22,-73,81,661,697,2373,603,-91,-104,-9,

-9,-104,-91,603,2373,697,661,81,-73,-22,

11,-97,-268,261,4142,-562,476,187,-24,-24,

33,-43,-371,-297,5618,-1222,162,204,20,-18,

48,49,-337,-894,6456,-1283,-144,146,46,-7

#pragmaDATA_SECTION(db,"

.dbuffer"

DATAdb[NH+2];

DATAr[NX];

DATA*dbptr=&

db[0];

inti;

shortx[NX];

for(i=0;

NX;

i++)x[i]=0;

{x[i]=(short)(63*sin(PI*300*i/15000)+63*sin(PI*8000*i/15000));

//clear

i<

i++)r[i]=0;

//clearoutputbuffer(optional)

NH+2;

i++)db[i]=0;

//cleardelaybuffer(amust)

//compute

fir2(x,h,r,dbptr,NX,NH);

//双MAC运算,速度快

//fir(x,h,r,dbptr,NX,NH);

//单MAC运算,速度相对双MAC要慢一些

Fir2

test.h"

shorti;

shorteflag1=PASS;

shorteflag2=PASS;

aafir2

17,22,17,2,-17,-34,-37,-22,

12,52,77,67,16,-61,-129,-148,

-91,32,173,260,232,72,-168,-381,

-447,-293,55,466,740,696,268,-437,

-1139,-1470,-1110,71,1933,4078,5957,7054,

7054,5957,4078,1933,71,-1110,-1470,-1139,

-437,268,696,740,466,55,-293,-447,

-381,-168,72,232,260,173,32,-91,

-148,-129,-61,16,67,77,52,12,

-22,-37,-34,-17,2,17,22,17}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1