ADC measurement issue
Hello all,
Currently I have been working on a project which involves reading values using ADC. This is the following connection:

AD8495 is used as an ambient temperature sensor. The connections given in the image are taken from the datasheet for adr8495. I have connected the output to channel A0 of my ADC on board with STM32F407ZGT6. The configuration of ADC is as follows.
static void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = ENABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.DiscontinuousConvMode = ENABLE;
hadc1.Init.NbrOfDiscConversion = 3;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 3;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_VREFINT;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = 2;
sConfig.SamplingTime = ADC_SAMPLETIME_84CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = 3;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
}The issue I am facing is as follows: Whenever I power the board using STLINK using 5v provision on it, and the adr8495 is powered as well, the ADC works properly showing the reading with respect to the ambient Temperature of the room.
But whenever I power the circuit using a Linear Power supply 5V, the ADC measurements change and are drastically reduced. I have checked all the common issues like grounding , any short connections,
but I have not been able to find an issue. One thing that might help is whenever I power the board using STLINK-V2 the 3.3Pin on the board is stable around 3.25V , and whenever Linear power supply is used the Pin is stable around 3.35V
I also came up with the idea of using VREFINT as for measuring the Vref that the board is actually getting powered by, and use that value for the engineering conversions i.e Converting raw ADC values to millivolts.
Can anyone provide any suggestion? Do ask if you have any query related to connections or the firmware.
Edited to apply proper source code formatting - please see How to insert source code for future reference.
