Bug in resolution setting when using LL for ADC3
As indicated in community.st.com/s/question/0D53W00000zoHteSAE/h7cubemx-critical-bugs-with-ll-and-adc3 there seems to have been a bug where the resolution wasn't correctly set when working with ADC3.
As of today, the conversion seems to instead be made twice, both in the calling code (generated by CubeMX)
ADC_InitStruct.Resolution = __LL_ADC12_RESOLUTION_TO_ADC3(LL_ADC_RESOLUTION_10B);
ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE;
LL_ADC_Init(ADC3, &ADC_InitStruct);and in the library code
ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
{
...
#if defined(ADC_VER_V5_V90)
if(ADCx==ADC3)
{
MODIFY_REG(ADCx->CFGR,
ADC3_CFGR_RES
| ADC_CFGR_AUTDLY
,
((__LL_ADC12_RESOLUTION_TO_ADC3(ADC_InitStruct->Resolution) & (ADC_CFGR_RES_1 | ADC_CFGR_RES_0)) << 1UL)
| ADC_InitStruct->LowPowerMode
);
}
else
...Running the code, ADC3->CFGR is indeed 0x80000000 both before and after LL_ADC_Init() as the incorrectly calculated resolution bits are masked by MODIFY_REG().
(CubeMX v6.6.1 generating code for STM32H723)
EDIT: The problem with the variable for the while-loop not being volatile seems to remain.
