2022-11-11 07:14 AM
Hello,
I'm facing some issues sampling ADC internal channel in of STM32u575.
In particular these are the steps I'm following:
VDDA enable
ADC Clock Configuration
HAL_ADC_Init (&ADC_Handle[i])
Interrupt configuration.
Then, I configure the ADC channel to read VREFINT and start a conversion, which is ok.
After that, when configuring ADC channel to read the internal temperature sensor, even if the function HAL_ADC_ConfigChannel returned ok, the temperature read value had no sense (-240°C which is just a little bit too cold).
I found out that by looking into config channel function that:
/* Parameters update conditioned to ADC state: */
/* Parameters that can be updated only when ADC is disabled: */
/* - Single or differential mode */
/* - Internal measurement channels: Vbat/VrefInt/TempSensor */
if (LL_ADC_IsEnabled(hadc->Instance) == 0UL)
This condition prevents me to configure internal channel id ADC is already enabled, however it does not return any error if the condition is met.
So, I was wondering if this is the right behaviour and if it is stated somewhere in the reference manual as I found out that bypassing these checks:
if (LL_ADC_IsEnabled(hadc->Instance) == 0UL)
if(__LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__LL_ADC_COMMON_INSTANCE(hadc->Instance)) == 0UL)
I get a correct temperature reading.
For now I'm disabling the ADC every time I need to change internal channel to ensure a correct reading.
Best regards,
Matteo
2022-11-12 01:01 AM
Cube is not necessarily correct. Follow the description in RM.
JW
2022-11-13 11:37 PM
Hello Jan,
Thank you for your answer, however I'm not talking about Cube generated code as I'm working in bare Eclipse. I only downloaded the Hal layer from ST, where no error is returned when trying to configure internal channel when ADC is already enabled, which seems not to be permitted in the function HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConfTypeDef *pConfig);
Before modifying the HAL layer, however, I wanted to make sure what was the expected behaviour
Best regards,
Matteo
2022-11-16 01:56 PM
Hi All,
This question was flagged for a case creation in our internal support system for support from one of our specialist teams. The support will be provided directly but if anyone else has the same issue, then they can submit a request on the ST.com website.
Regards,
Jake
ST Support