cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32u585 SystemClock_Config() failure to configure voltage scaling

JKahn.1
Associate III

I am using the B-U585I-IOT02A discovery kit with the STM32U585AI chip. Attempting to set the system clock value in STM Cube to anything that would result in voltage scaling above PWR_REGULATOR_VOLTAGE_SCALE4 results in a timeout and thus failure in the HAL_PWREx_ControlVoltageScaling() function.

This is all in the Cube generated code, without any other additions or manipulation.

Code sticks int he Error_Handler() function after the call to HAL_PWREx_ControlVoltageScaling().

Edit: I cannot even manually manipulate the PWR registers via ST-LINK. I can do this on other development kits (STM32L5 for example)

STM32CubeIDE Version: 1.12.0 Build: 14980_20230301_1550 (UTC)

What is the problem here? I need to be able to set a clock speed as I like.

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
  /** Configure the main internal regulator output voltage
  */
  if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2) != HAL_OK)
  {
    Error_Handler();
  }
 
  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLMBOOST = RCC_PLLMBOOST_DIV1;
  RCC_OscInitStruct.PLL.PLLM = 1;
  RCC_OscInitStruct.PLL.PLLN = 10;
  RCC_OscInitStruct.PLL.PLLP = 2;
  RCC_OscInitStruct.PLL.PLLQ = 2;
  RCC_OscInitStruct.PLL.PLLR = 2;
  RCC_OscInitStruct.PLL.PLLRGE = RCC_PLLVCIRANGE_1;
  RCC_OscInitStruct.PLL.PLLFRACN = 3072;
  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_PCLK3;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV1;
 
  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

1 ACCEPTED SOLUTION

Accepted Solutions
JKahn.1
Associate III

I looked at a project generated for the STM32L5 and noticed there a function call in HAL_MspInit(), to __HAL_RCC_PWR_CLK_ENABLE()  that was missing in this generated project

Added that to my STM32U5 project and now it seems to be working as expected

Note this is related to another issue I was having: https://community.st.com/s/question/0D53W00002DCKpHSAX/stm32u585-cannot-switch-between-smps-and-ldo-power-supplies?t=1680826046214

View solution in original post

1 REPLY 1
JKahn.1
Associate III

I looked at a project generated for the STM32L5 and noticed there a function call in HAL_MspInit(), to __HAL_RCC_PWR_CLK_ENABLE()  that was missing in this generated project

Added that to my STM32U5 project and now it seems to be working as expected

Note this is related to another issue I was having: https://community.st.com/s/question/0D53W00002DCKpHSAX/stm32u585-cannot-switch-between-smps-and-ldo-power-supplies?t=1680826046214