Skip to main content
Subrat Sahu
Associate
September 7, 2017
Question

STM32CubeMX 4.22 SystemClock_Config Bug

  • September 7, 2017
  • 1 reply
  • 2728 views
Posted on September 07, 2017 at 21:43

I am using STM32CubeMX 4.22.0

I am using STM32F103C8T6 chip with Keil v5 under Windows 10.

I configured only RCC to 

HSE  for Crystal\Ceramic Resonator and in Clock Configuration input frequency to 8 MHz and HCLK to 72MHz .I generated the code for keil, but at the function 'SystemClock_Config()' the chip  falls into Error_Handler().

following code was generated:

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_ClkInitTypeDef RCC_ClkInitStruct;

/**Initializes the CPU, AHB and APB busses clocks

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

I debug step by step. At the point  'Error_Handler'  the program goes in to infinite loop of function 'Error_Handler(char * file, int line) ' I can not understand what is the problem.  I also attached the full project at the attachment.

#stm32cubemx-4.22-systemclock_config-bug*
This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
September 8, 2017
Posted on September 08, 2017 at 10:06

And does your external clock actually start and function? 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Subrat Sahu
Associate
September 8, 2017
Posted on September 08, 2017 at 18:41

Thanks for Reply,

I have not tested the code on real hardware. I have debugged the code in Keil Simulator(Debugger). the program has been going in to infinite loop of 'Error_Handler' during the SystemClock_Config() .

Vangelis Fortounas
Associate II
September 8, 2017
Posted on September 08, 2017 at 19:23

Hello!

Your code is working fine in my cheap ebay board with f103c8t6

Try to increase the timeout  of ''HSE clock ready'' like this

0690X00000608ANQAY.png

If you put eg 5000 and you have the same error..  the oscillator is problematic(crystal  capacitors resistors)

Actually the 100ms are very enough to start the HSE!