add_repeating_timer_us only works with some values of delay_us #737
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#737
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
add_repeating_timer_us(-50, isr, NULL, &timer);is fine, butadd_repeating_timer_us(-51, isr, NULL, &timer);will hang the pico.A workaround is to call add_repeating_timer with a working delay value, and write the wanted value to the timer struct.
timer.delay_us = -51I'm not sure if this is mentioned in the C++ SDK documentation, but I could not find any mention of this.
"hang the pico" really? in what way?
a small example showing the problem would help (it probably matters what your callback is doing)
it might be that my sdk is not entirely up to date, but for me it will stop running the code when it hits add_repeating_timer_us with some delays
main.cpp:
CMakeLists.txt:
the LED will not blink if timer_delay is -51, but it will if its -50.
Same issue here.
is the issue only with negative numbers?
negative numbers means that there may be no pause between callbacks (if the number is too close to zero) and if there is no pause then you will appear to hang. it doesn't make a lot of sense that -51 would not work and -50 would, however there are a number of possible factors at play especially if you are running from (cold) flash.
I have a similar issue: for me it seams like it doesn't work for values smaller than X.
On one RP2040 it didn't work for times shorter than -107uS. On another I had issues while debugging around 84/85uS.
If it did not work it always ended up in a breakpoint, highlighted by the debugger in:
pico-sdk/src/rp2_common/pico_runtime/runtime.cline 186More information in the comments of my code:
I think I might have found a workaround. I am hitting a similar-looking bug where timers on the default pool stop firing if the main program does a short usleep at an unfortunate time. I have modified the code near here like this:
This resolves the problem for me - timers do not mysteriously stop firing anymore. However, I'm not sure that this is a correct solution and I'm not sure that this is the same bug. Does the workaround work for anyone else?
This patch from @JakubVanek worked for my issue where the timer would stop working for 2^32us and then come back on the rollaround. I am assuming that this was also because of other users of the default alarm pool ( but wasnt proven)
Thanks @JakubVanek!