2016-04-27 06:46 AM
Hello!
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, 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.
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 #getting-temperature-from-adc-on2016-04-29 04:01 AM
Do you have any source on this that you can disclose ?
2016-04-29 04:52 AM
Do you have the endian order of the bytes backward? Remember this is small endian, and an example for reading the values is provided in C, use that and print the values, or list the individual bytes as they appear in memory.
Why 8-bit? The ADC is capable of 12-bit. If you use 8-bit and the adjustment parameters are 12-bit you're going to have to scale the value you read from the ADC with a <<4 but you're going to lose a lot of resolution.2016-04-30 02:16 AM
2016-05-18 07:52 AM
The formula in the Datasheet:
>According to, temperature is computed with the following formula:
>temperature = ((110-30)/(TS_CAL2 - TS_CAL1)) x (TS_DATA * TS_CAL1) + 30 has a serious Problem I ran into, too. You can not use integer math to get a temperature value that is correct. Define all used variables into float and you will get proper results. If you do the math on a Piece of paper with integer, you always get 30 as a result ( the last +30 in the formula). Best regards, Markus.