Closed luiswirth closed 2 years ago
It seems to work for me - at least, the LED starts blinking. However, it blinks irregularly, so I'm not sure if everything is working as intended.
To make sure there is no difference in dependencies etc., I set up a git repo with a full binary crate at https://github.com/jannic/rp-hal-issue-287-test
All I need to do to get the LED blinking is calling cargo run
(with an rp pico connected via hs-probe, but should work with other probes the same way).
I cloned your repo and tested it using a picoprobe. I don't get any blinking (neither in debug nor release). The LED just stays on.
Found the reason for the irregular timing. When the alarm fires, there are two different things that could happen:
Because the loop is inside a critical section most of the time, these two cases happen with similar probabilities, leading to the strange irregular blinking.
While not really a solution, adding cortex_m::asm::delay(10000);
at the beginning of the loop
(but outside the critical section!) completely changes the timing, so the interrupt fires during that delay most of the times, and executes immediately.
BTW, line 104 is not necessary, the interrupt is already enabled since line 77.
I cloned your repo and tested it using a picoprobe. I don't get any blinking (neither in debug nor release). The LED just stays on.
Strange. For me, it also works when flashing the uf2 file (using bootsel mode, without a debug probe).
I got it working, with and without the delay!
For some reason loading from gdb and directly from openocd makes a difference... With gdb it's somehow broken. Maybe it prevents interrupts?
This seems to be gdb related and unrelated to rp-rs. Feel free to close.
What do you think of adding this or a similar interrupt_blinky
example to the code base?
Great that it works!
Not sure about gdb, I can't imagine it completely prevents interrupts, but of course it may cause some subtle differences. I don't know much about gdb and openocd, so I probably can't help with that.
Also, not sure about such an example. There are already some interrupt examples in boards/rp-pico/examples/
, and pico_rtic.rs
is covering timer interrupts. That's together with RTIC, but we can't cover every combination of features with a separate example, I guess.
(BTW, I don't have the rights necessary to close the issue. I guess you can do it yourself, as you created it.)
Oh I didn't know about these examples! I only looked at the rp2040-hal
examples. Thanks for letting me know and helping.
I'm trying to get interrupts working in my application, but I wasn't able to do so.
I tried to create a minimal setup and I'm not sure what's wrong.
My pico doesn't blink and the main "thread" execution gets stuck on
pac::NVIC::unmask(pac::Interrupt::TIMER_IRQ_0);