The EFM8LB1_TempSensor_WithCompensation example for EFM8LB1 use the internal 1.65V reference to measure the temperature, could I change the 1.65V internal reference to 2.4V internal pin reference (or other) as ADC reference voltage?
If the answer is yes, what factors I should take into consideration when I change the internal reference voltage for the ADC.
Basically the answer is yes because the temperature sensor would convert the die temperature to a voltage, any voltage reference for the ADC could be used to measure the voltage converted by the temperature sensor.
In the example (refer to file EFM8LB1_TempSensor_WithCompensation.c) we use below formula to convert ADC code to die temperature:
temp_scaled = ((ADC_AVG - tempsensor_0c)*SCALE) / constant;
constant equals 28.
tempsensor_0c was a one-point calibration value read from flash.
The key point here is that tempsensor_0c (read from flash) and constant 28 was gotten when ADC was configured to use 1.65V voltage reference and 14-bit mode.
In fact the constant 28 was gotten with below idea:
For 14 bit ADC, resolution is 2^14= 16384
temperature slope = 2.8mV/degC (Table 4.11 of datasheet)
1.65V full range = 1650mV
This mean when ADC was configured to use 1.65V voltage reference and 14-bit mode, 1 degC temperature change will cause 28 (decimal) ADC code change.
The tempsensor_0c that read from flash was also gotten when ADC was configured to use 1.65V voltage reference and 14-bit mode. This means that under controlled die temperature (0 degC), use 1.65V internal reference and 14-bit mode, we get a ADC output code as tempsensor_0c.
So if you want to change the ADC reference voltage or bit mode, you should either:
1. scale the ADC code (get with new reference voltage and bit mode) to a code that you would get with 1.65V and 14-mode.
2. scale tempsensor_0c and constant 28 in the formula above to suit for the new voltage reference and bit mode.
Both should work fine.
Let me assume you are taking the option 2 and use 2.4V reference voltage (still 14-bit mode), then you could get:
tempsensor_0c_after = (tempsensor_0c_flash * 1650 / 2400)
constant_after = 28 * 1650 / 2400 = 19.25
Then the final formula to get the temperature would be:
temp_scaled = ((ADC_AVG - tempsensor_0c_after)*SCALE) / 19.25;