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

📄 ad.c

📁 这个程序主要是用于DSP TMS320F2812进行数据处理
💻 C
字号:

#include "DSP28_Device.h"

float	a1[16];
unsigned int a2=0;
float	adclo=0.0;

// Prototype statements for functions found within this file.
interrupt void ad(void);

void main(void)
{

	InitSysCtrl();

	DINT;
	IER = 0x0000;
	IFR = 0x0000;

	InitPieCtrl();


	InitPieVectTable();	
	
	
	EALLOW;	// This is needed to write to EALLOW protected registers
	PieVectTable.ADCINT=&ad;
	EDIS;   // This is needed to disable write to EALLOW protected registers
    
    InitAdc();

    // Enable INT14 which is connected to CPU-Timer 2:
	IER |= M_INT1;
	//KickDog();
    // Enable global Interrupts and higher priority real-time debug events:
	
	EINT;   // Enable Global interrupt INTM
	ERTM;	// Enable Global realtime interrupt DBGM
	while(AdcRegs.ADC_ST_FLAG.bit.SEQ1_BSY==0)
		{			

			AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;

		}

	for(;;)
	{
			KickDog();
	}
} 	


interrupt void ad(void)
{
	IFR=0x0000;
//	PieCtrl.PIEIFR1.all = 0;
	PieCtrl.PIEACK.all=0xffff;
	a2++;
	a1[0]=((float)AdcRegs.RESULT0)*3.0/65520.0+adclo;
	a1[1]=((float)AdcRegs.RESULT1)*3.0/65520.0+adclo;
	a1[2]=((float)AdcRegs.RESULT2)*3.0/65520.0+adclo;
	a1[3]=((float)AdcRegs.RESULT3)*3.0/65520.0+adclo;
	a1[4]=((float)AdcRegs.RESULT4)*3.0/65520.0+adclo;
	a1[5]=((float)AdcRegs.RESULT5)*3.0/65520.0+adclo;
	a1[6]=((float)AdcRegs.RESULT6)*3.0/65520.0+adclo;
	a1[7]=((float)AdcRegs.RESULT7)*3.0/65520.0+adclo;
	a1[8]=((float)AdcRegs.RESULT8)*3.0/65520.0+adclo;
	a1[9]=((float)AdcRegs.RESULT9)*3.0/65520.0+adclo;
	a1[10]=((float)AdcRegs.RESULT10)*3.0/65520.0+adclo;
	a1[11]=((float)AdcRegs.RESULT11)*3.0/65520.0+adclo;
	a1[12]=((float)AdcRegs.RESULT12)*3.0/65520.0+adclo;
	a1[13]=((float)AdcRegs.RESULT13)*3.0/65520.0+adclo;
	a1[14]=((float)AdcRegs.RESULT14)*3.0/65520.0+adclo;
	a1[15]=((float)AdcRegs.RESULT15)*3.0/65520.0+adclo;
	AdcRegs.ADC_ST_FLAG.bit.INT_SEQ1_CLR=1;
	AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;
	EINT;
	
}

//===========================================================================
// No more.
//===========================================================================

⌨️ 快捷键说明

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