工具/软件:
您好:
我按如下方式读取 RTC 秒和秒数:
// process rtc if(!rtc_semaphore) { // check if rtc is being accessed rtc_semaphore = true; // set rtc semaphore true g_rtc_mark = HWREG(HIB_RTCC); // mark rtc seconds g_rtc_sub_mark = (HWREG(HIB_RTCSS) & HIB_RTCSS_RTCSSC_M); // mark rtc subseconds valid_timing = (g_rtc_mark == HWREG(HIB_RTCC)); // if seconds are not the same timing is valid } else { valid_timing = false; // rtc is being accessed } rtc_semaphore = false; // set rtc semaphore false as soon as we are done with RTC
这在定期触发的循环内运行。 按照数据表中的指示、我先读取 RTCC、然后读取 RTCSS、然后再次读取 RTCC (与第一次读取相比)、只有当两者都相等时、我才处理通过 VALID_TIMING 标志读取的数据。 还有一个 RTC_信 标将在 RTC 被代码的另一部分读取时(例如 usb_handler.h 中)跳过数据包、用于测量传入的同步数据包与 RTC 的差异。
以下是 RTC 和主机时间戳及其差异(以纳米为单位)的日志:
[node-1] [INFO] [1748355072.989121466] [node]: nanos_diff 769990 rtc 1748355072.32386 host 1748355072.989112275 [node-1] [INFO] [1748355072.992817739] [node]: nanos_diff 559546 rtc 1748355072.32514 host 1748355072.992808081 [node-1] [INFO] [1748355072.996931401] [node]: nanos_diff 767505 rtc 1748355072.32642 host 1748355072.996922290 [node-1] [INFO] [1748355073.000778899] [node]: nanos_diff -999196287 rtc 1748355073.32767 host 1748355073.773195 [node-1] [INFO] [1748355073.004645475] [node]: nanos_diff 761379 rtc 1748355073.127 host 1748355073.4637111 [node-1] [INFO] [1748355073.008656346] [node]: nanos_diff 865244 rtc 1748355073.255 host 1748355073.8647226 [node-1] [INFO] [1748355073.012311718] [node]: nanos_diff 614277 rtc 1748355073.383 host 1748355073.12302509 [node-1] [INFO] [1748355073.016466674] [node]: nanos_diff 865056 rtc 1748355073.511 host 1748355073.16459538
发生的情况是、在第二个读数即将结束时、RTC 位于1748355072.32642、下一个读数位于 RTC 1748355073.32767、下一个读数为1748355073.127
第二次跳到新的第二次,但次秒属于旧的第二次。 如果我先读取 RTCSS、然后读取 RTCC、RTCC 可以递增+1。 但我首先读取 RTCC、读取子秒、然后再次读取 RTCC、看看它们是否相等。 它们一直是、但第二个是比预期的+1。
任何想法的建议都有助于非常感激。
此致、
c.