Hello there,
I have got a problem with the OFFTRIM calibration of the 2808's ADC. The code is like that:
do // as long as there are zeros
{
AdcRegs.ADCOFFTRIM.bit.OFFSET_TRIM=trim;
RESET_ADC1; // reset Sequencer
START_ADC1; // start again
while (AdcRegs.ADCST.bit.INT_SEQ1==0); // wait for adc to be ready
adc00=AdcRegs.ADCRESULT0;
adc01=AdcRegs.ADCRESULT1;
adc02=AdcRegs.ADCRESULT2;
adc03=AdcRegs.ADCRESULT3;
adc04=AdcRegs.ADCRESULT4;
adc05=AdcRegs.ADCRESULT5;
adc06=AdcRegs.ADCRESULT6;
adc07=AdcRegs.ADCRESULT7;
adc08=AdcRegs.ADCRESULT8;
adc09=AdcRegs.ADCRESULT9;
adc10=AdcRegs.ADCRESULT10;
adc11=AdcRegs.ADCRESULT11;
adc12=AdcRegs.ADCRESULT12;
adc13=AdcRegs.ADCRESULT13;
adc14=AdcRegs.ADCRESULT14;
adc15=AdcRegs.ADCRESULT15;
if (!adc00 || !adc01 || !adc02 || !adc03 || !adc04 || !adc05 || !adc06 || !adc07 ||!adc08 || !adc09 || !adc10 || !adc11 || !adc12 || !adc13 || !adc14 || !adc15)
{
zero=1;
trim+=40;
}
else
{
zero=0;
adc_sum = adc00 + adc01 + adc02 + adc03 + adc04 + adc05 + adc06 + adc07 + adc08 + adc09 + adc10 + adc11 + adc12 + adc13 + adc14 + adc15; // summieren
adc_sum = adc_sum>>8;
AdcRegs.ADCOFFTRIM.bit.OFFSET_TRIM=trim-adc_sum;
}
}
while (zero);
When reseting and starting the DSP, it always gets zeros as result. Until I stop via CCs-debug and then run again. After that it works fine. Because of that it hangs at every start of system.
Has somebody any ideas?
Regards,
Jens