cancel
Showing results for 
Search instead for 
Did you mean: 

About the �?LL_AHB1_GRP1_EnableClock�? function of the LL library

Sodag.1
Associate II

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;

}

1 ACCEPTED SOLUTION

Accepted Solutions
Nikita91
Lead II

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.

View solution in original post

2 REPLIES 2
Nikita91
Lead II

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.

Sodag.1
Associate II

I checked the contents in the reference manual.

Thank you for your cooperation.