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

📄 adccalibrationinitadc.c

📁 DSP2812片内AD校准代码
💻 C
字号:
//###########################################################################
//
// FILE:	ADCcalibrationInitAdc.c
//
// TITLE:	Initialize ADC for ADC Calibration Driver Program.
//
//###########################################################################
//
// Ver  | dd-mmm-yyyy |  Who  | Description of changes
// =====|=============|=======|==============================================
//  1.0 | 20 Jun 2003 | AT/SD | Original Release.
// -----|-------------|-------|----------------------------------------------
//  1.1 | 26 Nov 2004 | AT    | Fixed Bug In ADCcalibrationInitADC function.
//      |             |       | Was incorrectly disabling ADC clock.
//
//###########################################################################


#include "DSP28_Device.h"
#include "ADCcalibrationDriver.h"

extern void DSP28x_usDelay(unsigned long Count);

#define ADC_usDELAY  5000L
#define ADC_usDELAY2  20L


void ADCcalibrationInitAdc(void)
{
	//----------------------------------------------------------------------
    // To powerup the ADC the ADCENCLK bit should be set first to enable
    // clocks, followed by powering up the bandgap and reference circuitry.
    // After a 5ms delay the rest of the ADC can be powered up. After ADC
    // powerup, another 20us delay is required before performing the first
    // ADC conversion. 
	//
	// V1.1: Fixed bug. Was disabling clock but disabling was not working
	//       because EALLOW and EDIS did not ave a space and hence were
	//       treated as labels. ADC clock was enabled in a previous function
	//       so thats why V1.0 program worked anyway.
	asm(" EALLOW");
	SysCtrlRegs.PCLKCR.bit.ADCENCLK=1;      // Power up clocks to ADC
	asm(" EDIS");

	AdcRegs.ADCTRL3.bit.ADCBGRFDN = 0x3;	// Power up bandgap/reference circuitry
	DELAY_US(ADC_usDELAY);                  // Delay before powering up rest of ADC
	AdcRegs.ADCTRL3.bit.ADCPWDN = 1;		// Power up rest of ADC
	DELAY_US(ADC_usDELAY);                  // Delay after powering up ADC
	AdcRegs.ADCTRL3.bit.ADCCLKPS=3;			// ADCCLK=25Mhz
	AdcRegs.ADCTRL1.bit.ACQ_PS=6; 			// Acq Time=3ADC CLK

	//----------------------------------------------------------------------
	// ADC is configurred for either sequential or simultaneous mode of
	// conversion:
	//
	// SEQUENTIAL:   ADC channels are converted one at a time:
	//               A0->A1->A2->...B0->B1->B2->....
	// 
	// SIMULTANEOUS: ADC channels are converted in pairs:
	//               A0->A1->A2->....
	//               B0  B1  B2
	//
	// The mapping of the ADC channel pins to ADC result registers for
	// sequnetial or simultaneous mode is given below:
	//
	// SEQUENTIAL:   ADC channels are converted one at a time:
	//               A0 -> ADCRESULT0
	//               A1 -> ADCRESULT1
	//               A2 -> ADCRESULT2
	//               A3 -> ADCRESULT3
	//               A4 -> ADCRESULT4
	//               A5 -> ADCRESULT5
	//               A6 -> ADCRESULT6
	//               A7 -> ADCRESULT7
	//               B0 -> ADCRESULT8
	//               B1 -> ADCRESULT9
	//               B2 -> ADCRESULT10
	//               B3 -> ADCRESULT11
	//               B4 -> ADCRESULT12
	//               B5 -> ADCRESULT13
	//               B6 -> ADCRESULT14
	//               B7 -> ADCRESULT15
	// 
	// SIMULTANEOUS: ADC channels are converted in pairs:
	//               A0 -> ADCRESULT0
	//               A1 -> ADCRESULT2
	//               A2 -> ADCRESULT4
	//               A3 -> ADCRESULT6
	//               A4 -> ADCRESULT8
	//               A5 -> ADCRESULT10
	//               A6 -> ADCRESULT12
	//               A7 -> ADCRESULT14
	//               B0 -> ADCRESULT1
	//               B1 -> ADCRESULT3
	//               B2 -> ADCRESULT5
	//               B3 -> ADCRESULT7
	//               B4 -> ADCRESULT9
	//               B5 -> ADCRESULT11
	//               B6 -> ADCRESULT13
	//               B7 -> ADCRESULT15
	//

	#if ADC_SAMPLING_MODE == SIMULTANEOUS 
	AdcRegs.ADCTRL3.bit.SMODE_SEL = 1;
    AdcRegs.ADCMAXCONV.all = 7;       		
	#endif

	#if ADC_SAMPLING_MODE == SEQUENTIAL
	AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;
    AdcRegs.ADCMAXCONV.all = 15;       
    #endif	

    AdcRegs.ADCCHSELSEQ1.all= 0x3210; 
    AdcRegs.ADCCHSELSEQ2.all= 0x7654; 
    AdcRegs.ADCCHSELSEQ3.all= 0xba98; 
    AdcRegs.ADCCHSELSEQ4.all= 0xfedc;
    AdcRegs.ADCTRL1.bit.SEQ_CASC=0x1;

	//----------------------------------------------------------------------
	// ADC is configured to start a conversion from the SOC signal
	// generated by EV-A:
	//
    AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1 = 1;  // Enable EVASOC to start SEQ1
    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;  // Enable SEQ1 interrupt (every EOS)	
}	

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

⌨️ 快捷键说明

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