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.

AdcOffsetSelfCal() always calculates a value of 80 for OFFTRIM

Hi All,

  I am running my program on a 28035 and I am facing some interesting challenges with the AdcOffsetSelfCal() routine provided by TI.

void AdcOffsetSelfCal()
{
Uint16 AdcConvMean;
EALLOW;
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; //Select internal reference mode
AdcRegs.ADCCTL1.bit.VREFLOCONV = 1; //Select VREFLO internal connection on B5
AdcChanSelect(13); //Select channel B5 for all SOC
AdcRegs.ADCOFFTRIM.bit.OFFTRIM = 80; //Apply artificial offset (+80) to account for a negative offset that may reside in the ADC core
AdcConvMean = AdcConversion(); //Capture ADC conversion on VREFLO
AdcRegs.ADCOFFTRIM.bit.OFFTRIM = 80 - AdcConvMean; //Set offtrim register with new value (i.e remove artical offset (+80) and create a two's compliment of the offset error)
AdcRegs.ADCCTL1.bit.VREFLOCONV = 0; //Select external ADCIN5 input pin on B5
EDIS;
}

  After executing AdcOffsetSelfCal() the AdcRegs.ADCOFFTRIM.bit.OFFTRIM register always contains 80. I have stepped into the AdcOffsetSelfCal() function and noticed that after forcing the sampling by executing the instruction AdcRegs.ADCSOCFRC1.all = 0x00FF; (in AdcConversion()), the result in all ADCRESULT registers is 4095. This causes the calculation "80 - AdcConvMean" to be always 80, and consequently the ADC ends up measuring with a horrible offset.

  I would appreciate some help in this regards.

  Thank you,

Lucas

  • Hi Lucas,

    Other than the offset calibration, does the ADC seem to function fine?  Have you tried converting signals on the pins?

    I think if it is otherwise working, then you have some problem getting the ADC setup to actually convert the internal VREFLO connection - in this case check for missing EALLOW (looks like you have it) and double check that the registers the code is writing are actually being written in expressions window.  

    If it doesn't work in general, then there is some fundamental issue with how the ADC is setup - in this case make sure to check all the enables and dividers on the clock, and to check that the ADC power-ups are indeed getting written. You can also check the VDDA and VSSA connections.  

  • Hi Devin,

     Thank you for your assistance. I did find the problem and was related, as you suggested, with improper initialization of the ADC.

      Cheers,

    Lucas