This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

280049 ADC 转换 有一路 有问题

一、现象描述

            280049 用的是 ADC 的A1 A2 和C0口 进行adc 转换  目前 A2和C0 转换都是正常的,但 A1的转换结果和C0  保持一致,不管这两个端口输入信号异同,A1的结果  同C0 ,C0 的结果是正确的。

            触发是利用PWM1触发的,每次触发能连续转换这三路ADC 然后能进中断,读取信息。

二、程序代码

     {/*
    I_OUT     as PV current output   cpu_pin_9_A2     homologous  100pin as  9pin   64插脚
    ADC_Vbus  as PV Voltage          cpu_pin_12_C0    homologous  100pin as 19pin   28插脚
    ADC_Vlink as high bus voltage    cpu_pin_14_A1    homologous  100pin as 22pin   30插脚
  */
    // Setup VREF as internal
    ADC_setVREF(ADCA_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);
    ADC_setVREF(ADCC_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);
    // Set ADCCLK divider to /4
    ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
    ADC_setPrescaler(ADCC_BASE, ADC_CLK_DIV_4_0);
    // Set pulse positions to late
//    ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
//    ADC_setInterruptPulseMode(ADCC_BASE, ADC_PULSE_END_OF_CONV);
    //ADC_disableContinuousMode(ADCA_BASE,ADC_INT_NUMBER1);
  // 是ADC模块的基地址;socNumber是转换开始时的编号;触发将导致SOC的源;参数通道是与输入信号相关联的数字;sampleWindow是获取窗口的持续时间。
    ADC_setupSOC(ADCA_BASE,ADC_SOC_NUMBER2,        //ADC 需要转换的通道  PV_I
                 ADC_TRIGGER_EPWM1_SOCA,          //ADC 触发
                 ADC_CH_ADCIN2,                   // A2 参数通道是与输入信号相关联的数字;
                 15);                            //Time
    ADC_setupSOC(ADCC_BASE,ADC_SOC_NUMBER0,      //ADC 需要转换的通道   PV_V
                 ADC_TRIGGER_EPWM1_SOCA,        //ADC 触发
                 ADC_CH_ADCIN0,                 // C0 参数通道是与输入信号相关联的数字;
                 10);                           //转换 Time
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER1,        //ADC 需要转换的通道   High_VBSU
                 ADC_TRIGGER_EPWM1_SOCA,           //ADC 触发
                 ADC_CH_ADCIN1,                    // A1  参数通道是与输入信号相关联的数字;
                 24);                              //Time
    // Power up the ADC and then delay for 1 ms
    ADC_enableConverter(ADCA_BASE);
    ADC_enableConverter(ADCC_BASE);
   // DEVICE_DELAY_US(1000);
}
// initADCSOC - Function to configure ADCA's SOC0 to be triggered by ePWM1.
void initADCSOC(void)
{
    // Configure burst mode for SOCs
    ADC_enableBurstMode(ADCA_BASE);
    ADC_setBurstModeConfig(ADCA_BASE, ADC_TRIGGER_EPWM1_SOCA,3);

  // Set SOC0 to set the interrupt 1 flag. Enable the interrupt and make sure its flag is cleared.
    ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER1);//Set ADCA SOC1 to set the interrupt 1 flag
    ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);

    EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);//ENable ad trigger  选择PWM1 触发ADC
    EPWM_setADCTriggerSource(EPWM1_BASE,EPWM_SOC_A,EPWM_SOC_TBCTR_ZERO);//时基计数器等于零
    EPWM_setADCTriggerEventPrescale(EPWM1_BASE,EPWM_SOC_A,1);//为每个预分测单元生成SOC脉冲,多达15个事件
    Interrupt_enable(INT_ADCA1);
}
// adcA1ISR - ADC A Interrupt 1 ISR
__interrupt void adcA1ISR(void)
{
    /*
    I_OUT     as PV current output   cpu_pin_9_A2     homologous  100pin as  9pin   64插脚
    ADC_Vbus  as PV Voltage          cpu_pin_12_C0    homologous  100pin as 19pin   28插脚
    ADC_Vlink as high bus voltage    cpu_pin_14_A1    homologous  100pin as 22pin   30插脚
      */
    // Add the latest result to the buffer  resultBase是ADC结果的基地址  socNumber是转换开始时的编号
    PV_IADResults[index1++]    = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2);//A
    PV_VADResults[index2++]    = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER0);//A
    H_VLinkADResults[index3++] = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER8);//C

    // Set the bufferFull flag if the buffer is full
      if(RESULTS_BUFFER_SIZE <= index1)
    {
        index1 = 0;index2=0;index3=0;
        bufferFull = 1;
    }
    // Clear the interrupt flag清除中断标志
      ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
    // Check if overflow has occurred 检查是否发生溢出
    if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1))
    {
        ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
        ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
    }
    // Acknowledge the interrupt
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
三、一直没有查出问题,硬件没有问题