Skip to content

What timer interrupts are enabled in RP2040 Zeptoforth? #49

Answered by tabemann
robzed asked this question in Q&A
Discussion options

You must be logged in to vote

The only problem with this setup is when next-robot-tick plus ROBOT-TICK-MICROSECS is in the past ─ then it will have to wrap around the 32-bit time before the timer interrupt is triggered. This is why it is hard to make a non-slipping timer using the timer interrupt.

Here is my attempt at making a non-slipping timer, using your code:

timer import

0 constant ROBOT-TICK-ALARM
2000 constant ROBOT-TICK-MICROSECS
variable next-robot-tick
variable robot-tick-xt

\ DEBUG
variable counter

: set-next-alarm
    \ set the next interrupt time
    begin
      ROBOT-TICK-MICROSECS next-robot-tick +!
      next-robot-tick @ us-counter-lsb - 0> dup not if
        robot-tick-xt @ execute
      then
   …

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
8 replies
@tabemann
Comment options

@tabemann
Comment options

@robzed
Comment options

@robzed
Comment options

@tabemann
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@robzed
Comment options

@tabemann
Comment options

Answer selected by robzed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants