cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 internal temperature sensor

emre ozdemir
Associate III

Hello All,

I need to read tempereture of mcu.

But I confused about formula given at referance manual.which is below.Because there no data TS_CAL_2 val

0693W00000DnKJwQAN.png 

0693W00000DnKKGQA3.png 

Thanks.

Regards.

EMRE

11 REPLIES 11
Philippe Cherbonnel
ST Employee

Hello @emre ÖZDEMİR​ ,

STM32 series value line does have only one calibration point. Other ones have two calibration points.

In LL driver, there are 2 macro available to help you to compute temperature from ADC raw conversion data.

- __LL_ADC_CALC_TEMPERATURE(): requires 2 calibration points, most accurate since specific to each sample.

- __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(): uses typical parameters from datasheet, generic to all samples.

Here is a proposal to use this macro:

#define VDDA_APPLI                     ((uint32_t) 3300)        /* Value of analog reference voltage (Vref+), connected to analog voltage supply Vdda (unit: mV) */
#define TEMPSENSOR_TYP_CAL1_V          (( int32_t)  760)        /* Internal temperature sensor, parameter V30 (unit: mV). Refer to device datasheet for min/typ/max values. */
#define TEMPSENSOR_TYP_AVGSLOPE        (( int32_t) 2500)        /* Internal temperature sensor, parameter Avg_Slope (unit: uV/DegCelsius). Refer to device datasheet for min/typ/max values. */
#define TEMPSENSOR_CAL_VREF            ((uint32_t) 3000)        /* Vdda value with which temperature sensor has been calibrated in production (+-10 mV). */
 
temperature_degC = __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(TEMPSENSOR_TYP_AVGSLOPE,
                                                        TEMPSENSOR_TYP_CAL1_V,
                                                        TEMPSENSOR_CAL1_TEMP,
                                                        VDDA_APPLI,
                                                        temperature_raw_data,
                                                        LL_ADC_RESOLUTION_12B);

You can optimize accuracy by using offset calibrated data instead of generic value (literal TEMPSENSOR_TYP_CAL1_V above).

Best regards

Philippe

Does V(SENSE) also need to be calibrated according to V(REFINT) (use a calibrated VDD value in the formula)?