Skip to content

Commit 330480d

Browse files
committed
fix for peripheral clock read on stm32h7
1 parent e3c4aeb commit 330480d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/stm/peripherals/timers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef *timer) {
164164
source = HAL_RCC_GetPCLK2Freq();
165165
// 0b0xx means not divided; 0b100 is divide by 2; 0b101 by 4; 0b110 by 8; 0b111 by 16.
166166
#ifdef STM32H7
167-
clk_div = (RCC->CFGR & RCC_D2CFGR_D2PPRE2);
167+
clk_div = (RCC->D2CFGR & RCC_D2CFGR_D2PPRE2) >> RCC_D2CFGR_D2PPRE2_Pos;
168168
#else
169169
clk_div = (RCC->CFGR & RCC_CFGR_PPRE2) >> RCC_CFGR_PPRE2_Pos;
170170
#endif
@@ -173,7 +173,7 @@ uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef *timer) {
173173
source = HAL_RCC_GetPCLK1Freq();
174174
// 0b0xx means not divided; 0b100 is divide by 2; 0b101 by 4; 0b110 by 8; 0b111 by 16.
175175
#ifdef STM32H7
176-
clk_div = (RCC->CFGR & RCC_D1CFGR_D1PPRE_Msk);
176+
clk_div = (RCC->D1CFGR & RCC_D1CFGR_D1PPRE) >> RCC_D1CFGR_D1PPRE_Pos;
177177
#else
178178
clk_div = (RCC->CFGR & RCC_CFGR_PPRE1) >> RCC_CFGR_PPRE1_Pos;
179179
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy