Other Parts Discussed in Thread: C2000WARE
For some reason I'm just getting values for ADCRESULT0 and ADCRESULT1.
I want to read 14 ADCRESULT values.
Thanks for any insights to help me understand what's happening.
Mechi
// TI File $Revision: /main/2 $ // Checkin $Date: February 20, 2009 15:37:05 $ //########################################################################### // // FILE: DSP2803x_Adc.c // // TITLE: DSP2803x ADC Initialization & Support Functions. // //########################################################################### // $TI Release: DSP2803x C/C++ Header Files V1.10 $ // $Release Date: July 27, 2009 $ //########################################################################### #include "DSP2803x_Device.h" // DSP2803x Headerfile Include File #include "DSP2803x_Examples.h" // DSP2803x Examples Include File #define ADC_usDELAY 1000L //--------------------------------------------------------------------------- // InitAdc: //--------------------------------------------------------------------------- // This function initializes ADC to a known state. // // NOTE: ADC INIT IS DIFFERENT ON 2803x DEVICES COMPARED TO OTHER 28X DEVICES // void InitAdc(void) { // *IMPORTANT* // The Device_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; (*Device_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 DSP2803x_Examples.h file must // contain the correct CPU clock period in nanoseconds. EALLOW; AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select internal BG EDIS; DELAY_US(ADC_usDELAY); // Delay before converting ADC channels } void InitAdcAio() { EALLOW; /* Configure ADC pins using AIO regs*/ // This specifies which of the possible AIO pins will be Analog input pins. // NOTE: AIO1,3,5,7-9,11,13,15 are analog inputs in all AIOMUX1 configurations. // Comment out other unwanted lines. GpioCtrlRegs.AIOMUX1.bit.AIO2 = 2; // Configure AIO2 for A2 (analog input) operation GpioCtrlRegs.AIOMUX1.bit.AIO4 = 2; // Configure AIO4 for A4 (analog input) operation GpioCtrlRegs.AIOMUX1.bit.AIO6 = 2; // Configure AIO6 for A6 (analog input) operation GpioCtrlRegs.AIOMUX1.bit.AIO10 = 2; // Configure AIO10 for B2 (analog input) operation GpioCtrlRegs.AIOMUX1.bit.AIO12 = 2; // Configure AIO12 for B4 (analog input) operation GpioCtrlRegs.AIOMUX1.bit.AIO14 = 2; // Configure AIO14 for B6 (analog input) operation EDIS; }
Attached are the relevant files.