Skip to content

Fix micros() for nano without breaking giga#174

Open
soburi wants to merge 1 commit intozephyrproject-rtos:nextfrom
soburi:micros_64bit
Open

Fix micros() for nano without breaking giga#174
soburi wants to merge 1 commit intozephyrproject-rtos:nextfrom
soburi:micros_64bit

Conversation

@soburi
Copy link
Copy Markdown
Member

@soburi soburi commented Apr 17, 2026

The rollover fix for the giga used the 64 bit timer instead of 32 bits. The nano does not have a 64 bit timer, so you need to use the 32 bit instead.

So I know check to see if the processor supports 64 bits if so use it else fall back to 32 bit.

Note: This branch doesn't include support for Arduino Giga,
but we'll include it as it's a reasonable solution for
preventing timer overflows.

Copilot AI review requested due to automatic review settings April 17, 2026 12:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates micros() to use Zephyr’s 64-bit cycle counter when the platform supports it, while preserving compatibility with targets that only provide a 32-bit cycle counter (e.g., Nano).

Changes:

  • Adds a CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER compile-time check in micros().
  • Uses k_cycle_get_64() on 64-bit cycle-counter platforms and falls back to k_cycle_get_32() otherwise.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soburi soburi requested a review from DhruvaG2000 April 17, 2026 13:15
The rollover fix for the giga used the 64 bit timer instead of 32
bits.  The nano does not have a 64 bit timer, so you need to use
the 32 bit instead.

So I know check to see if the processor supports 64 bits if so use it
else fall back to 32 bit.

Note: This branch doesn't include support for Arduino Giga,
      but we'll include it as it's a reasonable solution for
      preventing timer overflows.

Co-Authored-by: Kurt Eckhardt <kurte@rockisland.com>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants