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