You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "wangchdo (via GitHub)" <gi...@apache.org> on 2025/11/12 08:33:57 UTC

[PR] arch: introduce up_timer_trigger for fast timer irq trigger [nuttx]

wangchdo opened a new pull request, #17318:
URL: https://github.com/apache/nuttx/pull/17318

   ## Summary
   
   This PR introduces a new architecture API: up_timer_trigger(), which allows triggering a timer interrupt instantly and safely.
   It resolves an issue where up_alarm_start() or up_alarm_tick_start() could start the timer earlier than the current alarm time, leading to an incorrect timeout value. This could cause the timer interrupt to occur much later than expected—only after the timer counter overflows to the wrong timeout.
   
   This API can be used to test system timer interrupt handling or to improve the watchdog implementation in tickless mode.
   
   ## Impact
   
   Introduce new API: up_timer_trigger(). No functional impact to existing NuttX features.
   
   ## Testing
   
   **ostest passed on board a2g-tc397-5v-tft**
   
   NuttShell (NSH)
   nsh>
   nsh> uname -a
   NuttX 0.0.0 4f398c2e65 Nov 12 2025 16:24:15 tricore a2g-tc397-5v-tft
   nsh>
   nsh> ostest
   
   (...)
   
   user_main: scheduler lock test
   sched_lock: Starting lowpri_thread at 97
   sched_lock: Set lowpri_thread priority to 97
   sched_lock: Starting highpri_thread at 98
   sched_lock: Set highpri_thread priority to 98
   sched_lock: Waiting...
   sched_lock: PASSED No pre-emption occurred while scheduler was locked.
   sched_lock: Starting lowpri_thread at 97
   sched_lock: Set lowpri_thread priority to 97
   sched_lock: Starting highpri_thread at 98
   sched_lock: Set highpri_thread priority to 98
   sched_lock: Waiting...
   sched_lock: PASSED No pre-emption occurred while scheduler was locked.
   sched_lock: Finished
   
   End of test memory usage:
   VARIABLE  BEFORE   AFTER
   ======== ======== ========
   arena       28dfc    28dfc
   ordblks         7        6
   mxordblk    1f8c8    1f8c8
   uordblks     553c     553c
   fordblks    238c0    238c0
   
   user_main: nxevent test
   
   End of test memory usage:
   VARIABLE  BEFORE   AFTER
   ======== ======== ========
   arena       28dfc    28dfc
   ordblks         6        6
   mxordblk    1f8c8    1f8c8
   uordblks     553c     553c
   fordblks    238c0    238c0
   
   Final memory usage:
   VARIABLE  BEFORE   AFTER
   ======== ======== ========
   arena       28dfc    28dfc
   ordblks         1        6
   mxordblk    24238    1f8c8
   uordblks     4bc4     553c
   fordblks    24238    238c0
   user_main: Exiting
   ostest_main: Exiting with status 0
   nsh>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: introduce up_timer_trigger for fast timer irq trigger [nuttx]

Posted by "wangchdo (via GitHub)" <gi...@apache.org>.
wangchdo commented on PR #17318:
URL: https://github.com/apache/nuttx/pull/17318#issuecomment-3522514265

   > > ## Summary
   > 
   > > This PR introduces a new architecture API: up_timer_trigger(), which allows triggering a timer interrupt instantly and safely. It resolves the issue where up_alarm_start() or up_alarm_tick_start() could start the timer earlier than the current alarm time, leading to an incorrect timeout value. This could cause the timer interrupt to occur much later than expected—only after the timer counter overflows to the wrong timeout.
   > 
   > 
   > 
   > I already point out in another PR, the new api doesn't change anything at all, so please don't try ths direction again.
   
   OK I agree, I think it would be better to improve up_timer_start


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: introduce up_timer_trigger for fast timer irq trigger [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #17318:
URL: https://github.com/apache/nuttx/pull/17318#issuecomment-3521778708

   > ## Summary
   > This PR introduces a new architecture API: up_timer_trigger(), which allows triggering a timer interrupt instantly and safely. It resolves the issue where up_alarm_start() or up_alarm_tick_start() could start the timer earlier than the current alarm time, leading to an incorrect timeout value. This could cause the timer interrupt to occur much later than expected—only after the timer counter overflows to the wrong timeout.
   
   I already point out in another PR, the new api doesn't change anything at all, so please don't try ths direction.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: introduce up_timer_trigger for fast timer irq trigger [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #17318:
URL: https://github.com/apache/nuttx/pull/17318#discussion_r2518344104


##########
arch/arm/src/armv8-r/arm_arch_timer.c:
##########
@@ -417,3 +417,10 @@ void arm_arch_timer_secondary_init()
 #endif
 }
 #endif
+
+int up_timer_trigger(void)

Review Comment:
   @wangchdo please include a reference to this new up_timer_trigger in some Documentation pages, the only place where I found up_trigger_irq() was here: https://nuttx.apache.org/docs/latest/guides/zerolatencyinterrupts.html



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch: introduce up_timer_trigger for fast timer irq trigger [nuttx]

Posted by "wangchdo (via GitHub)" <gi...@apache.org>.
wangchdo closed pull request #17318: arch: introduce up_timer_trigger for fast timer irq trigger
URL: https://github.com/apache/nuttx/pull/17318


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org