2022-06-08 01:04 AM
i tried to use the internal temperatur sensor but its a little bit strange
when the tempertur goes up the value from the adc goes down
is that right or is my config for the adc wrong ?
2022-06-08 01:10 AM
Higher temperature give lower output voltage. You are right.
2022-06-08 01:37 AM
do you have an example how to calculate the temperatur ?
or which value whould by 0 °C ?
the examples i found are only for other stm chips with 2 calibration values
2022-06-08 02:57 AM
Have you looked at the datasheet:
2022-06-08 03:25 AM
yes i did but the calculation i tried is wrong
i think its much easier if the datasheet gives some examples
to start with
for example from the datasheet of a lm95071
this makes it clear how it has to be calculated
so can you tell me the hexvalue of the ad at 0°C with a vdd of 3.3 V ?
2022-06-08 04:24 AM
Don't forget to also look in the Reference Manual - that's where programming details are to be found (the datasheet concentrates on physical characteristics):
2022-06-08 05:00 AM
thank you very much
that was the the hint i was searching for
2022-06-08 06:48 AM
The HAL has macros to help.
In this case ADC_Data.word[2] is the ADC result from reading the Voltage Reference
And ADC_Data.word[1] is the ADC result from reading the Temperature Sensor.
uint16_t refv = __HAL_ADC_CALC_VREFANALOG_VOLTAGE(ADC_Data.word[2],ADC_RESOLUTION_12B);
uint16_t temp = __HAL_ADC_CALC_TEMPERATURE(refv,ADC_Data.word[1],ADC_RESOLUTION_12B);
The thing that got me was that the Temperature Sensor and the Voltage Reference both need a sample time of 5 microseconds or 160.5 clocks in my case. Way higher than I initially assumed.