Skip to main content
Wassim Ben Chikha
Associate III
October 2, 2017
Question

Problem in switching the SYSCLK to MSI in STM32CubeHALv1.7.0

  • October 2, 2017
  • 4 replies
  • 1141 views
Posted on October 02, 2017 at 10:39

Hi,

I

n

the HAL_RCC_DeInit function,

switching the SYSCLK to MSI

only

uses

this function

CLEAR_BIT(RCC->CFGR, RCC_CFG_SW)

. But, to select MSI as system clock source, I think that it is required to use

after that

th

e following

instruction

SET_BIT(RCC->CFGR, RCC_CFGR_SW_MSI). Please, can you verify if there are some problems in the function HAL_RCC_DeInit?

Many thanks for your time and look forward for your response.

Best regards,

Wassim Ben Chikha

    This topic has been closed for replies.

    4 replies

    Technical Moderator
    October 2, 2017
    Posted on October 02, 2017 at 18:17

    Hello,

    Could you please precise in which STM32Cube HAL library you have found this issue?  So, we can verify it.

    If you are using an old version

    of Cube firmware package

     try to use the latest. Then, please let us know if the issue still exist with the last version.

    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
    Tesla DeLorean
    Guru
    October 2, 2017
    Posted on October 02, 2017 at 19:13

    Using STM32L152RE

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Technical Moderator
    October 3, 2017
    Posted on October 03, 2017 at 10:43

    Hi,

    Thank you for sharing the details. I will check your reported issue, then raise it internally if confirmed.

    I will keep you informed about the taken actions or explanation if needed.

    Kind 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
    Yohann M.
    ST Employee
    October 5, 2017
    Posted on October 05, 2017 at 11:01

    Hello,

    The implementation is correct. To switch MSI to the system clock, value in the bit CFGR_SW should be equal to 0.

    This is done with CLEAR_BIT macro.

    A problem we may have in this function is that we don't wait for MSI RDY bit after switch on it.

    ----------

    void

    HAL_RCC_DeInit

    (

    void

    )

    {

    /* Set MSION bit */

    SET_BIT(RCC->

    CR

    , RCC_CR_MSION);

      /* Wait till MSI is ready */

    while (READ_BIT(RCC->CR, RCC_CR_MSIRDY) == RESET) {}

    /* Switch SYSCLK to MSI*/

    CLEAR_BIT

    (RCC->

    CFGR

    , RCC_CFGR_SW);

    (...)

    Technical Moderator
    April 25, 2019

    Hello,

    This issue is fixed with the STM32CubeL1 FW V1.9.0 release.

    Thanks

    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