cancel
Showing results for 
Search instead for 
Did you mean: 

Read temperature calibration values from MC register

hazin
Associate III

Steps to read the temperature calibration values from the stm32l152rc

1 ACCEPTED SOLUTION

Accepted Solutions
uint16_t cal1, cal2; 

cal1 = *(uint16_t*)TEMPSENSOR_CAL1_ADDR_CMSIS;
cal2 = *(uint16_t*)TEMPSENSOR_CAL2_ADDR_CMSIS;

TEMPSENSOR_CAL1_ADDR_CMSIS and TEMPSENSOR_CAL2_ADDR_CMSIS are defined in the CMSIS-mandated device header.

JW

View solution in original post

11 REPLIES 11

In the datasheet for your particular STM32 model, look up TS_CAL1 and TS_CAL2 addresses, and then read a halfword from that address.

Maybe related to this thread?

JW

Why is there two addresses corresponding to CAL1 and CAL2Screenshot 2023-10-19 135334.png

Each TS_CALx is 16-bit so it occupies two bytes.

JW

Can I get an example souce code to read TS_CAL1 and TS_CAL2 addresses.

uint16_t cal1, cal2; 

cal1 = *(uint16_t*)TEMPSENSOR_CAL1_ADDR_CMSIS;
cal2 = *(uint16_t*)TEMPSENSOR_CAL2_ADDR_CMSIS;

TEMPSENSOR_CAL1_ADDR_CMSIS and TEMPSENSOR_CAL2_ADDR_CMSIS are defined in the CMSIS-mandated device header.

JW

Thank You!!:hundred_points:

One more thing. The Calibration value shows 666 and 849 for 30°C and 110°C respectively. But when I tried to read it using the inbuilt ADC channel the value shows 680 for 25°C. What may be the reason?

Different VREF+/VDDA voltage than 3.0V, or some other reason.

JW

As often, only few families  have this data. I see it for F7 and L1. This non-orthogonality is a pity.