This is an automated email from the ASF dual-hosted git repository.
simbit18 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new e3b1e5914eb arch/arm/src: Add necessary conversion between tick and
usec for tickless
e3b1e5914eb is described below
commit e3b1e5914eb9ac319dc26a993c92912a02d1b862
Author: taoliu <[email protected]>
AuthorDate: Thu Feb 26 17:40:56 2026 +0800
arch/arm/src: Add necessary conversion between tick and usec for tickless
When testing tickless scheme with default arm_systick.c, we found the
count writed to systick register is too smaller the expected, just the
ticks not count, and os runing abnormally with too much interrupter.
Add necessary coversion, then system run well.
Signed-off-by: taoliu <[email protected]>
---
arch/arm/src/armv7-m/arm_systick.c | 11 ++++++++---
arch/arm/src/armv8-m/arm_systick.c | 11 ++++++++---
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/arch/arm/src/armv7-m/arm_systick.c
b/arch/arm/src/armv7-m/arm_systick.c
index a25df880f5f..28c676e1598 100644
--- a/arch/arm/src/armv7-m/arm_systick.c
+++ b/arch/arm/src/armv7-m/arm_systick.c
@@ -255,8 +255,11 @@ static int systick_interrupt(int irq, void *context, void
*arg)
if (lower->callback && systick_is_running())
{
uint32_t reload = getreg32(NVIC_SYSTICK_RELOAD);
- uint32_t interval = usec_from_count(
- RELOAD2TIMEOUT(reload), lower->freq);
+
+ /* Convert count to us then to tick for callback parameter */
+
+ uint32_t interval = USEC2TICK(usec_from_count(
+ RELOAD2TIMEOUT(reload), lower->freq));
uint32_t next_interval = interval;
lower->next_interval = &next_interval;
@@ -264,8 +267,10 @@ static int systick_interrupt(int irq, void *context, void
*arg)
{
if (next_interval && next_interval != interval)
{
+ /* Recover tick to us then to count for register writing */
+
reload = TIMEOUT2RELOAD(
- usec_to_count(next_interval, lower->freq));
+ usec_to_count(TICK2USEC(next_interval), lower->freq));
putreg32(CLAMP_RELOAD(reload), NVIC_SYSTICK_RELOAD);
putreg32(0, NVIC_SYSTICK_CURRENT);
}
diff --git a/arch/arm/src/armv8-m/arm_systick.c
b/arch/arm/src/armv8-m/arm_systick.c
index 9a0d5f52112..ca448e5b12a 100644
--- a/arch/arm/src/armv8-m/arm_systick.c
+++ b/arch/arm/src/armv8-m/arm_systick.c
@@ -255,8 +255,11 @@ static int systick_interrupt(int irq, void *context, void
*arg)
if (lower->callback && systick_is_running())
{
uint32_t reload = getreg32(NVIC_SYSTICK_RELOAD);
- uint32_t interval = usec_from_count(
- RELOAD2TIMEOUT(reload), lower->freq);
+
+ /* Convert count to us then to tick for callback parameter */
+
+ uint32_t interval = USEC2TICK(usec_from_count(
+ RELOAD2TIMEOUT(reload), lower->freq));
uint32_t next_interval = interval;
lower->next_interval = &next_interval;
@@ -264,8 +267,10 @@ static int systick_interrupt(int irq, void *context, void
*arg)
{
if (next_interval && next_interval != interval)
{
+ /* Recover tick to us then to count for register writing */
+
reload = TIMEOUT2RELOAD(
- usec_to_count(next_interval, lower->freq));
+ usec_to_count(TICK2USEC(next_interval), lower->freq));
putreg32(CLAMP_RELOAD(reload), NVIC_SYSTICK_RELOAD);
putreg32(0, NVIC_SYSTICK_CURRENT);
}