cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 RCC HSE Problem in Stm32cubeMX v4.21

Dnesh Sadat
Associate II
Posted on May 22, 2017 at 19:15

Hello ,

I designe my project using STM32F103RBT6 with 8 Mhz external crystal , and im using STM32CubeMX  4.21 .when i select HSE in RCC i have problem. when i debug the program , i have problem here:

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

but when using HSI all things fine,

what's the problem and How can i fix it?

2 REPLIES 2
Nesrine M_O
Lead II
Posted on May 22, 2017 at 19:32

Hi

Sadati.Danesh

,

I designe my project using STM32F103RBT6 with 8 Mhz external crystal , and im using STM32CubeMX 4.21 .when i select HSE in RCC i have problem.

-Nesrine-

Posted on May 23, 2017 at 10:27

Hello,

Im using

STM32F103RB nucleo Board . i think there is something wrong in stm32cubeMX software , here i the code that it generate :

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.PLL.PLLState = RCC_PLL_NONE;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

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

*/

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

/**Configure the Systick interrupt time

*/

HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

/**Configure the Systick

*/

HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

/* SysTick_IRQn interrupt configuration */

HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

This code doesn't work , but when i use HSI it works great.

Is there something wrong in generated code?