cancel
Showing results for 
Search instead for 
Did you mean: 

Why does HAL_RCC_OscConfig() fail on demo code?

YPear.1
Associate II

NUCLEO-F429ZI

mxcube v6.1

HAL_RCC_OscConfig() fails using demo project I believe it fails exactly here:

pll_config = RCC->PLLCFGR;                                      

     if((READ_BIT(pll_config, RCC_PLLCFGR_PLLSRC) != RCC_OscInitStruct->PLL.PLLSource) 

      (READ_BIT(pll_config, RCC_PLLCFGR_PLLM) != RCC_OscInitStruct->PLL.PLLM) ||             

      (READ_BIT(pll_config, RCC_PLLCFGR_PLLN) != RCC_OscInitStruct->PLL.PLLN) ||             

      (READ_BIT(pll_config, RCC_PLLCFGR_PLLP) != RCC_OscInitStruct->PLL.PLLP) ||             

      (READ_BIT(pll_config, RCC_PLLCFGR_PLLQ) != RCC_OscInitStruct->PLL.PLLQ))              

     {                                                   

      return HAL_ERROR;                                          

     } 

I tried 2 boards, same result.

Using arm GCC

thanks,

6 REPLIES 6
Imen.D
ST Employee

Hello @YPear.1​ ,

Welcome to the STM32 Community :smiling_face_with_smiling_eyes:

You are right, there is an issue within HAL_RCC_OscConfig() when checking on the RCC_PLLCFGR register. This is already passed to our development team for fix in the coming release of STM32CubeF4.

So, the lines should be as follow:

if ((READ_BIT(pll_config, RCC_PLLCFGR_PLLSRC) != RCC_OscInitStruct->PLL.PLLSource) ||  
        (READ_BIT(pll_config, RCC_PLLCFGR_PLLM)   != (RCC_OscInitStruct->PLL.PLLM) << RCC_PLLCFGR_PLLM_Pos) ||  
        (READ_BIT(pll_config, RCC_PLLCFGR_PLLN)   != (RCC_OscInitStruct->PLL.PLLN) << RCC_PLLCFGR_PLLN_Pos) ||  
        (READ_BIT(pll_config, RCC_PLLCFGR_PLLP)   != (((RCC_OscInitStruct->PLL.PLLP >> 1U) - 1U)) << RCC_PLLCFGR_PLLP_Pos) ||  
        (READ_BIT(pll_config, RCC_PLLCFGR_PLLQ)   != (RCC_OscInitStruct->PLL.PLLQ) << RCC_PLLCFGR_PLLQ_Pos))
      {
        return HAL_ERROR;
      }

For more details, please refer to this github link .

Please mark my answer as best by clicking on the "Select as Best" button if it fully solved your issue. This will help other users find this solution more quickly.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
YPear.1
Associate II

Thank you! Do know when the release will be?

thanks,

The fix is integrated internally in the coming STM32CubeF4 release, but for the moment I have no information to share regarding the target date.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
YPear.1
Associate II

Unfortunately it seems like the code update leads to the same result. I tripled checked it. Any other insights?

thanks,

Make sure the structure is cleared if used as an automatic/local variable.

Show calling context.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
YPear.1
Associate II

I'm not sure what else to modify, this is code generated by cube mx. I added the patch from above.

    if ((READ_BIT(pll_config, RCC_PLLCFGR_PLLSRC) != RCC_OscInitStruct->PLL.PLLSource) ||  
            (READ_BIT(pll_config, RCC_PLLCFGR_PLLM)   != (RCC_OscInitStruct->PLL.PLLM) << RCC_PLLCFGR_PLLM_Pos) ||  
            (READ_BIT(pll_config, RCC_PLLCFGR_PLLN)   != (RCC_OscInitStruct->PLL.PLLN) << RCC_PLLCFGR_PLLN_Pos) ||  
            (READ_BIT(pll_config, RCC_PLLCFGR_PLLP)   != (((RCC_OscInitStruct->PLL.PLLP >> 1U) - 1U)) << RCC_PLLCFGR_PLLP_Pos) ||  
            (READ_BIT(pll_config, RCC_PLLCFGR_PLLQ)   != (RCC_OscInitStruct->PLL.PLLQ) << RCC_PLLCFGR_PLLQ_Pos))
          {
            return HAL_ERROR;
          }