cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CUBEMX with Discovery F411VE

Michael Mihaylov
Associate

Hello after installing the latest version of CUBEMX(4.27) and generating a default project for my STM32F411VE Discovery board by choosing the option to initialize all the peripherals in their default mode it ended up not working. After some debugging I've come to the conclusion that it enters a failure while(1) loop in the SystemClock_Config function and more specifically at :

 RCC_OscInitTypeDef RCC_OscInitStruct;

 RCC_ClkInitTypeDef RCC_ClkInitStruct;

 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

   /**Configure the main internal regulator output voltage

   */

 __HAL_RCC_PWR_CLK_ENABLE();

 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

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

   */

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM = 4;

 RCC_OscInitStruct.PLL.PLLN = 192;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;

 RCC_OscInitStruct.PLL.PLLQ = 8;

 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

   _Error_Handler(__FILE__, __LINE__); /* <==============HERE */

 }

After further investigation of HAL_RCC_OscConfig

I've found that it returns HAL_TIMEOUT and more specifically in this section of code.

     /* Check the HSE State */

     if((RCC_OscInitStruct->HSEState) != RCC_HSE_OFF)

     {

       /* Get Start Tick*/

       tickstart = HAL_GetTick();

       /* Wait till HSE is ready */ 

       while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET)

       {

         if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)

         {

           return HAL_TIMEOUT;

         }

       }

     }

I've tried disabling some peripherals and nothing seems to work. Since I haven't really done anything special with the CODEMX generation (just chose the board and set up FreeRTOS with a systick of TIM11) I'm thinking it can only be a bug. And in my case it's a show stopper. I'd love some assistance.

Thank you in advance.

1 REPLY 1
Michael Mihaylov
Associate

After further investigation I've noticed the following:

  1. From the Pinout configuration RCC was set up as :

HSE - Bypass Clock source

LSE - Crystal/Ceramic resonator

nothing else was checked in the boxes below

2. After switching those so that HSE is using the resonator and the LSE is bypassing the clock source. The problem seems to have disappeared(it's no longer stuck at that place and a task is running .

What I do not understand is:

What does that change functionally? What would be the consequences of me doing that?

If there are no adverse consequences of me doing that then shouldn't have this been the default generation?