STM32F7 ADC driver issue when changing channel from vbat to temp sensor.
file - stm32f7xx_hal_adc.c
function - HAL_ADC_ConfigChannel
issue - The ADC_CHANNEL_VBAT and ADC_CHANNEL_TEMPSENSOR channels are shared so only one can be used at a time. If you want to use both, you will need to swap between the two. When swapping from VBAT to TS, the VBAT flag remains enabled in ADC->CCR causing ADC_CHANNEL_VREFINT to read unexpected values.
work around - when changing channels from vbat to the temp sensor, also clear:
CLEAR_BIT(ADC->CCR,ADC_CCR_VBATE);suggested driver update -
if(sConfig->Channel == ADC_CHANNEL_TEMPSENSOR)
{
/* Ensure the vBat channel is disabled */
CLEAR_BIT(ADC->CCR,ADC_CCR_VBATE);
/* Delay for temperature sensor stabilization time */
/* Compute number of CPU cycles to wait for */
counter = (ADC_TEMPSENSOR_DELAY_US * (SystemCoreClock / 1000000));
while(counter != 0)
{
counter--;
}
}