TI中文支持网
TI专业的中文技术问题搜集分享网站

关于28035的ADC采样问题

是这样的,我用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

补充一下,我使用的是外部参考源

mangui zhang:

AdcRegs.ADCSOC0CTL.bit.CHSEL  = 4; //set SOC0 channel select to ADCINA4 AdcRegs.ADCSOC1CTL.bit.CHSEL  = 2; //set SOC1 channel select to ADCINA2 AdcRegs.ADCSOC0CTL.bit.TRIGSEL  = 5; //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1 AdcRegs.ADCSOC1CTL.bit.TRIGSEL  = 5; //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1 AdcRegs.ADCSOC0CTL.bit.ACQPS  = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1) AdcRegs.ADCSOC1CTL.bit.ACQPS  = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1) //ADCSOCxCTL:ADCSOC0 – SOC15控制寄存器//(15~11)TRIGSEL:SOC产生来源(软件,CPUtimer中断,PWM,XINT)//(9~6)CHSEL:当SOCx产生的时候ADC转换通道选择(SIMULENx=0时单通道选择,SIMULENx = 1时,两对通道选择)//(5~0)ACQPS:SOCx的采样保持窗口大小。(06h Sample window is 7 cycles long (6 + 1 clock cycles).) EDIS;

// Assumes ePWM1 clock is already enabled in InitSysCtrl();   EPwm1Regs.ETSEL.bit.SOCAEN = 1;  // Enable SOC on A group   EPwm1Regs.ETSEL.bit.SOCASEL = 4;  // Select SOC from from CPMA on upcount      //ETSEL:事件触发选择寄存器//(15)SOCBEN:SOCB允许(为1:允许ADC在SOC脉冲来临时转换)//(14~12)SOCBSEL:EPWMxSOCB来源选择(DCBEVT1,TBCTR = 0x0000,TBCTR = TBPRD,equal to CMPA,equal to CMPB)//(11)SOCAEN:SOCA允许(为1:允许ADC在SOC脉冲来临时转换)//(10-8)SOCASEL:EPWMxSOCA来源选择(DCBEVT1,TBCTR = 0x0000,TBCTR = TBPRD,equal to CMPA,equal to CMPB)//(3)INTEN:EPWMx_INT中断产生允许(为1:允许)//(2~0)INTSEL:EPWMx_INT中断来源选择(TBCTR = 0x0000,TBCTR = TBPRD,equal to CMPA,equal to CMPB)   EPwm1Regs.ETPS.bit.SOCAPRD  = 1;  // Generate pulse on 1st event      //ETPS:时间产生预分频寄存器//(15~14)SOCBCNT:计数有多少次SOCB事件(一到3次)//(13~12)SOCBPRD:设定多少次SOCB事件产生一个SOCB的脉冲//(11~10)SOCACNT:计数有多少次SOCA事件(一到3次)//(9~8)SOCAPRD:设定多少次SOCA事件产生一个SOCB的脉冲//(3~2)INTCNT:计数有多少次EPWMx_INT中断事件(一到3次)//(1~0)INTPRD:设定多少次EPWMx_INT事件产生中断   EPwm1Regs.CMPA.half.CMPA  = 0x0080; // Set compare A value   EPwm1Regs.TBPRD     = 0xFFFF; // Set period for ePWM1   EPwm1Regs.TBCTL.bit.CTRMODE  = 0;  // count up and start

 

附加是参考代码   请查看

是这样的,我用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

补充一下,我使用的是外部参考源

xuehai yang:

回复 mangui zhang:

mangui zhang:

看了一下,没什么区别。我现在又发现,同一个代码,用28034就可以跑起来,ADC很正常,但是用28035就不行,ADC就跑步起来,何解???

是这样的,我用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

补充一下,我使用的是外部参考源

ep_wxl:

回复 xuehai yang:

你试试将里面自带的延时函数注释掉

是这样的,我用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

补充一下,我使用的是外部参考源

xuehai yang:

回复 ep_wxl:

试了,没效果,我觉得应该是28035和28034有点区别,但是不太确定在哪

赞(0)
未经允许不得转载:TI中文支持网 » 关于28035的ADC采样问题
分享到: 更多 (0)