cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767 internal temperature reading issues

PG29
Associate

Hello, 

I'm trying to measure cyclic temperature on a dedicated task with FreeRTOS. For that, I set my ADC with DMA, based on the example provided here (at DMA section: https://wiki.st.com/stm32mcu/wiki/Getting_started_with_ADC#Configure_DMA

 

For now, my task is as follows

#define T1 30.0
#define T2 110.0

/*....*/
/*Some other stuff*/
/*....*/

void StartSurvTemp(void const * argument)
{
  /* USER CODE BEGIN StartSurvTemp */
  float cal_temp1 = (float) *(volatile uint16_t*) 0x1FF0F44C; //Cal temp 1
  float cal_temp2 = (float) *(volatile uint16_t*) 0x1FF0F44E; //Cal temp 2
  char buffer[50];
  float temperature = 0.0;

  HAL_ADC_Start_DMA(&hadc1, (uint32_t *)&raw_temp, 1);
  /* Infinite loop */
  for(;;)
  {

	    temperature = T1 + (T2 - T1) * (raw_temp - cal_temp1) / (cal_temp2 - cal_temp1);
		sprintf(buffer, "Raw temp : %lu, Computed temp (Celsius) : %.4f\r\n", raw_temp, temperature);
		HAL_UART_Transmit(&huart3, buffer, strlen(buffer), 10);
		osDelay(1000);
  }
  /* USER CODE END StartSurvTemp */
}

I have two major issues with this code. 

First, when it's the first run of the code, I have strange calculated values, and it's solved with a press on the reset key

Raw temp : 939, Computed temp (Celsius) : 37090607759360.0000
Raw temp : 943, Computed temp (Celsius) : 7212297728.0000
Raw temp : 943, Computed temp (Celsius) : 6908214272.0000
Raw temp : 946, Computed temp (Celsius) : 7679472828416.0000
Raw temp : 947, Computed temp (Celsius) : 1783121280.0000
<<board reset>>
Raw temp : 947, Computed temp (Celsius) : 29.3626
Raw temp : 945, Computed temp (Celsius) : 30.2532
Raw temp : 946, Computed temp (Celsius) : 30.1688
Raw temp : 948, Computed temp (Celsius) : 30.0001
Raw temp : 949, Computed temp (Celsius) : 29.9157

 

The second one is about the value itself, Indeed, I tried to freeze the board with a freeze spray, and the temperature grew.

Raw temp : 910, Computed temp (Celsius) : 33.2068
Raw temp : 917, Computed temp (Celsius) : 32.6161
Raw temp : 921, Computed temp (Celsius) : 32.2785
<<Freeze spray>>
Raw temp : 853, Computed temp (Celsius) : 38.0169
Raw temp : 838, Computed temp (Celsius) : 39.2827
Raw temp : 840, Computed temp (Celsius) : 39.1140

 

Do you have any idea? 

Thanks in advance 

3 REPLIES 3
mƎALLEm
ST Employee

Hello,

Do you have the same behaviours without RTOS?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PG29
Associate

Hello, 

Yes, same behaviours without RTOS. 

So if the behavior is reproduced without RTOS, I suppose there is no reason to talk about RTOS.

keep the discussion focused on the temperature reading.

This thread will be moved to STM32 MCU products forum board.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.