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.

LAUNCHXL-F28379D: ADC conversion value continues to be zero

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Folks,

Have a what seems to be a silly problem. I am using the launchpad. I am trying the convert the analog voltage on the ADC input pins. I am applying 0.86 V as a test voltage on the analog pins. I am consistently reading 0 whether I apply the voltage or leave the pin floating. What am I missing ?

The conversion is triggered by the timer1. That seems to be happening as the ADCINT flag is set everytime the timer is invoked.

Relevant code snippets are below.

Thanks.

-Bhaktha

Init:

AdcaRegs.ADCCTL2.bit.PRESCALE = 0;

AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1; // Power up rest of ADC

DELAY_US(1000); // 1 mS for ADC to powerup

AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; // create int pulses 1 cycle prior to output latch
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; // Only two channles on ADCA
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 1; // Disable continuous mode
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; // enable ADC interrupt 1

Uint16 trigSel = 2;

AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = trigSel; // CurPh1
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = trigSel; // CurPh2

// Minimum for 12 bit mode
Uint16 acqps = 14;
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps;
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps;

//EOC = end of conversion event; SOC = start of conversion event
AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 0; // No ADCINT will trigger SOCx
AdcaRegs.ADCINTSOCSEL1.bit.SOC1 = 0;

AdcaRegs.ADCSOC0CTL.bit.CHSEL= 0;
AdcaRegs.ADCSOC1CTL.bit.CHSEL= 1;

Reading :

//
//wait for ADCA to complete, then acknowledge flag
//
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;

currentPh1Value = AdcaResultRegs.ADCRESULT0;

currentPh2Value = AdcaResultRegs.ADCRESULT1;

  • Bhaktha,

    Please try one of the C2000Ware examples (like adc_soc_epwm) to confirm that your LaunchPad is working:

    ~\C2000Ware_XXXX\device_support\f2837xd\examples\cpu1\adc_soc_epwm

    Do keep in mind that the ADC module has a maximum operating frequency of 50-MHz so setting AdcaRegs.ADCCTL2.bit.PRESCALE to 0 is not valid when SYSCLK is configured for 200-MHz.

    -Tommy

  • Tommy,

    Thanks for pointing out the prescale setting issue. I set it to 6, no luck though. What else could be wrong ?

    Let me know if you have your usual list of things to check.

    Thanks.

    -Bhaktha

  • Bhaktha,

    Did you try one of the C2000Ware examples?  That would really help to eliminate potential points of failure.

    If it works, you can have confidence that the hardware is good and you can also compare the C2000Ware ADC configuration against your own.

    -Tommy

  • Tommy,

    Yes, finally got around to try one of the examples and that worked flawlessly. Not sure what I was doing wrong :-( Used the ADC setup and config functions from that example, copied it in my project and made the changes to match my requirements. Its working now.

    One of these days I should go back and see what I was doing wrong though ...

    Cheers,

    -Bhaktha