-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the bug
I have posted this on https://forums.freertos.org/t/rp2040-freertos-smp-and-timer-isr/15297 , however, as I have not had any responses, I suspect it might not be a trivial issue, and therefore possibly a bug.
Example RP2040 code has only a single task, and a timer ISR, is compiled against FreeRTOS SMP branch, and it is here: https://gist.github.com/sdbbs/b1410cd45106e0c0ee599f7fcdbb8f90/48e79e193537a9346682b014ffd50d34c940cc1b
Depending on how the timer ISR is initialized, and whether CPU core affinity is set for the task, there are four different behaviors I observe, and only one of them works as expected (behavior D):
(A) | //#define USE_HARDWARE_ALARM_API |
vTaskCoreAffinitySet (xLedTaskHandle, 0b10); |
led_task inits and stops, timer ISR runs for some ms, then stops | |
(B) | #define USE_HARDWARE_ALARM_API |
vTaskCoreAffinitySet (xLedTaskHandle, 0b10); |
led_task inits and stops, timer ISR runs continuously | |
(C) | #define USE_HARDWARE_ALARM_API |
//vTaskCoreAffinitySet (xLedTaskHandle, 0b10); |
led_task runs continuously, timer ISR never starts | |
(D) | //#define USE_HARDWARE_ALARM_API |
//vTaskCoreAffinitySet (xLedTaskHandle, 0b10); |
both led_task runs continuously, and timer ISR runs continuously |
(I have also screenshots for these cases in the forum post)
I am puzzled as to why using vTaskCoreAffinitySet
would cause tasks or timers to stop working.
Target
- Development board: Raspberry Pi Pico (RP2040)
- Instruction Set Architecture: Cortex M0+
- IDE and version: none
- Toolchain and version: MINGW64 arm-none-eabi-gcc.exe (GCC) 10.1.0
Host
- Host OS: Windows
- Version: Windows 10
To Reproduce
- Use project https://gist.github.com/sdbbs/b1410cd45106e0c0ee599f7fcdbb8f90/48e79e193537a9346682b014ffd50d34c940cc1b ; only other files that are required but not in the gist are the standard
pico_sdk_import.cmake
andFreeRTOS_Kernel_import.cmake
- Make changes as in the table, recompile, run on Raspberry Pi Pico, and observe the behaviors on the debug pins with an oscilloscope/logic analyzer
Expected behavior
I expected both the task and the timer ISR to run in parallel continuously, without stopping, regardless of which commands I use to set up the timer, or whether I use vTaskCoreAffinitySet to pin the task on CPU core 1.
Screenshots
Screenshots are available in the forum post
Additional context