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

📄 dspad.c

📁 将定点DS2812P采样的值
💻 C
字号:

//
//      TMDX ALPHA RELEASE
//      Intended for product evaluation purposes
//
//###########################################################################
//
// FILE:	DSP281x_AdcDSP1.c
//
// TITLE:	DSP28 ADC Initialization & Support Functions.
//
//###########################################################################
//
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  0.55| 06 May 2002 | L.H. | EzDSP Alpha Release
//  0.56| 20 May 2002 | L.H. | No change
//  0.57| 27 May 2002 | L.H. | No change
//###########################################################################

#include "DSP281x_Device.h"
#include "DSPAD.h"
//---------------------------------------------------------------------------
// InitAdc: 
//---------------------------------------------------------------------------
// This function initializes ADC to a known state.
//
//#define ADC_MODCLK 0x3   // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3)         = 25MHz
struct ADC_Data ADCSplData;

void InitAdcDSP1(void)
{
	AdcRegs.ADCTRL1.bit.SEQ_CASC=1;
	// Configure ADC
//   AdcRegs.ADCMAXCONV.all = 0x0001;       // Setup 2 conv's on SEQ1
   AdcRegs.ADCMAXCONV.all = 0x00FF;       // Setup 1 conv's on SEQ1
//   AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; // Setup ADCINA0 as 1st SEQ1 conv.
//   AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x2; // Setup ADCINA2 as 2nd SEQ1 conv.
//CONVnn and the chanel relationship 
	AdcRegs.ADCCHSELSEQ1.bit.CONV00=0;
	AdcRegs.ADCCHSELSEQ1.bit.CONV01=1;
	AdcRegs.ADCCHSELSEQ1.bit.CONV02=2;
	AdcRegs.ADCCHSELSEQ1.bit.CONV03=3;
	
	AdcRegs.ADCCHSELSEQ2.bit.CONV04=4;
	AdcRegs.ADCCHSELSEQ2.bit.CONV05=5;
	AdcRegs.ADCCHSELSEQ2.bit.CONV06=6;
	AdcRegs.ADCCHSELSEQ2.bit.CONV07=7;
	
	AdcRegs.ADCCHSELSEQ3.bit.CONV08=8;
	AdcRegs.ADCCHSELSEQ3.bit.CONV09=9;
	AdcRegs.ADCCHSELSEQ3.bit.CONV10=10;
	AdcRegs.ADCCHSELSEQ3.bit.CONV11=11;
	
	AdcRegs.ADCCHSELSEQ4.bit.CONV12=12;
	AdcRegs.ADCCHSELSEQ4.bit.CONV13=13;
	AdcRegs.ADCCHSELSEQ4.bit.CONV14=14;
	AdcRegs.ADCCHSELSEQ4.bit.CONV15=15;

   AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1 = 1;  // Enable EVASOC to start SEQ1
   AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  // Enable SEQ1 interrupt (every EOS)

// Configure EVA
// Assumes EVA Clock is already enabled in InitSysCtrl();
   EvaRegs.T1CMPR = 0x0;               // Setup T1 compare value
   EvaRegs.T1PR = 0x0A2C;                 // Setup period register
   EvaRegs.GPTCONA.bit.T1TOADC = 0x2;       // Enable EVASOC in EVA
   EvaRegs.T1CON.all = 0x1042;            // Enable timer 1 compare (upcount mode)

	
}


void GetResult(void)
{

	ADCSplData.AI.word.A0=AdcRegs.ADCRESULT0>>4;	
	ADCSplData.AI.word.A1=AdcRegs.ADCRESULT1>>4;
	ADCSplData.AI.word.A2=AdcRegs.ADCRESULT2>>4;
	ADCSplData.AI.word.A3=AdcRegs.ADCRESULT3>>4;
	ADCSplData.AI.word.A4=AdcRegs.ADCRESULT4>>4;
	ADCSplData.AI.word.A5=AdcRegs.ADCRESULT5>>4;
	ADCSplData.AI.word.A6=AdcRegs.ADCRESULT6>>4;
	ADCSplData.AI.word.A7=AdcRegs.ADCRESULT7>>4;
	ADCSplData.AI.word.A8=AdcRegs.ADCRESULT8>>4;
	ADCSplData.AI.word.A9=AdcRegs.ADCRESULT9>>4;
	ADCSplData.AI.word.A10=AdcRegs.ADCRESULT10>>4;
	ADCSplData.AI.word.A11=AdcRegs.ADCRESULT11>>4;
	ADCSplData.AI.word.A12=AdcRegs.ADCRESULT12>>4;
	ADCSplData.AI.word.A13=AdcRegs.ADCRESULT13>>4;
	ADCSplData.AI.word.A14=AdcRegs.ADCRESULT14>>4;
	ADCSplData.AI.word.A15=AdcRegs.ADCRESULT15>>4;
/*	float	adclo=0.0;
	ADCSplData.AI.word.A1=((float)AdcRegs.ADCRESULT0)*3.0/65520.0+adclo;	
	ADCSplData.AI.word.A2=((float)AdcRegs.ADCRESULT1)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A3=((float)AdcRegs.ADCRESULT2)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A4=((float)AdcRegs.ADCRESULT3)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A5=((float)AdcRegs.ADCRESULT4)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A6=((float)AdcRegs.ADCRESULT5)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A7=((float)AdcRegs.ADCRESULT6)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A8=((float)AdcRegs.ADCRESULT7)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A9=((float)AdcRegs.ADCRESULT8)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A10=((float)AdcRegs.ADCRESULT9)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A11=((float)AdcRegs.ADCRESULT10)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A12=((float)AdcRegs.ADCRESULT11)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A13=((float)AdcRegs.ADCRESULT12)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A14=((float)AdcRegs.ADCRESULT13)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A15=((float)AdcRegs.ADCRESULT14)*3.0/65520.0+adclo;
	ADCSplData.AI.word.A16=((float)AdcRegs.ADCRESULT15)*3.0/65520.0+adclo;   */
//	AdcRegs.ADCST.bit.INT_SEQ1_CLR=1;   //clear the interrupt
	AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;    //start the conservation
}

⌨️ 快捷键说明

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