STM32F7 internal temperature (ADC) read

30 Nov 2017

Hello,

I need to read internal temperature of STM32F767 chip (Nucleo STM32F767 board) using ADC 1. The code is as follows:

include the mbed library with this snippet

#include "mbed.h"
Serial pc(SERIAL_TX, SERIAL_RX);
AnalogIn int_temp(ADC_TEMP);

main()
{
  float voltage = int_temp.read() * 3.3;
// temperature =( Measured voltage - voltage at 25 C)/Slope + 25 as mentioned in page 464 of reference manual
 temp = ((voltage - 0.76)/2.5) + 25;
printf("Temp = %f",temp);

}

/*
Temperature (in °C) = {(VSENSE – V25) / Avg_Slope} + 25
Where:
– V25 = VSENSE value for 25° C
– Avg_Slope = average slope of the temperature vs. VSENSE curve (given in mV/°C
or μV/°C)
*/

The temperature reading varies between 25.01 and 25.02 deg C even if the chip is hot. Am I doing anything wrong? How to read the internal temperature?

01 Dec 2017

Hi

Can you add a while(1) loop in the main routine and try again ?

main()
{
  while(1) {
    float voltage = int_temp.read() * 3.3;
    // temperature =( Measured voltage - voltage at 25 C)/Slope + 25 as mentioned in page 464 of reference manual
    temp = ((voltage - 0.76)/2.5) + 25;
    printf("Temp = %f",temp);
    wait(1);
  }
}