I’ve struggling with priorities in FreeRTOS. After some research I found that a program with a single task with priority other than 0 (the lowest), does not run! For example:
xTaskCreateStatic( plc_kernel_task, ( const portCHAR* ) "PLC", TASK_PLC_KERNEL_STACK_SIZE, NULL, 1, plc_kernel_task_ram, &plc_kernel_task_tcb );
(with: #define configMAX_PRIORITIES 3)
will not run. But if I change its priority to 0, then it runs smoothly.
It gets worst. If I have two tasks, TA and TB, where TA has a priority greater than TB (say (configMAX_PRIORITIES-1) vs tskIDLE_PRIORITY, respectively) neither task run. However, if I swap their priorities ( tskIDLE_PRIORITY vs configMAX_PRIORITIES-1) then both tasks run. TA is the master, and TB is the slave (from a binary semaphore point of view).
It sounds crazy but that’s the problem I’m facing it. Maybe I’m missing something. Any ideas? I could reduce the problem to the one I mentioned, so for the moment ignore the problem with two tasks.
Is there a problem with priorities?
I’m coding my program for the Arduino UNO (ATmega328 port) board on Linux, so I can’t debug (GDB) the program from inside. I’m not using sketches, instead I’m using Arduino-Makefile.
Thanks in advanced!