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.

CCS/TMS320F28027: ADC reading not changing with potmeter

Part Number: TMS320F28027
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

I am building the base control platform using the F28027PPT and evaluating using the F2802xx controlcard with dokking station.

I can power up the adc and link the ADC interrupt to the Epwm without any issue, and i have checked that it is sampling with the correct frequency. I have a potmeter connected to 3V3 and GND and output connected to A1

My problem is the value read in the ADCRESULT.ADCRESULT1 register does not change even though i can measure with an oscilloscope that the input voltage on A1 is changing?

Am i misunderstanding section 6.11.1 in TMS320F2802x,TMS320F2802xx Piccolo - Technical Reference Manual ?

Find my initialization and result reading function below:

ADC initialization:

void SetupADC(void){

EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select internal BG
EDIS;

DELAY_US(1000L);
//Select the channels to convert and end of conversion flag
EALLOW;

//Setup channel direction
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // internal bandgap used for reference
AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; // VrefLO internally connected to ADC Sampling
// ADC setup meassurement
AdcRegs.SOCPRICTL.bit.SOCPRIORITY = 3; // ADC0-2 has high priority
AdcRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin A2
AdcRegs.ADCSOC0CTL.bit.ACQPS = 10; //sample window is 10 SYSCLK cycles
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC0 will convert pin A3
AdcRegs.ADCSOC1CTL.bit.ACQPS = 10; //sample window is 10 SYSCLK cycles
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcRegs.ADCCTL1.bit.TEMPCONV = 1;
AdcRegs.ADCSOC2CTL.bit.CHSEL = 5; //SOC0 will convert pin A4
AdcRegs.ADCSOC2CTL.bit.ACQPS = 10; //sample window is 10 SYSCLK cycles
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcRegs.INTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
AdcRegs.INTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared

EDIS;
}

ADC interrupt function:

interrupt void adca1_isr(void)
{
//DINT;
//a = (double)AdcaResultRegs.ADCRESULT0*Vx + Vy;
Global.DataReady = 1;
ADC_TOGGLE();
a = AdcResult.ADCRESULT1*(3.3/4095);
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Allow other interrupts from group 1
// EINT;
}

  • user5897835,

    Your code is configuring SOC1 to convert A3

    AdcRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC0 will convert pin A3

    -Tommy

  • It is true that my comment of the code is incorrect. however, this is not my issue.
    Am i missing a part of the initialization of the ADC since i cannot read the correct value on the pin?

    is using internal bandgap for reference and connecting VrefLO to ADC sampling the correct way to set this up?
    AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // internal bandgap used for reference
    AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; // VrefLO internally connected to ADC Sampling
  • I have modified the ADC setup to include a calibration of the ADC by running:
    // Calibration
    AdcRegs.ADCOFFTRIM.bit.OFFTRIM = 80;
    AdcRegs.ADCCTL1.bit.VREFLOCONV = 1; // VrefLO internally connected to ADC Sampling
    AdcRegs.ADCOFFTRIM.bit.OFFTRIM = 80;
    AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // internal bandgap used for reference
    AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; // VrefLO internally connected to ADC Sampling

    Now I measure between 750 and 2229 on (int)AdcResult.ADCRESULT1
    0x02EE to 0x08F3 read directly as Hex in AdcResult.ADCRESULT1
  • user5897835 said:
    It is true that my comment of the code is incorrect. however, this is not my issue.
    Am i missing a part of the initialization of the ADC since i cannot read the correct value on the pin?

    is using internal bandgap for reference and connecting VrefLO to ADC sampling the correct way to set this up?
    AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // internal bandgap used for reference
    AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; // VrefLO internally connected to ADC Sampling

    Using the internal reference is fine.

    Going back to my comment about your code configuring SOC1 to sample A3:

    Your original problem statement was that you could not see the expected conversion value in ADCRESULT1 when applying a potentiometer signal on channel A1. Based on your configuration, ADCRESULT1 will show the conversion value from channel A3, not A1. Can you verify which channel is connected to the potentiometer?

  • I found the error. Apperently having A1 on SOC0, A2 on SOC1, and A3 on SOC3 will read the correct value on A2 and A3 while not A1.
    Moving A1 to SOC1 will enable me to read the voltage on A1.

    Why is SOC0 not reading voltage?
  • user5897835,

    Please try using a fresh copy of adc_soc example from C2000Ware: \C2000Ware_XXXX\device_support\f2802x\examples\structs\adc_soc

    Verify that the example works as-is, and then change the channels as desired.

    -Tommy
  • user5897835,

    It has been a while since your last update. I assume that you were able to resolve your issue.

    If not, please reply to this thread. If the thread has locked due to timeout, please create a new thread describing the current status of your issue.

    -Tommy