This is an automated email from the ASF dual-hosted git repository.

acassis 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 1f9793b7b5f arch/arm/stm32h7: fix the period of the PPS output.
1f9793b7b5f is described below

commit 1f9793b7b5fbcfa61c976e24f700a8a22371e959
Author: Daniel P. Carvalho <[email protected]>
AuthorDate: Mon Sep 21 18:48:27 2026 -0300

    arch/arm/stm32h7: fix the period of the PPS output.
    
    The interval and the width of the pulse train of the PPS output were
    programmed as the number of increments of the system time minus one,
    but the MAC takes them as they are. Each period was one increment (10 ns
    with HCLK at 200 MHz) shorter than a second, so the pulses came 10 ns
    early each second, about 36 us in an hour, and the output drifted away
    from the system time.
    
    Program the interval and the width without subtracting one.
    
    On a run of 8.2 hours against a grandmaster clock the pulse moved 0.29 ms
    ahead of the system time, which is 10 ns per second, while the system time
    stayed within 1 us of the grandmaster. With the change, a run of 11 hours
    showed no drift of the pulse against the system time, within 3 us per hour
    on samples of 1 ms of resolution.
    
    Signed-off-by: Daniel P. Carvalho <[email protected]>
    Assisted-by: Claude:claude-sonnet-5
---
 arch/arm/src/stm32h7/stm32_ethernet.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_ethernet.c 
b/arch/arm/src/stm32h7/stm32_ethernet.c
index aa919d6d237..bda84f897a3 100644
--- a/arch/arm/src/stm32h7/stm32_ethernet.c
+++ b/arch/arm/src/stm32h7/stm32_ethernet.c
@@ -296,13 +296,12 @@
  * second and a width of half of it, that starts at a whole second of the
  * system time. The first pulse is at least STM32_PTP_PPS_MARGIN_NS ahead,
  * so the target time is loaded before it. The interval and the width are
- * in increments of the system time, minus one.
+ * in increments of the system time.
  */
 
 #    define STM32_PTP_PPS_MARGIN_NS   (100000000)
-#    define STM32_PTP_PPS_INTERVAL    (NSEC_PER_SEC / STM32_PTP_SSINC - 1)
-#    define STM32_PTP_PPS_WIDTH       ((NSEC_PER_SEC / 2) / \
-                                       STM32_PTP_SSINC - 1)
+#    define STM32_PTP_PPS_INTERVAL    (NSEC_PER_SEC / STM32_PTP_SSINC)
+#    define STM32_PTP_PPS_WIDTH       ((NSEC_PER_SEC / 2) / STM32_PTP_SSINC)
 #  endif
 #endif
 

Reply via email to