in HAL_MspInit (), HAL_SYSCFG_EnableVREFBUF() always runs into a timeout
Hello,
I’m using CubeMX v6.18 (no difference in 6.19) to create code for STM32H5 (FW1.7.0)
I noticed, that in generated HAL_MspInit() the call of HAL_SYSCFG_EnableVREFBUF() seems to take a while because the function always runs into a 10ms timeout. A bit is set in this function, but the status VREFBUF_CSR.VRR never changes to 1.
void HAL_MspInit(void)
{
/* System interrupt init*/
/** Enable the VREF clock
*/
__HAL_RCC_VREF_CLK_ENABLE();
/** Configure the internal voltage reference buffer voltage scale
*/
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE0);
/** Enable the Internal Voltage Reference buffer
*/
HAL_SYSCFG_EnableVREFBUF();
/** Configure the internal voltage reference buffer high impedance mode
*/
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);If I change the order of function calls slightly (first set VREFBUF to output before enableVREFBUF)
/** Configure the internal voltage reference buffer high impedance mode
*/
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
HAL_SYSCFG_EnableVREFBUF();
then HAL_SYSCFG_EnableVREFBUF() runs through without additional delay.
As this is generated code and my modification gets overwritten each time I generate now code , I can’t do this simple correction. Instead, I added at the beginning of the MspInit()
/* USER CODE BEGIN MspInit 0 */
__HAL_RCC_VREF_CLK_ENABLE();
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
/* USER CODE END MspInit 0 */There are similar topics that describe this problem for other devices, e.g. for STM32H7, STM32G5.
Regards,
Gunnar Bohlen
HMS Networks
