Skip to main content
Sodag.1
Associate III
Jun 24, 2022 8:14 AM UTC
Solved

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

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.
Nikita91
Nikita91Best answer
Lead II
Jun 24, 2022 4:26 PM UTC

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.

3 replies

Nikita91
Nikita91Best answer
Lead II
Jun 24, 2022 4:26 PM UTC

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.

AMacd.1
Senior
Feb 7, 2025 7:12 PM UTC

What reference manual?  Please cite.

Sodag.1
Sodag.1Author
Associate III
Jun 27, 2022 1:13 AM UTC

I checked the contents in the reference manual.

Thank you for your cooperation.