2020-12-07 05:09 AM
Hello,
I´m working on a Project with a STM32F373CCT. I need to compensate the signal read from the SDADC Signal with the internal ADC Temprature sensor.
The Problem is that I only get the Value 0xFFF from the internal Temprature Sensor and also the Reference Voltage Channel.
I already checked the ADC configuration Bit ADC_CR2_TSVREFE. It is set and it is set before the ADC is turned on.
I also checked the VDDA and VSSA Pins with a DVM. They are connected to the GND, 3.3V VCC accordingly.
Also the ADC is running at 10MHz and a sampling Time of 239.5 cycles should be far greater than the needed 17.1µs sampling Time for the Internal Temperature sensor.
Some more Information to the Project:
I am using the SDADC with the internal 1,8V reference, but this reference should be seperated from the normal ADC Voltage.
I am using the current STMCubeIDE 1.5.0 with STM32Cube MCU Package for STM32F3 in Version 1.11.2
My simple Testcode:
int main(void)
{
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART3_UART_Init();
MX_ADC1_Init();
/* Infinite loop */
while (1)
{
HAL_Delay(100);
HAL_ADC_Start(&hadc1);
HAL_Delay(100);
HAL_ADC_PollForConversion(&hadc1, 1000);
HAL_Delay(100);
uint32_t temp = HAL_ADC_GetValue(&hadc1);
}
}
the corresponding ADC.c:
/**
******************************************************************************
* File Name : ADC.c
* Description : This file provides code for the configuration
* of the ADC instances.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "adc.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
ADC_HandleTypeDef hadc1;
/* ADC1 init function */
void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 1;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
}
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
{
if(adcHandle->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/* ADC1 clock enable */
__HAL_RCC_ADC1_CLK_ENABLE();
/* USER CODE BEGIN ADC1_MspInit 1 */
/* USER CODE END ADC1_MspInit 1 */
}
}
void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
{
if(adcHandle->Instance==ADC1)
{
/* USER CODE BEGIN ADC1_MspDeInit 0 */
/* USER CODE END ADC1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_ADC1_CLK_DISABLE();
/* USER CODE BEGIN ADC1_MspDeInit 1 */
/* USER CODE END ADC1_MspDeInit 1 */
}
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
As mentioned above, changing the Channel to the internal ADC Ref measurement doesn´t change the measurement result. It always measures 0xFFF.
Can somebody help me, or have some clues, what to check next to use the internal Temprature sensor?
Best Regards
Solved! Go to Solution.
2021-02-11 03:03 AM
For anybody who has a similar Problem with the Internal ADC Temprature or Ref Voltage Measurement.
There has been a Pin with a Voltage greater than VCC or less than VSS. (2 Inputs connected without a proper Voltage Level.)
According to the support this can happen when Voltage on any possible ADC Pin (even if the Pin is not set for the alternate Function) is present.
Setting all Unused Pins to Input and activating the Pull-Down resistors (for defined voltage levels on all Pins) fixxed the Problem.
2020-12-07 05:20 AM
Additional Info:
I added the 100ms Delays just to be sure there are no sattling Time Issues of the ADC. I know they are useless otherwise.
And from on Target Debugging: This is what the ADC Registers look like after 2 Cycles of ADC Measurement.
2021-02-11 03:03 AM
For anybody who has a similar Problem with the Internal ADC Temprature or Ref Voltage Measurement.
There has been a Pin with a Voltage greater than VCC or less than VSS. (2 Inputs connected without a proper Voltage Level.)
According to the support this can happen when Voltage on any possible ADC Pin (even if the Pin is not set for the alternate Function) is present.
Setting all Unused Pins to Input and activating the Pull-Down resistors (for defined voltage levels on all Pins) fixxed the Problem.