Skip to main content
John Hite
Associate III
March 15, 2017
Solved

APB1PeriphClock

  • March 15, 2017
  • 3 replies
  • 894 views
Posted on March 15, 2017 at 17:38

Is there a function or macro for determining the frequency of APB1PeriphClock and APB2PeriphClock?

Thanks,

jh

#apb1periphclock
This topic has been closed for replies.
Best answer by Tesla DeLorean
Posted on March 15, 2017 at 18:07

  RCC_ClocksTypeDef RCC_Clocks;

  /* SysTick end of count event each 1ms */

  RCC_GetClocksFreq(&RCC_Clocks);

  printf('SYS:%d H:%d, P1:%d, P2:%d\r\n',

                      RCC_Clocks.SYSCLK_Frequency,

                      RCC_Clocks.HCLK_Frequency,   // AHB

                      RCC_Clocks.PCLK1_Frequency,  // APB1

                      RCC_Clocks.PCLK2_Frequency); // APB2

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 15, 2017
Posted on March 15, 2017 at 18:07

  RCC_ClocksTypeDef RCC_Clocks;

  /* SysTick end of count event each 1ms */

  RCC_GetClocksFreq(&RCC_Clocks);

  printf('SYS:%d H:%d, P1:%d, P2:%d\r\n',

                      RCC_Clocks.SYSCLK_Frequency,

                      RCC_Clocks.HCLK_Frequency,   // AHB

                      RCC_Clocks.PCLK1_Frequency,  // APB1

                      RCC_Clocks.PCLK2_Frequency); // APB2
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Khouloud GARSI
ST Employee
March 15, 2017
Posted on March 15, 2017 at 18:51

Hi

Hite.John

,

  • In SPL you can use 'RCC_GetClocksFreq' which returns the frequencies of different on chip clocks: SYSCLK, HCLK, PCLK1 and PCLK2.

void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)

  • In cube, there is:

uint32_t HAL_RCC_GetPCLK1Freq(void) : Returns the PCLK1 frequency

uint32_t HAL_RCC_GetPCLK2Freq(void) : Returns the PCLK2 frequency

Khouloud

John Hite
John HiteAuthor
Associate III
March 15, 2017
Posted on March 15, 2017 at 18:59

I thank you both.

John