Skip to main content
Associate II
October 19, 2023
Solved

Read temperature calibration values from MC register

Steps to read the temperature calibration values from the stm32l152rc

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
October 19, 2023
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

11 replies

waclawek.jan
Super User
October 19, 2023

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

hazinAuthor
Associate II
October 19, 2023

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

waclawek.jan
Super User
October 19, 2023

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

JW

hazinAuthor
Associate II
October 19, 2023

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

waclawek.jan
waclawek.janBest answer
Super User
October 19, 2023
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

hazinAuthor
Associate II
October 20, 2023

Thank You!!:hundred_points:

waclawek.jan
Super User
October 20, 2023

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

JW