AnsweredAssumed Answered

Getting temperature from ADC on STM32f091

Question asked by Gates on Apr 27, 2016
Latest reply on May 18, 2016 by horbach.markus


I have a problem with the sensor temperature of STM32F091 (ARM Cortex M0).
According to datasheet, temperature is coming from ADC channel 16.
In my program, ADC acquiring is working well because I can receive values from channels 10, 11 and  12.

The value I read from ADC channel 16 (temperature sensor) is 117.

According to
datasheet page 253, temperature is computed with the following formula:

temperature = ((110-30)/(TS_CAL2 - TS_CAL1)) x (TS_DATA * TS_CAL1) + 30

This formula doesn't work for me: zero is returned.

I tried to understand why by checking the value of TS_CAL1 and TS_CAL2 in the chip memory. The values are the following:

TS_CAL1 = 0xDF06 (1759 in decimal)
TS_CAL2 = 0x2605 (1318 in decimal)

I found these values at the addresses given in the
datasheet page 18.

If I well understand, I should have 1759 when I have 30°C.
How can I have this 16 bit value when my ADC is sampling 8 bits (255 max)?

Then I tried to change scale of TS_CAL1 and TS_CAL2 in case of ST made their acquiring in 12bits mode:

NEW_TS_CAL1 = (TS_CAL1 * 4095)/255 = 110
NEW_TS_CAL2 = (TS_CAL2 * 4095)/255 = 82

With these values the formula returns me a value of 8°C but the temperature in the romm I am currently working in is 24°C.

I don't know what to do now to make it work.
Please help