cancel
Showing results for 
Search instead for 
Did you mean: 

The issue of clock configuration for STM32F446RCT6

乒乓
Visitor

Why is it that when I set the clock frequency of the STM32 to a high frequency (180 MHz), the code will crash, but when I set it to a low frequency (72 MHz), the code can run normally?

_0-1769582293868.png

_1-1769582326658.png

 

9 REPLIES 9
乒乓
Visitor

Threads murged for the same question.

Why is it that when I set the clock frequency of the STM32 to a high frequency (180 MHz), the code will crash, but when I set it to a low freque

void SystemClock_Config (void)

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 */
 HAL_RCC_PWR CLK_ENABLE ();
 HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1);

 */
 RCC_OscInitStruct. OscillatorType = RCC_OSCILLATORTYPE_HSE;
 RCC_OscInitStruct. HSEState = RCC_HSE ON;
 RCC_OscInitStruct. PLL. PLLState = RCC_PLL_ON;
 RCC_OscInitStruct. PLL. PLLSource = RCC_PLLSOURCE_HSE;
 RCC_OscInitStruct. PLL. PLLM = 4;
 RCC_OscInitStruct. PLL. PLLN = 180;
 RCC_OscInitStruct. PLL. PLLP = RCC_PLLP_DIV2;
 RCC_OscInitStruct. PLL. PLLQ = 2;
 RCC_OscInitStruct. PLL. PLLR = 2;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL OK)
 {
  Error Handler () ;
 }

 RCC_ClkInitStruct. ClockType = RCC CLOCKTYPE HCLK | RCC CLOCKTYPE SYSCLK
 RCC_CLOCKTYPE PCLK1 | RCC CLOCKTYPE PCLK2;
 RCC_ClkInitStruct. SYSCLKSource = RCC SYSCLKSOURCE PLLCLK;
 RCC_ClkInitStruct . AHBCLKDivider = RCC SYSCLK DIV1;
 RCC_ClkInitStruct. APB1CLKDivider = RCC HCLK DIV4;
 RCC_ClkInitStruct. APB2CLKDivider = RCC HCLK DIV2;
 
 if (HAL PWREx EnableOverDrive () != HAL OK)
 {
  Error Handler () ;
 }

 if (HAL RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL OK)
 {
  Error Handler();
 }

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

Please edit your post to have a proper title and post your question within the message.

Please indicate the full part number of the chip you are using.

How to write your question to maximize your chance... - STMicroelectronics Community

If you feel a post has answered your question, please click "Accept as Solution".
mƎALLEm
ST Employee

Hello @乒乓 and welcome to the ST community,

What crystal value you've attached to HSE? you should not exceed 8MHz in that configuration.

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.

The external clock I configured is 8 MHz.

_0-1769589684072.png

 

What board are you using? ST board or custom board?

If custom board, post the schematics.

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.

User has created a duplicate post on this here:

The issue of clock configuration for STM32F446RCT6 - STMicroelectronics Community

If you feel a post has answered your question, please click "Accept as Solution".
mfgkw
Senior III

Is the crystal really 8 MHz?

The MCU might get in trouble when you configure 8 MHz but the reality is e.g. 16 MHz...


@mfgkw wrote:

Is the crystal really 8 MHz?

The MCU might get in trouble when you configure 8 MHz but the reality is e.g. 16 MHz...


This is what I'm suspecting.

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.