From 4d8a1b355d85c7d61f56f1323b607cbb2733f4ff Mon Sep 17 00:00:00 2001 From: Nate Gay Date: Tue, 30 Dec 2025 23:52:04 -0600 Subject: [PATCH] Enable microsecond precision --- .../Components/Drv/RtcManager/RtcManager.cpp | 8 ++++---- prj.conf | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/FprimeZephyrReference/Components/Drv/RtcManager/RtcManager.cpp b/FprimeZephyrReference/Components/Drv/RtcManager/RtcManager.cpp index 128f476c..4d6de020 100644 --- a/FprimeZephyrReference/Components/Drv/RtcManager/RtcManager.cpp +++ b/FprimeZephyrReference/Components/Drv/RtcManager/RtcManager.cpp @@ -28,10 +28,10 @@ void RtcManager ::configure(const struct device* dev) { // ---------------------------------------------------------------------- void RtcManager ::timeGetPort_handler(FwIndexType portNum, Fw::Time& time) { - // Get system uptime - int64_t t = k_uptime_get(); - U32 seconds_since_boot = static_cast(t / 1000); - U32 useconds_since_boot = static_cast((t % 1000) * 1000); + // Get system uptime in useconds + int64_t t = k_uptime_ticks(); + U32 seconds_since_boot = static_cast(t / 1000000); + U32 useconds_since_boot = static_cast(t % 1000000); // Check device readiness if (!device_is_ready(this->m_dev)) { diff --git a/prj.conf b/prj.conf index 69773c74..f255f27c 100644 --- a/prj.conf +++ b/prj.conf @@ -10,6 +10,10 @@ CONFIG_MAIN_STACK_SIZE=8192 CONFIG_POSIX_API=y CONFIG_REBOOT=y +#### System Clock Configuration #### +# Run system clock at 1 MHz for microsecond precision timing +CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000000 + #### Native USB #### #CONFIG_USB_DEVICE_STACK=y #CONFIG_USB_CDC_ACM=y