cancel
Showing results for 
Search instead for 
Did you mean: 

NUCLEO-H743ZI (STM32H7 400MHz) - STM32CubeMX will not configure to 400MHz

SWood.8
Associate III

Pretty frustrating experience so far. I have seen many people asking but no-one has a straight answer.

Very simple question, these are my steps:

1- Started Cube32MX, selected NUCLEO and reset all no essential pins. See photo. 0690X000006DMGDQA4.png

2- Clock configuration is set to 96MHz. Trying to set clock to 400MHz creates a never ending search

This is just one of several dead-end headaches I am experiencing after migrating from L4 to H7.

Can someone from ST please make an honest comment on this.

1 ACCEPTED SOLUTION

Accepted Solutions
SWood.8
Associate III

OK... another tweak and now it seems to work. Changed the PLL Source MUX around so System Clock driven by HSI....

0690X000006DMHaQAO.png

... and now we have 400MHz clock running and print(f) working also at all above speeds.... not easy

0690X000006DMHfQAO.png

View solution in original post

3 REPLIES 3
SWood.8
Associate III

May have resolved my own problem [Edit: Eventually ! See next few posts ] . I tweaked the highlighted region to create desired results, with some adjustments to the /Dividers in the top-right Clocks to limit to 100MHz where needed. Initial results on Build and Debug in TrueSTUDIO show it is operating OK. Resolve Clock Issues could not reach this result after > 1 hour.

0690X000006DMGwQAO.png

STM32CubeMX generated Code for SystemClock_Config is as follows:

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
 
  /**Supply configuration update enable 
  */
  MODIFY_REG(PWR->CR3, PWR_CR3_SCUEN, 0);
  /**Configure the main internal regulator output voltage 
  */
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
 
  while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) 
  {
    
  }
  /**Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = 32;
  RCC_OscInitStruct.PLL.PLLN = 100;
  RCC_OscInitStruct.PLL.PLLP = 2;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  RCC_OscInitStruct.PLL.PLLR = 2;
  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 busses 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_2) != HAL_OK)
  {
    Error_Handler();
  }
  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
  PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
}

SWood.8
Associate III

Still completely up in the air on this one. Using this code in main.c...

  uint32_t SysClk;
  uint32_t HClk;
  uint32_t PClk1;
  uint32_t PClk2;
  SysClk = HAL_RCC_GetSysClockFreq();
  HClk = HAL_RCC_GetHCLKFreq();
  PClk1 = HAL_RCC_GetPCLK1Freq();
  PClk2 = HAL_RCC_GetPCLK2Freq();
  printf("*******************\n");
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
	  printf("Clock Speeds:\n");
	  printf("SysClk (System Clock) = %lu Hz\n", SysClk);
	  printf("HClk (AHB / Main CPU Clock) = %lu Hz\n", HClk);
	  printf("PClk1 (Peripherals Clock 1) = %lu Hz\n", PClk1);
	  printf("PClk2 (Peripherals Clock 2) = %lu Hz\n", PClk2);

I got the following result from the supposed 400MHz config above (only 64MHz):

0690X000006DMHLQA4.png

... BUT when I changed the Clock Config back to a 80Mhz ...

0690X000006DMHQQA4.png

... the resulting clock speeds were reporting correctly; and higher!

0690X000006DMHVQA4.png

So either CubeMX just isn't writing sensible code (likely) or the HAL_commands used to read them are wrong. Either way, it's another hair pulling day with the STM32H7

SWood.8
Associate III

OK... another tweak and now it seems to work. Changed the PLL Source MUX around so System Clock driven by HSI....

0690X000006DMHaQAO.png

... and now we have 400MHz clock running and print(f) working also at all above speeds.... not easy

0690X000006DMHfQAO.png