2020-09-09 02:42 AM
Hello,
it seems cube 5.3.0 generates broken code for the ADC config.
the ADC_InitStruct.Clock is never written to CFGR2, and CFGR2 is never written.
Any suggestion why ? is this a problem from Cube code generation ?
in adc.c :
in adc.c : ADC_InitStruct.Clock = LL_ADC_CLOCK_SYNC_PCLK_DIV4;
..
LL_ADC_Init(ADC1, &ADC_InitStruct);
then stm32f0xx_ll_adc.c :
ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
{
ErrorStatus status = SUCCESS;
/* Check the parameters */
assert_param(IS_ADC_ALL_INSTANCE(ADCx));
assert_param(IS_LL_ADC_CLOCK(ADC_InitStruct->Clock));
assert_param(IS_LL_ADC_RESOLUTION(ADC_InitStruct->Resolution));
assert_param(IS_LL_ADC_DATA_ALIGN(ADC_InitStruct->DataAlignment));
assert_param(IS_LL_ADC_LOW_POWER(ADC_InitStruct->LowPowerMode));
/* Note: Hardware constraint (refer to description of this function): */
/* ADC instance must be disabled. */
if(LL_ADC_IsEnabled(ADCx) == 0U)
{
/* Configuration of ADC hierarchical scope: */
/* - ADC instance */
/* - Set ADC data resolution */
/* - Set ADC conversion data alignment */
/* - Set ADC low power mode */
MODIFY_REG(ADCx->CFGR1,
ADC_CFGR1_RES
| ADC_CFGR1_ALIGN
| ADC_CFGR1_WAIT
| ADC_CFGR1_AUTOFF
,
ADC_InitStruct->Resolution
| ADC_InitStruct->DataAlignment
| ADC_InitStruct->LowPowerMode
);
}
else
{
/* Initialization error: ADC instance is not disabled. */
status = ERROR;
}
return status;
}
Solved! Go to Solution.
2020-09-09 04:34 AM
It appears to be correct in the latest repository version:
MODIFY_REG(ADCx->CFGR2,
ADC_CFGR2_CKMODE
,
ADC_InitStruct->Clock
);
2020-09-09 04:34 AM
It appears to be correct in the latest repository version:
MODIFY_REG(ADCx->CFGR2,
ADC_CFGR2_CKMODE
,
ADC_InitStruct->Clock
);
2020-09-10 02:56 AM
Thank you !
Yes, it seems ST has already solved it.