-
Notifications
You must be signed in to change notification settings - Fork 971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trouble with Timer High Level APIs #2140
Comments
Sorry, I can't seem to reproduce the problem. I see the printf with or without the sleep. Are you using stdio usb or stdio uart (what pico_enable_stdio_* lines do you have in your cmake file)?
It's safe, although it's somewhat unwise. Adding an alarm at a specific time with add_alarm_at is a bit dangerous as it might be in the past? I would suggest adding a hard_assert that it's returning >0. And/or use add_alarm_in_ms instead. |
Also, you might want to look at https://www.raspberrypi.com/documentation/pico-sdk/high_level.html#group_repeating_timer rather than repeatedly setting new alarms in your alarm-callback? |
Also worth trying the develop branch to pick up this fix 969f589 |
I'm using:
I know this api, but I need to change the period between an activation and the next one. I know I can even use other peripherals, but now I'm just playing with this API. I have a smaller piece of code that gives me problem:
It prints:
It seems the timer doesn't count untill sleep_ms(). The CMakeList:
|
I'm new about Pico SDK, so I'm just experimenting the APIs... I don't understand why this piece of code doesn't print
triggered
, unless I decommentsleep_ms(1)
. It seems the interrupt never triggers.Reading the docs, the alarm_callback runs in IRQ context, so I don't need to insert sleep_ms(1). Moreover, in the example, in the alarm_callback there is a
printf
... Is it safe calling a printf in an IRQ routine?If I'm missing something, let me know please.
I'm using RP2350 and SDK v2.1.0.
The text was updated successfully, but these errors were encountered: