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.

TMS320F280023C: Problems with ADC setup

Part Number: TMS320F280023C
Other Parts Discussed in Thread: C2000WARE

Hi,

I have set up SOC2 on my microcontroller to trigger on the ePWM1 SOCA output signal.

There is a varying voltage on my input pin (A2), but despite the ISR being entered frequently (checked with a counter variable) the value of the ADC result register doesn't change. It just stays fixed at 2045-2046.

Here is my initialisation code and ISR code. Please help me figure out what I'm missing.

void init_adc(void)
{
    EALLOW;
    CpuSysRegs.PCLKCR13.bit.ADC_A=1;
    EDIS;
    ADC_setVREF(ADCA_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);

    EALLOW;
    AdcaRegs.ADCCTL1.bit.ADCPWDNZ=1;        // Power on the ADC

    AdcaRegs.ADCCTL2.bit.PRESCALE = 2;      // ADCCLK=50MHz for SYSCLK=100MHz

    //SOC2: triggered by EPWM1-SOCA, 270ns acquisition window, sampling on channel 2
    AdcaRegs.ADCSOC2CTL.bit.TRIGSEL = 0x5;
    AdcaRegs.ADCSOC2CTL.bit.ACQPS = 26;
    AdcaRegs.ADCSOC2CTL.bit.CHSEL = 2;

    AdcaRegs.ADCCTL1.bit.INTPULSEPOS=1;     // Interrupt pulse generation occurs at the end of conversion, 1 cycle before result latching on to the result reg
    AdcaRegs.ADCINTSEL1N2.bit.INT2SEL=2;    // Set EOC2 as interrupt trigger for ADCINT2
    AdcaRegs.ADCINTSEL1N2.bit.INT2CONT=0;
    AdcaRegs.ADCINTSEL1N2.bit.INT2E=1;
    EDIS;

    DEVICE_DELAY_US(5000);
}

__interrupt void ADC2_ISR(void)
{
    adcval_raw = AdcaResultRegs.ADCRESULT2;
    adcval = 3.3*(((float)adcval_raw)/4096);
    soaCurrent = ((1.65-adcval)/(20*0.004));
    EPwm1Regs.ETCLR.bit.SOCA=1;
    AdcaRegs.ADCINTFLGCLR.bit.ADCINT2=1;
    PieCtrlRegs.PIEACK.bit.ACK10=1;
}

Thanks in advance.

Regards,

Vishnu

  • Hi Vishnu,

    Even though you aren't using ADC-C, you should still probably configure the ADC-C reference since it shares a reference pin with ADC-A on this device.  I don't think that is the problem, but it is definitely best practice to do this.

    Other than that, I don't see anything obviously missing.  You might try switching the channel select to try another channel to see if your A2 channel is possibly damaged.  I'd also recommend that you try out some of the ADC SW examples included in C2000ware (both unmodifed and modified only to change the channel select to A2).   It is also worth pausing the execution at some point and using the expressions window to examine the state of AdcaRegs to ensure Adca in general and SOC2 specifically are configured as expected.  

    What HW are you running on? Is this the TI controlCard or Launchpad, or a custom PCB you developed?