是这样的,我用28035的多通道ADC采样时,遇到了一个奇怪的问题,ADC转换之后,中断标志位也置位了,但是结果寄存器里面没有数据,都是0。ADC的采样模式是同时采样,在调试过程中,使用单步,ADCRESULT寄存器都是0,为什么?请TI高手给点提示啊,谢谢!
具体的代码配置如下:
Uint16 index, SampleSize, Mean;
Uint32 Sum,Sum1;
index = 0; //initialize index to 0
SampleSize = 256; //set sample size to 256 (**NOTE: Sample size must be multiples of 2^x where is an integer >= 4)
Sum = 0; //set sum to 0
// *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 = 1; // Select external reference
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
// Configure ADC
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enabled ADCINT1
AdcRegs.INTSEL1N2.bit.INT1CONT = 0; //Disable ADCINT1 Continuous mode
//同时采样模式
//exp:simultaneous sample for SOC14 and SOC15(SOC12 and SOC13 ....).Lowest three bits of CHSEL
//field define the pair of channels to be converted .EOC14 and EOC15 associated with SOC14 and
//SOC15 pair.SOC14's and SOC15's results will be placed in ADCRESULT14 and ADCRESULT15
//registers,respectively.
AdcRegs.ADCSAMPLEMODE.all=0xFF; //all Simultaneous sample 同时采样模式
AdcRegs.ADCCTL1.bit.TEMPCONV = 0; //Connect A5 temp sensor 关闭内部温度传感器,ADCINA5 当作正常AD端口使用
AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; //Connect B5 VREFLO ADCINB5当作正常端口使用
//Set the ADC sample window to the desired value (Sample window = ACQPS + 1)
AdcRegs.ADCSOC0CTL.bit.CHSEL = 5; //SOC0 to ADCINA5/ADCINB5
AdcRegs.ADCSOC2CTL.bit.CHSEL = 5; //SOC1 to ADCINA5/ADCINB5
AdcRegs.ADCSOC4CTL.bit.CHSEL = 5; //SOC2 to ADCINA5/ADCINB5
AdcRegs.ADCSOC6CTL.bit.CHSEL = 5; //SOC3 to ADCINA5/ADCINB5
AdcRegs.ADCSOC8CTL.bit.CHSEL = 5; //SOC4 to ADCINA5/ADCINB5
AdcRegs.ADCSOC10CTL.bit.CHSEL = 5; //SOC5 to ADCINA5/ADCINB5
AdcRegs.ADCSOC12CTL.bit.CHSEL = 5; //SOC6 to ADCINA5/ADCINB5
AdcRegs.ADCSOC14CTL.bit.CHSEL = 5; //SOC7 to ADCINA5/ADCINB5
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6; //set SOC2 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC6CTL.bit.ACQPS = 6; //set SOC3 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC8CTL.bit.ACQPS = 6; //set SOC4 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC10CTL.bit.ACQPS = 6; //set SOC5 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC12CTL.bit.ACQPS = 6; //set SOC6 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC14CTL.bit.ACQPS = 6; //set SOC7 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
//ADC Conversion
//SOCx force Start of conversion Flag.
//writing a 1 will force to 1 the respective SOCx flag bit in the ADCSOCFLG1 register.
AdcRegs.ADCSOCFRC1.all = 0x5555; // Force Start SOC0-14 to begin ping-pong sampling
//ADC偏置校正
AdcRegs.ADCOFFTRIM.bit.OFFTRIM = 200 ; //Set offtrim register +80
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
while( index < SampleSize )
{
//Wait for ADCINT1 to trigger, then add ADCRESULT0-15 registers to sum
while (AdcRegs.ADCINTFLG.bit.ADCINT1 == 0){}
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Must clear ADCINT1 flag since INT1CONT = 0
AdcRegs.ADCSOCFRC1.all = 0x5555; // Force Start SOC0-14 to begin ping-pong sampling
Sum += AdcResult.ADCRESULT0;
Sum += AdcResult.ADCRESULT1;
Sum += AdcResult.ADCRESULT2;
Sum += AdcResult.ADCRESULT3;
Sum += AdcResult.ADCRESULT4;
Sum += AdcResult.ADCRESULT5;
Sum += AdcResult.ADCRESULT6;
Sum += AdcResult.ADCRESULT7;
Sum += AdcResult.ADCRESULT8;
Sum += AdcResult.ADCRESULT9;
Sum += AdcResult.ADCRESULT10;
Sum += AdcResult.ADCRESULT11;
Sum += AdcResult.ADCRESULT12;
Sum += AdcResult.ADCRESULT13;
Sum += AdcResult.ADCRESULT14;
Sum += AdcResult.ADCRESULT15;
index+=16;
} // end data collection
Mean = Sum / SampleSize; //Calculate average ADC sample value
补充一下,我使用的是外部参考源