A task (even the highest priority one) "blocks" if it blocks in a call to a Delay operation, or waits on a semaphore or queue.
Typically, most tasks will have some operation in their loop which blocks, while they wait for the next time they should do more work. The only exception will be lowest priority tasks which intend to use any remaining time doing something. (They need to be lowest as any task lower won't get time).
I can see that pxCurrentTCB corresponds to my second task, but it never starts its execution. It is stuck on portYield method that Timer Interrupt executes. To be more specific "return" of portYield macro jumps again and again to the instruction just after "call _vTaskSwitchContext" on file portASM_PIC24.S
That sounds like something has corrupted your system. Some likely causes:
Stack overrun
Interrupts using not FromISR APIs (or non-interrupts using a FromISR API incorrectly)
Interrupts with wrong priorities
Also, as a side note, using vTaskSuspend this way is a bit unusual, and I find I use vTaskSuspend only in very unusual cases. Normally a task is waiting for SOMETHING, either time (so you use a vTaskDelay or vTaskDelayUntil) or is waiting for some data (so you get data from a Queue) or it is waiting to be signaled via a semaphore. These tend to be more reliable than using Suspend and Resume,
Thanks again...actually I tried with the method you mentioned to introduce delays first, but I got same issue.
Where did you get your PIC24 project from?
How did you put your PIC24 project together?
Have you tried building and running the official demo application for the PIC24 that comes in the FreeRTOS zip file download?
Do you have stack overflow detection turned on?
Did you start with something very simple to get confidence that you had integrated the code correctly? I would suggest starting by turning
pre-emption off, then creating two tasks that do nothing but yield to each other. For example you can start with
just the following two tasks:
volatile unsigned long ul1, ul2;
void vTask1( void *pvParameters )
{
for( ;; )
{
ul1++;
taskYIELD();
}
}
void vTask2( void *pvParameters )
{
for( ;; )
{
ul2++;
taskYIELD();
}
}
Create these two tasks using:
portBASE_TYPE xTaskCreate(
vTask1,
"T1",
configMINIMAL_STACK_SIZE,
NULL,
1,
NULL;
);
portBASE_TYPE xTaskCreate(
vTask2,
"T2",
configMINIMAL_STACK_SIZE,
NULL,
1,
NULL;
);
Start the scheduler, let it run for a while (you may be able to do that in the MPLAB simulator), then pause the debugger. Now if you inspect the ul1 and ul2 variables they should have approximately the same value. Next if you inspect xTickCount (defined in tasks.c) you should find it has incremented.
If that works, then it shows you can yield from one task to another, then you can turn preemption on and take out the calls to taskYIELD() and try it again.....
[you may also benefit from reading one of the tutorial books]
Regards.