Can I use ADC5 in standalone mode when ADC34 are in Dual Mode ? Code fail to start ADC5 . Documentation missing data.
Hello ST community,
I use ADC3, 4 and 5 of STM32G474 and configure them to ADC3/4 dual mode, ADC5 standalone (no other option in CubeMx).
HAL function HAL_ADC_Start_DMA fail for ADC5 , because it check if it is in correct mode of ADC3 master.
So there is many questions:
- is ADC5 part of ADC345 dual mode block? (in documentation and code it is so, ADC345_Common is such register block) .
- How to use triple ADC in Dual mode ? Documentation missing ?
- Can ADC5 stand alone be used same time with ADC34 Dual mode ? I tried to initialize ADC5 and start it manually with ADC34 dual, looks like it works, but what regression can I await.
I hope it's just HAL code fix and hardware work as needed (ADC1/2 dual , ADC3/4 dual, ADC5 stand alone).
Code related to problem from stm32g4xx_hal_adc.c :
HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length)
{
HAL_StatusTypeDef tmp_hal_status;
#if defined(ADC_MULTIMODE_SUPPORT)
uint32_t tmp_multimode_config = LL_ADC_GetMultimode(__LL_ADC_COMMON_INSTANCE(hadc->Instance));
#endif
/* Check the parameters */
assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
/* Perform ADC enable and conversion start if no conversion is on going */
if (LL_ADC_REG_IsConversionOngoing(hadc->Instance) == 0UL)
{
/* Process locked */
__HAL_LOCK(hadc);
#if defined(ADC_MULTIMODE_SUPPORT)
/* Ensure that multimode regular conversions are not enabled. */
/* Otherwise, dedicated API HAL_ADCEx_MultiModeStart_DMA() must be used. */
if ((tmp_multimode_config == LL_ADC_MULTI_INDEPENDENT)
|| (tmp_multimode_config == LL_ADC_MULTI_DUAL_INJ_SIMULT)
|| (tmp_multimode_config == LL_ADC_MULTI_DUAL_INJ_ALTERN)
)
#endif
{
...................................
}
#if defined(ADC_MULTIMODE_SUPPORT)
else
{
tmp_hal_status = HAL_ERROR;
/* Process unlocked */
__HAL_UNLOCK(hadc);
}
#endif
}
else
{
tmp_hal_status = HAL_BUSY;
}
/* Return function status */
return tmp_hal_status;
}ADC3/4 is configured for Dual regular simultaneous mode only,
so why ADC5 check this mode?
ADC345_common not configured to any of "if" condition and function return HAL_ERROR for ADC5 , I hope such behavior is buggy.
Best regards,
Maksims M.
