cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7A3 stuck in SystemClock_Config in KEIL

laurianus
Associate III

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();
}
}
12 REPLIES 12
mƎALLEm
ST Employee

Hello @laurianus 

  1. Please use </>  button to format your shared code. See this post. (I'm editing your post).
  2. You need to share your schematics especially the HSE and the LSE parts.
  3. Please don't write to the reserved bits:
    /*AXI clock gating */
    RCC->CKGAENR = 0xFFFFFFFF;

 

mALLEm_1-1744392789747.png

Keep them to 0.

Thanks

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

It was stuck in LSE so I just changed from LSE to LSI and is working now. Maybe it is a problem with LSE Crystal

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

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

mALLEm_1-1744392789747.png

Keep them to 0.

Thanks


This was generated like this by STM32 Cube MX

 

 


@laurianus wrote:

mALLEm_1-1744392789747.png

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?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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

 

Where's it stuck? the VOSRDY line?

What board? The NUCLEO-H7A3ZI-Q?

Sure this is an LDO board and not SMPS ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

 

 

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.