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

📄 main1.c

📁 DSP5410控制AD50进行数字录音实验
💻 C
字号:
#include "5410reg.h"
#include "stdio.h"

#define Foffset 20000
#define fc_clock port2000
#define temp port6000
#define LowPass 0
#define HighPass 1
#define BandPass 2
ioport unsigned fc_clock;
ioport unsigned temp;

//McBSP2初始化表
const unsigned short init_tblx[][2]=
{
{0,0x0000},
{1,0x0200},
//上两目使McBSP1处于复位状态
{2,0x0040},
{3,0x0000},
{4,0x0040},
{5,0x0000},

{6,0x0101},
{7,0x2000},
{8,0x0000},
{9,0x0000},
{10,0x0000},
{11,0x0000},
{12,0x0000},
{13,0x0000},
{14,0x000c},
//下两目使McBSP 开始工作
{0,0x0001},
{1,0x0043}
};

short *init_tbl=(short*)init_tblx;
int mtmp;
int Type;

void Delay()
{
    int temp,ft;
    for(ft=0;ft<100;ft++)
    	for (temp=0;temp<1000;temp++) ;
}


void ShortDelay()
{
	int tmp;
	for(tmp=0;tmp<100;tmp++) ;
}
void MainDelay(unsigned int count)
{
	int tmp;
	for(tmp=0;tmp<count;tmp++);
}


void initMCBSP()
{
int i,j;

//	asm(" ssbx INTM ");

	for(i=0;i<17;i++)
	{
		SPSA2=init_tbl[i*2+0];
		for(j=0;j<100;j++);
		MCBSP2  =init_tbl[i*2+1];
		for(j=0;j<100;j++);
	}
	Delay();	
}

void initDMA()
{
	
	IMR=0X1000;        //DMA  4通道中断使能
	
	asm("	rsbx intm");  //  开放所有可屏蔽中断
	
	DMSA=0x0014;         // 选择DMA4通道
	DMSRC1=0x0031;      //  设置串口1接收端为DMA事件的源地址
	DMDST1=0x2000;      //   设置DMA事件的目的地址
	DMCTR1=0x3000;       //设置直接传送数据个数
	DMSFC1=0x5000;     //  设置DMA为多帧模式,源地址不调整目的地址按57h的值调整
	
    DMSA=0x0020;
    DMIDX0=0x0001;     //设置目的地址为自动加1调整
    DMPERC=0x1090;     // 设置通道4为高优先级并使能通道4

}


void WriteAD50(unsigned int Data)
{
	/*int tmp;
	
	tmp=fc_clock;    
    while((fc_clock&0x40)==0) ;
    asm (" nop");
    asm (" nop");    
    fc_clock=0x10;           
    asm (" nop");          
    tmp=fc_clock;
    while((tmp&0x40)) tmp=fc_clock;
     //asm (" nop");    
    tmp=fc_clock;
    while((tmp&0x40)==0) tmp=fc_clock;
    fc_clock=0x0;
    fc_clock=0x0;
    DXR12=Data;   //给TLC320AD50C的寄存器编程
    SPSA2=0x0001;  //
    while(  (MCBSP2&0x0002)==0);  //数据是否被TLC320AD50C接收
    asm (" nop");
    asm (" nop");
    ShortDelay();
    asm (" nop");
    asm (" nop");*/
    DXR12=0x0001;   //给TLC320AD50C的寄存器编程
    SPSA2=0x0001;  //
    while(  (MCBSP2&0x0002)==0);  //数据是否被TLC320AD50C接收
    DXR12=Data;   //给TLC320AD50C的寄存器编程
    SPSA2=0x0001;  //
    while(  (MCBSP2&0x0002)==0);  //数据是否被TLC320AD50C接收
}

void initAD50()
{
	//int tmp;
	WriteAD50(0x0180);   //给TLC320AD50C的寄存器1编程,使其复位
	WriteAD50(0x0180);   //给TLC320AD50C的寄存器1编程,使其复位
	MainDelay(100);
	WriteAD50(0x0101);    //TLC320AD50C脱离复位并且设置寄存器1,使INP,INM为输入
	
	WriteAD50(0x0101);    //TLC320AD50C脱离复位并且设置寄存器1,使INP,INM为输入
	asm (" nop");
	WriteAD50(0x0210);    //设置TLC320AD50C寄存器2,使电话模式无效
	asm (" nop");
	WriteAD50(0x0411);     //设置TLC320AD50C寄存器4,使采样频率为10.667KHz
	asm (" nop");
	asm (" nop");
	WriteAD50(0x0301);      //设置TLC320AD50C寄存器3,使带0个从机
	asm("	nop");	 	
}


void initDSP()
{
    asm(" ssbx intm");
   fc_clock=0x0;
   PMST=0xFFC3;
   IFR=0x3fff;
    
} 

void main()
{
	int i;
	initDSP();
	initMCBSP();
 	initAD50();
 	initDMA();   
   while(1){
   //initMCBSP();
 	//initAD50();
 	//initDMA();
     for(i=0;i<6000;i++)
    {
    	SPSA2=0x0000;
    	while((MCBSP2&0x0002)==0);
    	mtmp=DRR12;	
    	DXR12=mtmp;
    }
	}
}     	

⌨️ 快捷键说明

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