Friends,
I have this code running in a FreeRTOS task:
If I start the task on core 0, I receive the interrupts just fine:
If I start the task on core 1, I do not receive the interrupts.
The only difference between these two runs is which core the button task runs on:
This works, and replacing the affinity mask with 0b10 (run on core 1) gives the non-working behavior.
I am curious why this would be. I have looked at the rp2040 datasheet and I was given to understand that the gpio interrupts would be sent on whichever core they were bound on. That seems to be the intent of the code in gpio_set_irq_enabled. But that does not seem to be happening.
If you're interested in trying the code for yourself, here's the project:
https://github.com/jaguilar/awning/blob ... /awning.cc
To get the behavior I showed above, disable the radio task and just use the button task, and add printfs where appropriate.
If it's not immediately obvious what's happening, I'm happy to prepare a more brief testcase.
I have this code running in a FreeRTOS task:
Code:
static TaskHandle_t task_handle = xTaskGetCurrentTaskHandle(); printf("%p\n", task_handle); gpio_set_irq_callback(+[](uint gpio, uint32_t event_mask) { BaseType_t higher_priority_task_woken = pdFALSE; vTaskNotifyGiveFromISR(task_handle, &higher_priority_task_woken); portYIELD_FROM_ISR(higher_priority_task_woken); }); gpio_set_irq_enabled(kPinButtonDn, GPIO_IRQ_EDGE_FALL, true); gpio_set_irq_enabled(kPinButtonUp, GPIO_IRQ_EDGE_FALL, true); gpio_set_irq_enabled(kPinButtonMy, GPIO_IRQ_EDGE_FALL, true); while (true) { while (xTaskNotifyWait(0b1, 0b1, nullptr, pdMS_TO_TICKS(1000)) != pdPASS) { printf("timeout %hhu\n", GetPressedButtons()); }
Code:
will initialize wifiwifi init donetimeout 0dn # button presses detected on interruptupmytimeout 0
Code:
will initialize wifiwifi init donetimeout 0timeout 4 # buttons are seen pressed during the timeout, but no interrupttimeout 1timeout 2timeout 0
Code:
xTaskCreateAffinitySet( button_task, "button_task", 512, nullptr, 1, 0b01, nullptr);
I am curious why this would be. I have looked at the rp2040 datasheet and I was given to understand that the gpio interrupts would be sent on whichever core they were bound on. That seems to be the intent of the code in gpio_set_irq_enabled. But that does not seem to be happening.
If you're interested in trying the code for yourself, here's the project:
https://github.com/jaguilar/awning/blob ... /awning.cc
To get the behavior I showed above, disable the radio task and just use the button task, and add printfs where appropriate.
If it's not immediately obvious what's happening, I'm happy to prepare a more brief testcase.
Statistics: Posted by jags84 — Tue May 07, 2024 2:55 am