You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there's a logic error in here, which means TIMER1 doesn't work as expected.
Looking at this snippet:
staticvoidhardware_alarm_irq_handler(void) {
// Determine which timer this IRQ is foruintalarm_num=TIMER_ALARM_NUM_FROM_IRQ(__get_current_exception() -VTABLE_FIRST_IRQ);
check_hardware_alarm_num_param(alarm_num);
uinttimer_num=TIMER_NUM_FROM_IRQ(alarm_num);
alarm_num is always a value 0-3. This is then used as the IRQ number on line 150:
i.e. it calculates irq_num and uses that as part of TIMER_NUM_FROM_IRQ(irq_num).
If I rewrite this with the following snippet, my tests pass as expected:
voidhardware_alarm_irq_handler(void*data) {
// Determine which timer this IRQ is foruintirq_num=__get_current_exception() -VTABLE_FIRST_IRQ; // Create new intermediate variable.uintalarm_num=TIMER_ALARM_NUM_FROM_IRQ(irq_num); // Use here (behaviour unchanged).check_hardware_alarm_num_param(alarm_num);
uinttimer_num=TIMER_NUM_FROM_IRQ(irq_num); // And here, correcting the issue.timer_hw_t*timer=timer_get_instance(timer_num);
hardware_alarm_callback_tcallback=NULL;
This seems to affect both the 2.0 and current HEAD of the develop branch.
Correct the logic for determining `timer_num`. Previously this would
always evaluate to 0 due to using `alarm_num` instead of `irq_num`.
Fixesraspberrypi#1948.
I think there's a logic error in here, which means
TIMER1
doesn't work as expected.Looking at this snippet:
alarm_num
is always a value 0-3. This is then used as the IRQ number on line 150:which is fine when using
TIMER0
, but won't work withTIMER1
, becausealarm_num
is being used instead ofirq_num
. In contrast, https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/pico_time_adapter/include/pico/time_adapter.h#L31-L36 seems to do the correct thing:i.e. it calculates
irq_num
and uses that as part ofTIMER_NUM_FROM_IRQ(irq_num)
.If I rewrite this with the following snippet, my tests pass as expected:
This seems to affect both the 2.0 and current
HEAD
of thedevelop
branch.Found as part of work on zephyrproject-rtos/zephyr#77368
The text was updated successfully, but these errors were encountered: