Skip to content

cpu/rp2350: implement timers - #22375

Open
AnnsAnns wants to merge 5 commits into
RIOT-OS:masterfrom
AnnsAnns:rp2350_timer
Open

AnnsAnns wants to merge 5 commits into
RIOT-OS:masterfrom
AnnsAnns:rp2350_timer

Conversation

@AnnsAnns

@AnnsAnns AnnsAnns commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

Contribution description

Part of the ongoing "wait people actually use the pico2, oh god why" series. This implements timer support, hooray. Timers are surprisingly not that complicated, I just never looked at them when adding support because I didn't have a proper use outside of xosc_sleep which was enough for my needs.

Testing procedure

cd examples/guides/timers
sudo BOARD=rpi-pico-2-arm make flash term PORT=/dev/ttyUSB0

Issues/PRs references

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:
-The initial timer was based on the pico 1 timer together with Claude Fable 5, mostly to experiment with it, I cross checked its claims with the datasheet at all times, chapter 12.8 and related timer tables are fairly understandable.

@github-actions github-actions Bot added Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports labels Jun 11, 2026
@AnnsAnns AnnsAnns added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 11, 2026
@riot-ci

riot-ci commented Jun 11, 2026 •

Copy link
Copy Markdown

Murdock results

✔️ PASSED

bef7f0a Update cpu/common/rp2350/periph/timer.c

Success Failures Total Runtime
14016 0 14017 09m:28s

Artifacts

@crasbe crasbe added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label Jun 11, 2026
Comment thread cpu/rp2350_common/Makefile.features Resolved
Comment thread cpu/common/rp2350/periph/timer.c Resolved
Comment thread cpu/rp2350_common/periph/timer.c Resolved
/**
* @ingroup cpu_rp2350
* @{
*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe you can add a comment here which date and version the RP2350 Reference Manual has that is referenced here. That will make it much easier in 10 years when all the references have changed 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

where is the fun in that, future generations need to be scared of me in the git blame

Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/periph/timer.c Outdated
Comment on lines +112 to +113
if (!timeout) {
/* catch case that a tick happens right before arming the alarm */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I find this confusion. Firstly I'd write if(timeout == 0), as it is an integer and not a boolean. Same comparison, but the former is IMO clearer than the latter.

Secondly, the comment does not really fit the code, does it? The alarm won't be armed for timeout == 0, instead the callback is just called once.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have to be honest I forgot the context of this

return 0;
}

int timer_set_absolute(tim_t dev, int channel, unsigned int value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this function need a check for value >= 0?
Does a value of 0 or a negative value make sense?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not following, isn't that the idea of making it unsigned?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I probably overlooked that it is unsigned.

Still, is a value of 0 permissible?

return 0;
}

int timer_set_periodic(tim_t dev, int channel, unsigned int value, uint8_t flags)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this function need a check for value >= 0?
Does a value of 0 or a negative value make sense?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

s. above

Comment thread cpu/rp2350_common/periph/timer.c Outdated
unsigned state = irq_disable();
/* The ARMED bits are write-1-clear (table 1236) */
DEV(dev)->ARMED = 1u << channel;
flag_periodic[dev] &= ~(1u << channel);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we also reset the _flag_reset flag here? Not that it would matter much (it is set and reset by timer_set), but maybe good practice?

Comment thread cpu/common/rp2350/periph/timer.c Resolved
@crasbe

crasbe commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Haven't tested it myself yet and I really don't have the time to at the moment, I just did some minor procrastination here.

@AnnsAnns

Copy link
Copy Markdown
Member Author

Thank you for looking into this, your procrastination counters mine, it's Yin and Yang 🫪

Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/common/rp2350/periph/timer.c Resolved
Comment thread cpu/common/rp2350/periph/timer.c Resolved

@crasbe crasbe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not use the existing register defines?

Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/include/timer_conf.h Resolved
Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/include/timer_conf.h Resolved
@AnnsAnns

Copy link
Copy Markdown
Member Author

Why not use the existing register defines?

I'm currently looking into getting the RP2350.h to be more compatible in general in the hopes of removing all defines that exist in the sdk, there is some weirdness still

@crasbe

crasbe commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Why not use the existing register defines?

I'm currently looking into getting the RP2350.h to be more compatible in general in the hopes of removing all defines that exist in the sdk, there is some weirdness still

I don't quite follow?

@AnnsAnns AnnsAnns left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ty for the reviews, since I have an exam on Monday my brain decided that now is the perfect time to look at this instead of doing stuff for my exam 🤠👍

Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/periph/timer.c Resolved
return -ENODEV;
}
/* TICKS blocks are designed to generate 1 us ticks, so we can only support that frequency */
assert(freq == US_PER_SEC);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I forgot the complete context of this but as far as I remember that frequency is used internally for timers yes

Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/periph/timer.c Resolved
Comment thread cpu/rp2350_common/periph/timer.c Outdated
Comment on lines +112 to +113
if (!timeout) {
/* catch case that a tick happens right before arming the alarm */

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have to be honest I forgot the context of this

return 0;
}

int timer_set_absolute(tim_t dev, int channel, unsigned int value)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not following, isn't that the idea of making it unsigned?

return 0;
}

int timer_set_periodic(tim_t dev, int channel, unsigned int value, uint8_t flags)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

s. above

Comment thread cpu/common/rp2350/periph/timer.c Resolved
Comment thread cpu/common/rp2350/periph/timer.c Resolved
@AnnsAnns

AnnsAnns commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

oh wow my comments went wrong af

Comment thread cpu/rp2350_common/periph/timer.c Resolved
@AnnsAnns AnnsAnns added the AI: Co-Authored PR/Issue relies on AI. Documentation / Code was partly generated by AI. label Jul 6, 2026
@basilfx

basilfx commented Jul 6, 2026

Copy link
Copy Markdown
Member

Wanted to try this, but it isn't compiling for me:

Compile log
Building application "timers_example" for "rpi-pico-2-arm" with CPU "rp2350_arm".

"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/pkg/cmsis/
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/pkg/mpaland-printf/
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/build/pkg/mpaland-printf -f /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/pkg/mpaland-printf/mpaland-printf.mk
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/pkg/picosdk/
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/boards
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/boards/rpi-pico-2-arm
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/core
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/core/lib
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_arm
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/drivers
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/cortexm_common
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/drivers/periph_common
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/auto_init
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/div
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/boards/common/init
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/frac
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/libc
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/boards/common/rpi-pico-2
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/malloc_thread_safe
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/newlib_syscalls_default
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/cortexm_common/periph
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/preprocessor
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/stdio
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/stdio_uart
"make" -C /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/sys/ztimer
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c: In function 'timer_init':
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:82:40: error: 'RESETS_RESET_TIMER0_BITS' undeclared (first use in this function)
   82 |     reset_bit = (DEV(dev) == TIMER0) ? RESETS_RESET_TIMER0_BITS : RESETS_RESET_TIMER1_BITS;
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:82:40: note: each undeclared identifier is reported only once for each function it appears in
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:82:67: error: 'RESETS_RESET_TIMER1_BITS' undeclared (first use in this function)
   82 |     reset_bit = (DEV(dev) == TIMER0) ? RESETS_RESET_TIMER0_BITS : RESETS_RESET_TIMER1_BITS;
      |                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Applications/ArmGNUToolchain/15.2.rel1/arm-none-eabi/arm-none-eabi/include/sys/reent.h:462,
                 from /Applications/ArmGNUToolchain/15.2.rel1/arm-none-eabi/arm-none-eabi/include/sys/errno.h:11,
                 from /Applications/ArmGNUToolchain/15.2.rel1/arm-none-eabi/arm-none-eabi/include/errno.h:9,
                 from /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:17:
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:87:9: error: called object is not a function or function pointer
   87 |         assert(CLOCK_XOSC % freq == 0)
      |         ^~~~~~
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:88:30: error: 'TICKS_TIMER0_CTRL_ENABLE_BITS' undeclared (first use in this function); did you mean 'CLK_PERI_CTRL_ENABLE_BIT'?
   88 |         TICKS->TIMER0_CTRL = TICKS_TIMER0_CTRL_ENABLE_BITS;
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              CLK_PERI_CTRL_ENABLE_BIT
/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph/timer.c:92:30: error: 'TICKS_TIMER1_CTRL_ENABLE_BITS' undeclared (first use in this function); did you mean 'CLK_PERI_CTRL_ENABLE_BIT'?
   92 |         TICKS->TIMER1_CTRL = TICKS_TIMER1_CTRL_ENABLE_BITS;
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                              CLK_PERI_CTRL_ENABLE_BIT
make[4]: *** [/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/Makefile.base:162: /Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/examples/guides/timers/bin/rpi-pico-2-arm/periph/timer.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/Makefile.base:31: ALL--/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common/periph] Error 2
make[2]: *** [/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/Makefile.base:31: ALL--/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_common] Error 2
make[1]: *** [/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/Makefile.base:31: ALL--/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/cpu/rp2350_arm] Error 2
make: *** [/Users/basilfx/Desktop/Projecten/RIOT/RIOT_pr/examples/guides/timers/../../../Makefile.include:743: application_timers_example.module] Error 2

@AnnsAnns

AnnsAnns commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

ah yeah that came with the reviews I'll look into it, haven't compiled post review yet, ty for pointing that out

@crasbe crasbe added the State: waiting for author State: Action by the author of the PR is required label Jul 20, 2026
@AnnsAnns

AnnsAnns commented Jul 20, 2026 •

Copy link
Copy Markdown
Member Author

Fixed the compilation error, should work again.

Can't retest it because I accidentally took a pico without any pins with me .... and I also accidentally took a pico 1 and not a pico 2 with me 😢 But the underlying timer stuff shouldn't have changed so I'd be surprised if it stopped working

@AnnsAnns AnnsAnns removed the State: waiting for author State: Action by the author of the PR is required label Jul 20, 2026
@crasbe

crasbe commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

It seems like the timer only works immediately after flashing and not after a reset. This is tests/sys/ztimer_msg. The second part is after a reset and it never prints anything

2026-07-20 12:42:38,484 # Help: Press s to start test, r to print it is ready
s
2026-07-20 12:42:40,027 # START
2026-07-20 12:42:40,033 # main(): This is RIOT! (Version: 2026.07-devel-346-gf7d13-rp2350_timer)
2026-07-20 12:42:40,034 # This is thread 2
2026-07-20 12:42:40,036 # sending 1st msg
2026-07-20 12:42:40,039 # now=1:130958 -> every 2.0s: Hello World
2026-07-20 12:42:40,041 # sending 2nd msg
2026-07-20 12:42:40,044 # now=1:133304 -> every 5.0s: This is a Test
2026-07-20 12:42:40,046 # This is thread 3
2026-07-20 12:42:42,108 # sec=2 min=0 hour=0
2026-07-20 12:42:44,162 # now=3:132639 -> every 2.0s: Hello World
2026-07-20 12:42:44,169 # sec=3 min=0 hour=0
2026-07-20 12:42:46,231 # sec=4 min=0 hour=0
2026-07-20 12:42:48,286 # now=5:134292 -> every 2.0s: Hello World
2026-07-20 12:42:48,292 # sec=5 min=0 hour=0
2026-07-20 12:42:50,348 # now=6:135116 -> every 5.0s: This is a Test
2026-07-20 12:42:50,354 # sec=6 min=0 hour=0
2026-07-20 12:42:52,410 # now=7:135945 -> every 2.0s: Hello World
2026-07-20 12:42:52,416 # sec=7 min=0 hour=0
2026-07-20 12:42:54,478 # sec=8 min=0 hour=0
2026-07-20 12:42:56,534 # now=9:137597 -> every 2.0s: Hello World
2026-07-20 12:42:56,539 # sec=9 min=0 hour=0
2026-07-20 12:42:58,601 # sec=10 min=0 hour=0
2026-07-20 12:42:59,357 # Help: Press s to start test, r to print it is ready
s
2026-07-20 12:43:00,955 # START
2026-07-20 12:43:00,961 # main(): This is RIOT! (Version: 2026.07-devel-346-gf7d13-rp2350_timer)
2026-07-20 12:43:00,962 # This is thread 2
2026-07-20 12:43:00,963 # sending 1st msg
2026-07-20 12:43:00,966 # now=0:36652 -> every 2.0s: Hello World
2026-07-20 12:43:00,969 # sending 2nd msg
2026-07-20 12:43:00,972 # now=0:36760 -> every 5.0s: This is a Test
2026-07-20 12:43:00,972 # This is thread 3

Also the time is kinda wrong, the two seconds take four seconds and the five seconds take ten.

@crasbe

crasbe commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Unsurprisingly, the examples/guides/timer program is also too slow:

2026-07-20 12:44:32,983 # main(): This is RIOT! (Version: 2026.07-devel-346-gf7d13-rp2350_timer)
2026-07-20 12:44:38,427 # 3 seconds have passed!
2026-07-20 12:44:42,553 # 5 seconds have passed!

@crasbe crasbe added the State: waiting for author State: Action by the author of the PR is required label Aug 4, 2026
@AnnsAnns

Copy link
Copy Markdown
Member Author

Will look into this this week (hopefully) since this reconfirms my suspicion that I messed something up with the frequencies in my port

@AnnsAnns

Copy link
Copy Markdown
Member Author
2026-08-11 13:09:17,749 # sec=10 min=0 hour=0
2026-08-11 13:09:18,751 # sec=11 min=0 hour=0
2026-08-11 13:09:19,743 # now=12:170206 -> every 5.0s: This is a Test
2026-08-11 13:09:19,747 # now=12:175160 -> every 2.0s: Hello World
2026-08-11 13:09:19,753 # sec=12 min=0 hour=0
2026-08-11 13:09:20,754 # sec=13 min=0 hour=0
2026-08-11 13:09:21,751 # now=14:178658 -> every 2.0s: Hello World
2026-08-11 13:09:21,756 # sec=14 min=0 hour=0
2026-08-11 13:09:22,758 # sec=15 min=0 hour=0
2026-08-11 13:09:23,755 # now=16:182156 -> every 2.0s: Hello World
2026-08-11 13:09:23,759 # sec=16 min=0 hour=0
2026-08-11 13:09:24,747 # now=17:173966 -> every 5.0s: This is a Test
2026-08-11 13:09:24,761 # sec=17 min=0 hour=0
2026-08-11 13:09:25,758 # now=18:185654 -> every 2.0s: Hello World
2026-08-11 13:09:25,762 # sec=18 min=0 hour=0
2026-08-11 13:09:26,764 # sec=19 min=0 hour=0
2026-08-11 13:09:27,761 # now=20:189152 -> every 2.0s: Hello World
2026-08-11 13:09:27,766 # sec=20 min=0 hour=0
2026-08-11 13:09:28,768 # sec=21 min=0 hour=0

Appears to be correct now, in the process I realized that I added a lot of noise to the riscv irq when porting the pico2

Comment thread cpu/rp2350_common/periph/timer.c Outdated

if (timeout == 0) {
if (ctx_cb[dev]) {
ctx_cb[dev](ctx_arg[dev], channel);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wrong

@AnnsAnns AnnsAnns Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was copied 1:1 from the pico 1 implementation, why is this wrong?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From IRL conversation:

He is ragebaiting me 🥀 The relevant line in timer.h that explains what it was supposed to do was added in his PR 3 weeks ago, like other timers the pico1 did it incorrectly

#include "regs/resets.h"

/** Number of alarm channels per timer block */
#define TIMER_CHANNEL_NUMOF 4u

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Misses more defines

@AnnsAnns AnnsAnns Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added the isr macros the the pico1 also has (though I don't see them being used anywhere). I don't see any other defines required in the timer.h / pico1, either they are somewhere else where I'm not looking or I'm defining everything the pico1 is

@Teufelchen1

Copy link
Copy Markdown
Contributor

Appears to be correct now, in the process I realized that I added a lot of noise to the riscv irq when porting the pico2

Wait past me already did that but I can at least confirm that it does appear to be fixed fr

2026-10-16 13:45:50,799 # 3 seconds have passed!
2026-10-16 13:45:52,800 # 5 seconds have passed!
2026-10-16 13:45:55,802 # 3 seconds have passed!
2026-10-16 13:45:57,804 # 5 seconds have passed!
2026-10-16 13:46:00,806 # 3 seconds have passed!
2026-10-16 13:46:02,808 # 5 seconds have passed!
2026-10-16 13:46:05,810 # 3 seconds have passed!
2026-10-16 13:46:07,812 # 5 seconds have passed!
2026-10-16 13:46:10,814 # 3 seconds have passed!
2026-10-16 13:46:12,816 # 5 seconds have passed!
2026-10-16 13:46:15,817 # 3 seconds have passed!
2026-10-16 13:46:17,820 # 5 seconds have passed!
2026-10-16 13:46:20,821 # 3 seconds have passed!

That output looks very wrong

@kfessel

kfessel commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

That output looks very wrong

from examples/guides/timers/main.c

int main(void)
{
    /* Create a timer */
    ztimer_t timer = { .callback = timer_callback,
                       .arg = "3 seconds have passed!" };

    /* Set the timer to fire in 3 seconds */
    ztimer_set(ZTIMER_SEC, &timer, 3);

    /* Sleep for 5 seconds */
    ztimer_sleep(ZTIMER_SEC, 5);

    puts("5 seconds have passed!");

    return 0;
}

more like mildly wrong

main seem to be restarting and has no message when it sets a timer

I suggest adding a message at the beginning of main()

@AnnsAnns

Copy link
Copy Markdown
Member Author

That output looks very wrong

What karl said but I agree that without context the prints look confusing

Comment thread cpu/common/rp2350/include/timer_conf.h Resolved
@AnnsAnns

Copy link
Copy Markdown
Member Author
image

Updated according to new timer.h comments

@AnnsAnns

Copy link
Copy Markdown
Member Author
image

@AnnsAnns

Copy link
Copy Markdown
Member Author
image also works

@crasbe

crasbe commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

This needs a rebase after the cpu/common PR #22983 👀

@crasbe

crasbe commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Perhaps you can wait a bit longer, I have a PR coming up that fixes the incorrect CORE_CPUCLOCK as well as the wrong clock base for TIMER0/1.

@AnnsAnns

Copy link
Copy Markdown
Member Author

Perhaps you can wait a bit longer, I have a PR coming up that fixes the incorrect CORE_CPUCLOCK as well as the wrong clock base for TIMER0/1.

Oops, my github was still on the previous comment 🙈

Comment thread cpu/common/rp2350/periph/timer.c Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Co-Authored PR/Issue relies on AI. Documentation / Code was partly generated by AI. Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants