Skip to contentSkip to conversation

ARM: stm32f7: fix prescaler calculation of timer

PATCH In review Bo Shen 3 participants 3 messages Oct 3, 2017 – Oct 9, 2017

Subsystems (3)
lore
Share & tools
lore

Bo Shen

author
#0 lore raw

PATCH 1/1 ARM: stm32f7: fix prescaler calculation of timer

As the timer 2 is on APB1 bus, the maximum of clock frequency of APB1 timer clock is half of SYSCLK. Then to calculate the timer prescaler for timer 2 which need to be divided by 2.

---
 arch/arm/mach-stm32/stm32f7/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32/stm32f7/timer.c +1 -1
index c15f8bb..b04c101 100644
@@ -26,7 +26,7 @@ int timer_init(void)
 	/* Stop the timer */
 	writel(readl(&gpt1_regs_ptr->cr1) & ~GPT_CR1_CEN, &gpt1_regs_ptr->cr1);
 
-	writel((CONFIG_SYS_CLK_FREQ/CONFIG_SYS_HZ_CLOCK) - 1,
+	writel((CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ_CLOCK) - 1,
 						&gpt1_regs_ptr->psc);
 
 	/* Configure timer for auto-reload */
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 ARM: stm32f7: fix prescaler calculation of timer

Quoted 8 lines

-----Original Message-----
From: Bo Shen [mailto:voice.shen at gmail.com]
Sent: Monday, October 02, 2017 10:48 PM
To: albert.u.boot at aribaud.net; Vikas MANOCHA <[email protected]>
Cc: u-boot at lists.denx.de; Bo Shen <[email protected]>
Subject: [PATCH] ARM: stm32f7: fix prescaler calculation of timer

Quoted 4 lines

As the timer 2 is on APB1 bus, the maximum of clock frequency of APB1 timer clock is half of SYSCLK. Then to calculate the timer prescaler for timer 2 which need to be divided by 2.

Cheers,
Vikas

Quoted 19 lines
---
 arch/arm/mach-stm32/stm32f7/timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-stm32/stm32f7/timer.c +1 -2
index c15f8bb..b04c101 100644
@@ -26,7 +26,7 @@ int timer_init(void)
 	/* Stop the timer */
 	writel(readl(&gpt1_regs_ptr->cr1) & ~GPT_CR1_CEN, &gpt1_regs_ptr->cr1);
 
-	writel((CONFIG_SYS_CLK_FREQ/CONFIG_SYS_HZ_CLOCK) - 1,
+	writel((CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ_CLOCK) - 1,
 						&gpt1_regs_ptr->psc);
 
 	/* Configure timer for auto-reload */
--

2.7.4

#2 lore raw
In reply to Bo Shen
Quoted 6 lines · Bo Shen

As the timer 2 is on APB1 bus, the maximum of clock frequency of APB1 timer clock is half of SYSCLK. Then to calculate the timer prescaler for timer 2 which need to be divided by 2.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171009/43705bb7/attachment.sig>