Skip to main content
zekeriya
Associate III
March 27, 2017
Solved

STM32F429 CLOCK CONFIGURATION PROBLEM

  • March 27, 2017
  • 18 replies
  • 4229 views
Posted on March 27, 2017 at 08:43

I am trying to configure HSE clock with 8Mhz crystal with STM32F429.

HAL_ERROR occurs when HAL_RCC_OscConfig function is executed in the following partition.

  /*----------------------------- HSI Configuration --------------------------*/

  if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI)

  {

    /* Check the parameters */

    assert_param(IS_RCC_HSI(RCC_OscInitStruct->HSIState));

    assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct->HSICalibrationValue));

    

    /* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */

    if((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_HSI) ||\

      ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_PLL) && ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSI)))

    {

      /* When HSI is used as system clock it will not disabled */

      if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON))

      {

        return HAL_ERROR;//Always this line works

      }

Actually HSE is running and ready, but the problem in HSI causes HAL_ERROR to return.

Error_Handler () is constantly running in this section with the reason for this problem.

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

    */

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|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 = 8;

  RCC_OscInitStruct.PLL.PLLN = 336;

  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

  RCC_OscInitStruct.PLL.PLLQ = 7;

  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

  {

    Error_Handler();

  }

I need help

Thank you

    This topic has been closed for replies.
    Best answer by Imen.D
    Posted on April 04, 2017 at 18:29

    Hello All,

    I would inform you that a new patch 

    http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

      V 4.20.1 is available to fix this issue.

    Sorry for any inconvenience this may cause you.

    Imen

    18 replies

    ST Technical Moderator
    March 27, 2017
    Posted on March 27, 2017 at 10:27

    Hello,

    This is confirmed bug in clock configuration with 

    CubeMx 4.20 and will be fixed soon

    in the new patch release.

    We apologize for any inconvenience this may cause.

     Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Pablo Leibovich
    Associate III
    March 27, 2017
    Posted on March 27, 2017 at 14:26

    Hi!

    I confirm that this bug is also present for STM32F072RB micros.

    Thanks!

    Zt Liu
    Senior III
    March 27, 2017
    Posted on March 27, 2017 at 10:28

    Hey, 

    I got this problem too in Nucleo STM32F446.

    I solved it by modifying the followings:

    Change

    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;

    to:

    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

    zekeriya
    zekeriyaAuthor
    Associate III
    March 27, 2017
    Posted on March 27, 2017 at 10:48

    Thank you Zhitai Liu for reply but,

    When I make this change, the processor becomes completely inoperable. It becomes flashing impossible. In order to get rid of this situation, I dismount the crystal and take it back again and start it again. So the processor becomes operational again. After that I put the crystal back in place. So I can get back to the beginning of the problem.

    Imen.DBest answer
    ST Technical Moderator
    April 4, 2017
    Posted on April 04, 2017 at 18:29

    Hello All,

    I would inform you that a new patch 

    http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-configurators-and-code-generators/stm32cubemx.html

      V 4.20.1 is available to fix this issue.

    Sorry for any inconvenience this may cause you.

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    zekeriya
    zekeriyaAuthor
    Associate III
    April 5, 2017
    Posted on April 05, 2017 at 08:24

     ,

     ,

    Hello Imen,

    I installed version 4.20.1. But the problem continues.

    If I do not change the RCC line like this,it is waiting in the infinite

    loop at the Error_Handler().

    //RCC_OscInitStruct.OscillatorType =

    RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE,

    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE,

    Thank you

    Zekeriya Altınordu

    4.04.2017 19:30 tarihinde Imen D yazdı:

    >,

    STMicroelectronics Community

    <,https://community.st.com/?et=watches.email.thread>,

    >,

    Re: STM32F429 CLOCK CONFIGURATION PROBLEM

    reply from Imen D

    <,

    in /STM32 MCUs Forum/ - View the full discussion

    <,https://community.st.com/0D70X000006ScjCSAS

    >,

    Zt Liu
    Senior III
    April 5, 2017
    Posted on April 05, 2017 at 03:44

    Does any one check that CubeMX 4.20.1 really solve this issue?

    In my F446 project, I still need to comment out 

    RCC_OSCILLATORTYPE_HSI| to make HSE configured.

    784985211
    Associate
    April 5, 2017
    Posted on April 05, 2017 at 10:02

    CubeMX 4.20.1 have solved this issue,

    I just tried it

    。
    ST Technical Moderator
    April 5, 2017
    Posted on April 05, 2017 at 10:52

    Hi,

    This issue is resolved with the new patch and I have checked this by creating a new project to have the correct configuration.

    But, as you are using an old .ioc project, you should first EDIT the .ioc file and REMOVE this line (remove the RCC.OscillatorType that you don't need)

    RCC.OscillatorTypeHSI=RCC_OSCILLATORTYPE_HSI

    Then re-generate the project, this will resolve your problem.

    Please keep me informed about your updates.

    Best Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks