2025-04-11 10:09 AM - last edited on 2025-04-11 10:26 AM by mƎALLEm
I have a problem with an STM32H7A3 which remains stuck in SystemClock_Config. I use Keil. Any ideas please?
it just remain stucked here:
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/*AXI clock gating */
RCC->CKGAENR = 0xFFFFFFFF;
/** Supply configuration update enable
*/
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE
|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = 64;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 42;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 4;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
|RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
Error_Handler();
}
}
Solved! Go to Solution.
2025-04-11 11:16 AM
According to what you provided as info, I'm pretty sure it's a hardware issue: broken crystal, crystal not suitable, big value of the serie resistor Rext (if it's available) or the crystal is not well connected to the MCU pins.
2025-04-11 10:26 AM - edited 2025-04-11 10:33 AM
Hello @laurianus
/*AXI clock gating */
RCC->CKGAENR = 0xFFFFFFFF;
Keep them to 0.
Thanks
2025-04-11 10:30 AM
2025-04-11 10:37 AM - edited 2025-04-11 10:39 AM
Most probably the LSE didn't start . In that case you need to review your crystal parameters based on the application AN2867 "Guidelines for oscillator design on STM8AF/AL/S and STM32 MCUs/MPUs".
At first step try to increase the drive level using this macro:
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
Or your crystal is disconnected from the MCU pins
2025-04-11 10:38 AM
Keep them to 0.
Thanks
This was generated like this by STM32 Cube MX
2025-04-11 10:40 AM - edited 2025-04-11 10:42 AM
@laurianus wrote:
![]()
Keep them to 0.
Thanks
This was generated like this by STM32 Cube MX
In that case, I need to escalate that internally. Could you please share your ioc file?
2025-04-11 10:43 AM
At first step try to increase the drive level using this macro:
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
This does not work on any level. I will check LSE Crystal. ANywya at leats now I can use LSI even is not so precise.
Thank you
2025-04-11 10:49 AM
Where's it stuck? the VOSRDY line?
What board? The NUCLEO-H7A3ZI-Q?
Sure this is an LDO board and not SMPS ?
2025-04-11 10:54 AM
Where's it stuck? the VOSRDY line?
What board? The NUCLEO-H7A3ZI-Q?
Sure this is an LDO board and not SMPS ?
It stuck here
while (__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == 0U)
It is a custom board and it has LDO power supply
2025-04-11 11:16 AM
According to what you provided as info, I'm pretty sure it's a hardware issue: broken crystal, crystal not suitable, big value of the serie resistor Rext (if it's available) or the crystal is not well connected to the MCU pins.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.