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;
