AnsweredAssumed Answered

How to read bandgap?

Question asked by Adam Pribyl on Sep 17, 2013
Latest reply on Sep 18, 2013 by Adam Pribyl

I am trying to do a temperature sensor measurement according AN3031 on FRDM-KL25. I used PE to generate the code. I can read stable results from ADC for tempsensor and for Vrefh but the internal bandgap is floating a lot. Even the +-3% accuracy of internal bandgap can not explain it.

 

The code is as "easy" as this:

 

      AD1_MeasureChan(1, 0);

      AD1_GetChanValue16(0, &adcvalue);

      printf("ADC value: %d, ", adcvalue);

      AD1_MeasureChan(1, 2);

      AD1_GetChanValue16(2, &adcvalue);

      printf("Bandgap: %d ", adcvalue);

      AD1_MeasureChan(1, 1);

      AD1_GetChanValue16(1, &adcvalue);

      printf("Temperature sensor: %d, ", adcvalue);

      AD1_MeasureChan(1, 2);

      AD1_GetChanValue16(2, &adcvalue);

      printf("Bandgap: %d ", adcvalue);

      AD1_MeasureChan(1, 3);

      AD1_GetChanValue16(3, &adcvalue);

      printf("Vrefh: %d \r\n", adcvalue);

 

ADC is in 16bit mode single ended 10us, low power mode, high speed conversion, async clock. With 1 conversion I receive completely insane values after bandgap read looks like it depends on the previous read, with 64 conversion it is from 20000-26000 which is way too much to do any reasonable calculation of the temperature. I can change the ADC properties but is has no influence on the results. I may be doing something completely wrong, but ATM do not see what.

Outcomes