论坛

f28035的adc怎么这么差,还是我的程序有问题?求解

此问题已被解答
All Replies
  • 秀才101分

    这是我的程序

    void adc_setup(void)
    {
    //
    InitAdcAio();
    InitAdc(); // For this example, init the ADC,库函数自带的初始化

    AdcOffsetSelfCal();
    //ad的相关配置
    EALLOW;
    AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; //ADCINT1 trips after AdcResults latch
    AdcRegs.INTSEL1N2.bit.INT1E = 1; //Enabled ADCINT1
    AdcRegs.INTSEL1N2.bit.INT1CONT = 1; //Disable ADCINT1 Continuous mode
    AdcRegs.INTSEL1N2.bit.INT1SEL = 5; //setup EOC5 to trigger ADCINT1 to fire

    AdcRegs.ADCSOC0CTL.bit.CHSEL = 8; //set SOC0 channel select to ADCINB0;u_out
    AdcRegs.ADCSOC1CTL.bit.CHSEL = 9; //set SOC1 channel select to ADCINB1;i_l
    AdcRegs.ADCSOC2CTL.bit.CHSEL = 1; //set SOC2 channel select to ADCINA1;u_in
    AdcRegs.ADCSOC3CTL.bit.CHSEL = 11; //set SOC3 channel select to ADCINB3;u_gnd
    AdcRegs.ADCSOC4CTL.bit.CHSEL = 12; //set SOC4 channel select to ADCINB4;t1
    AdcRegs.ADCSOC5CTL.bit.CHSEL = 13; //set SOC5 channel select to ADCINB5;t2
    AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 14; //set SOC0 start trigger on EPWM5 ,ADCSOCB, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 14; //set SOC1 start trigger on EPWM5B, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 14; //set SOC2 start trigger on EPWM5B, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 14; //set SOC3 start trigger on EPWM5B, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 14; //set SOC4 start trigger on EPWM5B, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 14; //set SOC5 start trigger on EPWM5B, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC0CTL.bit.ACQPS = 20; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC1CTL.bit.ACQPS = 20; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC2CTL.bit.ACQPS = 20; //set SOC2 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC3CTL.bit.ACQPS = 20; //set SOC3 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC4CTL.bit.ACQPS = 20; //set SOC4 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC5CTL.bit.ACQPS = 20; //set SOC5 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)

    __interrupt void adc_isr(void)
    {

    //unsigned int pwmout;

    g_adc_raw[0][g_adc_pos]= AdcResult.ADCRESULT0;
    g_adc_raw[1][g_adc_pos] =AdcResult.ADCRESULT1;
    g_adc_raw[2][g_adc_pos] =AdcResult.ADCRESULT2;
    g_adc_raw[3][g_adc_pos] = AdcResult.ADCRESULT3;
    g_adc_raw[4][g_adc_pos] = AdcResult.ADCRESULT4;
    g_adc_raw[5][g_adc_pos] =AdcResult.ADCRESULT5;

    g_adc_pos++;
    if (g_adc_pos>=MAXADCNUM)//以下程序执行的时间应该测试出来????
    {
    g_adc_pos =0;
    pid_all();//pid调节运算
    }
    else
    {
    //adc_seq1_start();//一个pwmb的中断中启动了adc,连续转换9次
    }
    AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
    return;
    }

    这是采样的结果。实际电位都是0,为什么第一组数据总是偏差很大。

  • 探花10985分

    ACQPS不能设置为20,请查看ADC手册关于ADCSOCxCTL.ACQPS位说明,另外AdcResult.ADCRESULT0结果不能用,具体可以查看F28035勘误表关于ADC部分说明。

    如果此回复解答了您的问题,请在“ 这问题是否已被解答?” 点击 ” 是 “,谢谢!

  • 秀才180分

    由于TI资料过于乱,你能否直接发个ADC勘误表的文档链接。另外,如果AdcResult.ADCRESULT0结果不能用,留这个功能有何用?

  • 探花10985分

    详细请参考勘误表,网址如下

    http://www.ti.com/lit/pdf/sprz295

    如果此回复解答了您的问题,请在“ 这问题是否已被解答?” 点击 ” 是 “,谢谢!