Hello,
I need to convert 8 channels simultaneously with F28377D development tools.
Reference to http://e2e.ti.com/support/microcontrollers/c2000/f/171/p/355638/1253304.aspx#1253304
I learned that I can only sampling 4 channels at one time, so I samples A0, B0, C4, D0 as the 1st group with SOC0; samples A2, B2, C2, D2 as the 2nd group with SOC1. The end of SOC1 will trigger an interrupt to read ADCRESULT0 and ADCRESULT1 in one function. Sampling rate is 50KHz.
The problem to me, is the 1st group has coupling with the 2nd group -- like that if I input a high voltage to A0(the ADCRESULT0 read around 3900), and do not connect A2, there will be some large values in ADCRESULT1(should be 0, but read around 3000); then if I ground A2 (A0 still is high), there will be some small values in ADCRESULT1(should be 0, but read around 15).
following is a part of my codes:
-----------------------------------
//Write ADC configurations and power up the ADC for ADC A B C and D
void ConfigureADC(void)
{
EALLOW;
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // set ADCCLK divider to /4
AdcaRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdcaRegs.ADCCTL2.bit.SIGNALMODE = 0; // single-ended channel conversions (12-bit mode only)
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power up the ADC
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; // set ADCCLK divider to /4
AdcbRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdcbRegs.ADCCTL2.bit.SIGNALMODE = 0; // single-ended channel conversions (12-bit mode only)
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power up the ADC
AdccRegs.ADCCTL2.bit.PRESCALE = 6; // set ADCCLK divider to /4
AdccRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdccRegs.ADCCTL2.bit.SIGNALMODE = 0; // single-ended channel conversions (12-bit mode only)
AdccRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power up the ADC
AdcdRegs.ADCCTL2.bit.PRESCALE = 6; // set ADCCLK divider to /4
AdcdRegs.ADCCTL2.bit.RESOLUTION = 0; // 12-bit resolution
AdcdRegs.ADCCTL2.bit.SIGNALMODE = 0; // single-ended channel conversions (12-bit mode only)
AdcdRegs.ADCCTL1.bit.INTPULSEPOS = 1; // Set pulse positions to late
AdcdRegs.ADCCTL1.bit.ADCPWDNZ = 1; // power up the ADC
DELAY_US(1000); // delay for 1ms to allow ADC time to power up
EDIS;
}
void SetupADCEpwm(void)
{
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin B0
AdcbRegs.ADCSOC0CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdccRegs.ADCSOC0CTL.bit.CHSEL = 4; // SOC0 will convert pin C4
AdccRegs.ADCSOC0CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdcdRegs.ADCSOC0CTL.bit.CHSEL = 0; // SOC0 will convert pin D0
AdcdRegs.ADCSOC0CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
// AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; // end of SOC0 will set INT1 flag
// AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // enable INT1 flag
// AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // make sure INT1 flag is cleared
// stage 2
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 2; // SOC1 will convert pin A2
AdcaRegs.ADCSOC1CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdcbRegs.ADCSOC1CTL.bit.CHSEL = 2; // SOC1 will convert pin B2
AdcbRegs.ADCSOC1CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdcbRegs.ADCSOC1CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdccRegs.ADCSOC1CTL.bit.CHSEL = 2; // SOC1 will convert pin C2
AdccRegs.ADCSOC1CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdccRegs.ADCSOC1CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdcdRegs.ADCSOC1CTL.bit.CHSEL = 2; // SOC1 will convert pin D2
AdcdRegs.ADCSOC1CTL.bit.ACQPS = 14; // sample window is 15 SYSCLK cycles
AdcdRegs.ADCSOC1CTL.bit.TRIGSEL = 7; // trigger on ePWM2 SOCA/C
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; // end of SOC1 will set INT1 flag.
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; // make sure INT1 flag is cleared
EDIS;
}
interrupt void adca1_isr(void)
{
// Read the ADC result and store in circular buffer
// results of 1st group, copy to AdcA
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT0;
AdcaResults[resultsIndex++] = AdcbResultRegs.ADCRESULT0;
AdcaResults[resultsIndex++] = AdccResultRegs.ADCRESULT0;
AdcaResults[resultsIndex++] = AdcdResultRegs.ADCRESULT0;
// results of 2nd group, copy to AdcB
resultsIndex = resultsIndex-4;
AdcbResults[resultsIndex++] = AdcaResultRegs.ADCRESULT1;
AdcbResults[resultsIndex++] = AdcbResultRegs.ADCRESULT1;
AdcbResults[resultsIndex++] = AdccResultRegs.ADCRESULT1;
AdcbResults[resultsIndex++] = AdcdResultRegs.ADCRESULT1;
if(RESULTS_BUFFER_SIZE <= resultsIndex)
{
resultsIndex = 0;
}
.....
}
------------
Thanks.