2023-12-28 12:14 AM - edited 2023-12-28 03:15 AM
Hello everyone, we want to read the value from the temperature sensor with ADC using the stm32f431kbu6 microprocessor. We use the code mentioned below.
#define TS_CAL_1 (*((uint16_t*)0x1FFF75A8)
#define TS_CAL_2 (*((uint16_t*)0x1FFF75CA)
float mcuTempCalculate (uint16_t tempADCval, uint16_t VrefIntADCval)
{
float temperature = 0;
temperature=(((130.0f-30.0f)/(TS_CAL_2-TS_CAL_1))*(3.3/3.0 * tempADCval - TS_CAL_1))+30.0f;
return temperature;
}
However, we read the temperature value as 6-8V. temADCval value is 863. Where might the problem be? Can you help?
2023-12-28 01:22 AM
> #define TS_CAL_2 (*((uint16_t)0x1FFF75CA)
An asterisk (*) is missing after uint16_t here.
JW
2023-12-28 02:22 AM
Actually, I forgot to add (*) in my code. While writing here, I am getting the values I specified, even though there is (*).
2023-12-28 03:30 AM - edited 2023-12-28 03:33 AM
> we read the temperature value as 6-8V.
Cannot read higher than Vref. Check your ADC measurements. By the way VrefIntADCval is not used in your function and the compiler should print a warning.
2023-12-28 06:25 AM
> we read the temperature value as 6-8V
6-8V is a voltage range, not a temperature. Perhaps you meant 6-8F?
> STM32L431KBU
> stm32f431kbu6
It's difficult to provide specific feedback when your post and code have typos. Copy/paste should be working.
2023-12-28 08:06 AM
Unexpected temperature sensor readout is a recurring theme here, try to search.
Often, calibration as outlined in reference manual, helps. Other possible sources of problems here.
JW