cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX 4.22 SystemClock_Config Bug

Subrat Sahu
Associate II
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*
10 REPLIES 10
Posted on September 09, 2017 at 12:03

Hi,

Ok,  I understand now. I am  working before in arduino ide to program  Stm32f103 . Therefore i have not aware much about inside of stm hal library. Now I have to study the internal structure of hal library for my knowledge.  Many many thanks for your help.