void main(void) { ... InitAdc();// Power up bandgap/reference/ADC circuits GPIOinit();// I2C_Init(); ... SetupADC(); ... } void InitAdc(void) { extern void DSP28x_usDelay(Uint32 Count); // *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; //Initialise ADCCTL1 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 //AdcRegs.ADCCTL1.bit.ADCREFSEL = 1; // Select outside reference AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; // INT Pulse Generated After converting EDIS; DELAY_US(ADC_usDELAY); // Delay before converting ADC channels } void SetupADC(void) { Uint16 indx; int32 temp; EALLOW; AdcRegs.ADCINTFLGCLR.all=0x1FF; AdcRegs.INTSEL3N4.bit.INT3E=1; //Enable ADCINT3 AdcRegs.INTSEL3N4.bit.INT3SEL=5; //EOC5 Trigger ADCINT3 AdcRegs.ADCSAMPLEMODE.all=0xFF; //Simultaneous Sampling Mode ?????????? AdcRegs.ADCINTSOCSEL1.all=0x0000; AdcRegs.ADCINTSOCSEL2.all=0x0000; //SOC0 AdcRegs.ADCSOC0CTL.bit.ACQPS=6; //Sample Window Size AdcRegs.ADCSOC0CTL.bit.CHSEL=2; //Channel Select INA2--GND AdcRegs.ADCSOC0CTL.bit.TRIGSEL=9; //Tiggger Source -PWM3-SOCA //SOC1 AdcRegs.ADCSOC1CTL.bit.ACQPS=6; AdcRegs.ADCSOC1CTL.bit.CHSEL=2; AdcRegs.ADCSOC1CTL.bit.TRIGSEL=9; //SOC2 AdcRegs.ADCSOC2CTL.bit.ACQPS=6; AdcRegs.ADCSOC2CTL.bit.CHSEL=0; AdcRegs.ADCSOC2CTL.bit.TRIGSEL=9; //SOC3 AdcRegs.ADCSOC3CTL.bit.ACQPS=6; AdcRegs.ADCSOC3CTL.bit.CHSEL=0; AdcRegs.ADCSOC3CTL.bit.TRIGSEL=9; //SOC4 AdcRegs.ADCSOC4CTL.bit.ACQPS=6; AdcRegs.ADCSOC4CTL.bit.CHSEL=1; AdcRegs.ADCSOC4CTL.bit.TRIGSEL=9; //SOC5 AdcRegs.ADCSOC5CTL.bit.ACQPS=6; AdcRegs.ADCSOC5CTL.bit.CHSEL=1; AdcRegs.ADCSOC5CTL.bit.TRIGSEL=9; //SOC6 AdcRegs.ADCSOC6CTL.bit.ACQPS=6; AdcRegs.ADCSOC6CTL.bit.CHSEL=4; AdcRegs.ADCSOC6CTL.bit.TRIGSEL=9; //SOC7 AdcRegs.ADCSOC7CTL.bit.ACQPS=6; AdcRegs.ADCSOC7CTL.bit.CHSEL=4; AdcRegs.ADCSOC7CTL.bit.TRIGSEL=9; // Map the Interrupt to and ISR routine. PieVectTable.ADCINT3 = &adc_isr; // Enable ADCINT in PIE PieCtrlRegs.PIEIER10.bit.INTx3 = 1; IER |= M_INT10; // Enable CPU Interrupt 1 EDIS; }