Skip to main content
Explorer II
November 4, 2025
Solved

stm32h755 Clock setup: HAL_RCC_ClockConfig returns error.

  • November 4, 2025
  • 3 replies
  • 308 views

Hi all,

I am having issues with Clock setup for Stm32h755. Especially regarding the M4 core. Currently, I only run the M4 core. The M7 core has no valid firmware. Is that even a supported mode?

I try to setup a rather basic clock setup but the setup keeps failing at the call: HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4), which will return an not ok return value.

I also tried using HSI and other different setups. But it seems the keep failing in the same way. Interestingly... When I simply ignore the error. Then most stuff seems to work just fine. I got ADC, SPI, Timers working. However, I am not sure where the issue is with the clock configuration.

The entire clock setup: 

static void SystemClock_Config(void) {
 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 __HAL_RCC_SYSCFG_CLK_ENABLE();

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 RCC_OscInitStruct.PLL.PLLM = 5;
 RCC_OscInitStruct.PLL.PLLN = 192;
 RCC_OscInitStruct.PLL.PLLP = 2;
 RCC_OscInitStruct.PLL.PLLQ = 2;
 RCC_OscInitStruct.PLL.PLLR = 2;
 RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
 RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
 RCC_OscInitStruct.PLL.PLLFRACN = 0;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
 // print error
 }

 /** 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_DIV2;
 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) {
 // print error
 }
}


Best regards

Mark


Edited to apply proper source code formatting - please see How to insert source code for future reference.

    This topic has been closed for replies.
    Best answer by Mark12

    Hi,

    this was a good lead that showed me the real problem. There was a missing call to Hal_Init(). Which caused the tickPriority to not be set.

     

    Thanks & Best regards

    Mark

    3 replies

    Super User
    November 4, 2025

    The clock failing to start can suggest the HSE design is not correct. Perhaps incorrect load caps.

    Guidelines for oscillator design on STM8AF/AL/S and STM32 MCUs/MPUs - Application note

     

    M4 having no firmware is fine. You can set option bytes such that the M4 core doesn't boot, but it's not an issue here.

    Super User
    November 4, 2025

    @Mark12 wrote:

    the call: HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_4 ), which will return an not ok return value..


    Have you tried stepping into that function to see where & why, exactly, it is failing?

    Mark12Author
    Explorer II
    November 4, 2025

    Hi Andrew,

    I stepped inside and it seems to fail in:

    __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)

     

    more precisely in this check:

    /* Configure the SysTick IRQ priority */
    if (TickPriority < (1UL << __NVIC_PRIO_BITS))
    {
     HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
     uwTickPrio = TickPriority;
    }
    else
    {
     // will return ERROR here
     return HAL_ERROR;
    }
     

    Edited to apply proper source code formatting - please see How to insert source code for future reference.

    Technical Moderator
    November 4, 2025

    Hello,

    Which board are you using? Nucleo board?

    If it's the case, you need to set HSE in Bypass mode as the clock source is provided from the STLINK (STLINK_MCO) and there is no crystal on the board:

    mALLEm_0-1762275019446.png

     

    Mark12Author
    Explorer II
    November 4, 2025

    Hi,

    yes. I am on a nucleo board. I tried setting HSE_Bypass but it didnt change the behavior. The Config method fails on the method 

    HAL_InitTick

    Because of what seems to be an invalid TickPriority of "16" which is somehow present. 

     

    Edited to apply proper source code formatting - please see How to insert source code for future reference.

    Super User
    November 4, 2025

    16 is not a valid priority. Change it to 15 or less.

    TDK_0-1762292476257.png

     

    Include your IOC file if you're having trouble.