You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CCS-COMM_BOARD/F28335/DSP2833x_Adc.c

71 lines
2.3 KiB
C

//###########################################################################
//
// FILE: DSP2833x_Adc.c
//
// TITLE: DSP2833x ADC Initialization & Support Functions.
//
//###########################################################################
// $TI Release: F2833x/F2823x Header Files and Peripheral Examples V142 $
// $Release Date: November 1, 2016 $
// $Copyright: Copyright (C) 2007-2016 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################
//
// Included Files
//
#include "F28335/DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "F28335/DSP2833x_Examples.h" // DSP2833x Examples Include File
//
// Defines
//
#define ADC_usDELAY 5000L
//
// InitAdc - This function initializes ADC to a known state.
//
void
InitAdc(void)
{
//extern void DSP28x_usDelay(Uint32 Count);
extern void DelayUs(Uint16);
//
// *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.ADCTRL3.all = 0x00E0; // Power up bandgap/reference/ADC circuits
DELAY_US(5000); // Delay before converting ADC channels
//
}
//
// End of file
//