[PATCH] bsps/arm: fix Cortex-M7 systick reload value

Dariusz Sabała dariusz.sabala at creotech.pl
Wed Oct 26 07:38:24 UTC 2022


>From e17fb5abf82d03baf25ee16433c9d6e9861e3e3a Mon Sep 17 00:00:00 2001
From: Dariusz Sabala <dariusz.sabala at creotech.pl>
Date: Tue, 25 Oct 2022 11:11:20 +0200
Subject: [PATCH] bsps/arm: fix Cortex-M7 systick reload value

- see ARM DUI 0646C Arm Cortex-M7 Devices Generic User Guide
  "The RELOAD value is calculated according to its use.
  For example, to generate a multi-shot timer with a period
  of N processor clock cycles, use a RELOAD value of N-1.
  If the SysTick interrupt is required every 100 clock pulses,
  set RELOAD to 99."
- see routines used in CMSIS project for reference
---
 bsps/arm/shared/clock/clock-armv7m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bsps/arm/shared/clock/clock-armv7m.c b/bsps/arm/shared/clock/clock-armv7m.c
index 255de1ca42..c870684980 100644
--- a/bsps/arm/shared/clock/clock-armv7m.c
+++ b/bsps/arm/shared/clock/clock-armv7m.c
@@ -90,7 +90,7 @@ static void _ARMV7M_Clock_initialize_early(void)

   interval = (uint32_t) ((freq * us_per_tick) / 1000000);

-  systick->rvr = interval;
+  systick->rvr = interval - 1;
   systick->cvr = 0;
   systick->csr = ARMV7M_SYSTICK_CSR_ENABLE | ARMV7M_SYSTICK_CSR_CLKSOURCE;
 }
--
2.34.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20221026/2c5a4e22/attachment-0001.htm>


More information about the devel mailing list