STM32L431KBU TEMEPRATURE SENSOR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-28 12:14 AM - edited ‎2023-12-28 3: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?
- Labels:
-
ADC
-
STM32L4 series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-28 1:22 AM
> #define TS_CAL_2 (*((uint16_t)0x1FFF75CA)
An asterisk (*) is missing after uint16_t here.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-28 2:22 AM
Actually, I forgot to add (*) in my code. While writing here, I am getting the values ​​I specified, even though there is (*).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-28 3:30 AM - edited ‎2023-12-28 3: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-28 6:25 AM
- Make sure you're using the same VREF+ voltage (3.0V per the datasheet) as what was used to get TS_CAL values. If your voltage is different, then adjust.
- Use max sampling time or use a sampling time that meets the temperature sensor requirements per the datasheet.
> 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-12-28 8: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
