66 lines
2.4 KiB
C
66 lines
2.4 KiB
C
// TI File $Revision: /main/5 $
|
|
// Checkin $Date: October 23, 2007 13:34:09 $
|
|
//###########################################################################
|
|
//
|
|
// FILE: DSP2833x_Adc.c
|
|
//
|
|
// TITLE: DSP2833x ADC Initialization & Support Functions.
|
|
//
|
|
//###########################################################################
|
|
// $TI Release: DSP2833x/DSP2823x Header Files V1.20 $
|
|
// $Release Date: August 1, 2008 $
|
|
//###########################################################################
|
|
|
|
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
|
|
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
|
|
|
|
#define ADC_usDELAY 5000L
|
|
|
|
//---------------------------------------------------------------------------
|
|
// InitAdc:
|
|
//---------------------------------------------------------------------------
|
|
// This function initializes ADC to a known state.
|
|
//
|
|
void InitAdc(void)
|
|
{
|
|
extern void DSP28x_usDelay(Uint32 Count);
|
|
|
|
|
|
// *IMPORTANT*
|
|
// The ADC_cal function, which copies the ADC calibration values from TI reserved
|
|
// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
|
|
// Boot ROM. If the boot ROM code is bypassed during the debug process, the
|
|
// following function MUST be called for the ADC to function according
|
|
// to specification. The clocks to the ADC MUST be enabled before calling this
|
|
// function.
|
|
// See the device data manual and/or the ADC Reference
|
|
// Manual for more information.
|
|
|
|
EALLOW;
|
|
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
|
|
ADC_cal();
|
|
EDIS;
|
|
|
|
|
|
|
|
|
|
// 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_RATE define statement in the DSP2833x_Examples.h file must
|
|
// contain the correct CPU clock period in nanoseconds.
|
|
|
|
AdcRegs.ADCREFSEL.bit.REF_SEL = 0x01;
|
|
AdcRegs.ADCTRL3.all = 0x00E0; // Power up bandgap/reference/ADC circuits
|
|
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
|
|
//pause_us(50L);
|
|
}
|
|
|
|
|
|
//===========================================================================
|
|
// End of file.
|
|
//===========================================================================
|