STM32F7 ADC driver issue when changing channel from vbat to temp sensor.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-18 5:53 PM
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--;
}
}
- Labels:
-
ADC
-
STM32Cube MCU Packages
-
STM32F7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-19 7:23 AM
Hi @HMcKi​ ,
Your request is relevant as it is aligned with the description of TSVREF in the reference manual:
Note: VBATE must be disabled when TSVREFE is set. If both bits are set, only the VBAT conversion is performed.
I'll share it with development team in order to take care to provide a fix.
However, I would like to understand more the issue reading ADC_CHANNEL_VREFINT: do you confirm that expected values are read when implementing the workaround you are suggesting?
-Amel
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-19 3:03 PM
Hi Amel,
Thanks for the hasty reply.
Confirmed.
Cheers,
Hamish.
