Skip to main content
Visitor II
June 24, 2022
Solved

About the ?LL_AHB1_GRP1_EnableClock ? function of the LL library

  • June 24, 2022
  • 2 replies
  • 1621 views

Regarding LL_AHB1_GRP1_EnableClock, after setting bit in the function, it is read to "tmprg" and cast to void type. What is the reason for reading?

__STATIC_INLINE void LL_AHB1_GRP1_EnableClock(uint32_t Periphs)

{

 __IO uint32_t tmpreg;

 SET_BIT(RCC->AHBENR, Periphs);

 /* Delay after an RCC peripheral clock enabling */

 tmpreg = READ_BIT(RCC->AHBENR, Periphs);

 (void)tmpreg;

}

    This topic has been closed for replies.
    Best answer by Nikita91

    It is because in the reference manual it is indicated that after having validated a clock it is necessary to wait a little before it is effective.

    The way to do this is to read the register again. In this way we are sure that the writing in the register has been effective (not delayed by the multiple bridges between the buses) and the clock started before using it.

    The method used here is a bit crude because storing the read result in a volatile variable is unnecessary.

    2 replies

    Nikita91Answer
    Explorer II
    June 24, 2022

    It is because in the reference manual it is indicated that after having validated a clock it is necessary to wait a little before it is effective.

    The way to do this is to read the register again. In this way we are sure that the writing in the register has been effective (not delayed by the multiple bridges between the buses) and the clock started before using it.

    The method used here is a bit crude because storing the read result in a volatile variable is unnecessary.

    Graduate II
    February 7, 2025

    What reference manual?  Please cite.

    Sodag.1Author
    Visitor II
    June 27, 2022

    I checked the contents in the reference manual.

    Thank you for your cooperation.