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

📄 dsp280x_adc.c

📁 SVPWM算法的DSP源码已通过硬件验证
💻 C
字号:

// TI File $Revision: /main/1 $
// Checkin $Date: December 1, 2004   11:11:30 $
//###########################################################################
//
// FILE:	DSP280x_Adc.c
//
// TITLE:	DSP280x ADC Initialization & Support Functions.
//
//###########################################################################
// $TI Release: DSP280x Header Files V1.60 $
// $Release Date: December 3, 2007 $
//###########################################################################

#include "DSP280x_Device.h"     // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File

//#define ADC_usDELAY  5000L


//---------------------------------------------------------------------------
// InitAdc: 
//---------------------------------------------------------------------------
// This function initializes ADC to a known state.
//
// PLEASE NOTE, ADC INIT IS DIFFERENT ON 281x vs 280x DEVICES!!!
//
void InitAdc(void)
{
   extern void DSP28x_usDelay(Uint32 Count);

    // To powerup the ADC the ADCENCLK bit should be set first to enable
    // clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
    // Before the first conversion is performed a 5ms delay must be observed 
	// after power up to give all analog circuits time to power up and settle

    // Please note that for the delay function below to operate correctly the 
	// CPU_CLOCK_SPEED define statement in the DSP280x_Examples.h file must 
	// contain the correct CPU clock period in nanoseconds. 

    AdcRegs.ADCTRL3.all = 0x00E0;  // Power up bandgap/reference/ADC circuits
    //DELAY_US(ADC_usDELAY);         // Delay before converting ADC channels
    DelayUs(50);
}	


void user_setup_adc(void)
{
	AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_ACQ_PS;
	AdcRegs.ADCTRL1.bit.CPS = ADC_CPS;
	AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_ADCCLKPS;

	AdcRegs.ADCTRL1.bit.CONT_RUN = 0;				// 启动停止,Discontinuous run
	AdcRegs.ADCTRL1.bit.SEQ_CASC = 1;				// 级联模式,1 -> Cascaded mode,16Ch SEQ
	AdcRegs.ADCTRL3.bit.SMODE_SEL = 0;				// 顺序采样模式,0->Sequential; 1->Simultaneous;
    AdcRegs.ADCTRL2.bit.EPWM_SOCA_SEQ1 = 1;         //EPWM1中断启动ADC
	AdcRegs.ADCREFSEL.bit.REF_SEL = 0x00;			// 内部参考

	AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 14;		// 15道

	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 = 0xa;
	AdcRegs.ADCCHSELSEQ3.bit.CONV11 = 0xb;
	AdcRegs.ADCCHSELSEQ4.bit.CONV12 = 0xc;
	AdcRegs.ADCCHSELSEQ4.bit.CONV13 = 0xd;
	AdcRegs.ADCCHSELSEQ4.bit.CONV14 = 0xe;
}

⌨️ 快捷键说明

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