using TS_CAL1 value on STM32C011 seems to make calculated temp less accurate
I'm using the internal temp sensor on a C011 chip *actually the STM32C0116 dev board) and trying to get an approximate reading in C, using __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS macro.
I understand that this won't be very accurate, but it seems that when I use the T_CAL1 value stored in ROM the result actually gets significantly worse. Here is my code:
#define VDDA_APPLI ((uint32_t) 3300)
#define TEMPSENSOR_TYP_CAL1_V (( int32_t) 760)
#define TEMPSENSOR_TYP_AVGSLOPE (( int32_t) 2530)
#define TEMPSENSOR_CAL_VREF ((uint32_t) 3000)
int32_t get_last_temp_reading(void)
{
uint16_t t_cal1 = *TEMPSENSOR_CAL1_ADDR;
return (int32_t)__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(TEMPSENSOR_TYP_AVGSLOPE,
//TEMPSENSOR_TYP_CAL1_V,
t_cal1,
TEMPSENSOR_CAL1_TEMP,
VDDA_APPLI,
raw_value,
LL_ADC_RESOLUTION_12B);
}
My raw_value is 787. When I use the typical datasheet value of 760, I get a result of -20. If I use t_cal1 (which has a value of 1048) I get -134
What is going on? OK, I don't expect much accuracy, but using the internal cal value should at least make things better not worse?
