Issue:
But when I try to run the above built hex file on a PIC18F4520 board, the blinking task (task2) executes only for 4 times successfully. After that the task2 stops executing.
When i debug using breakpoints, at the kernel.asm, the control moves into "No task in RUNNING state" mode, i.e., it continously moves into the label "_while" at kernel.asm. This doesnt happen during the first four times. It blinks properly for the first four times.
Can someone direct me where I am going wrong.
Note: I use Microchip-C18 compiler to build the source (as instructed at the link)
checked with link you provided for the code, in your code check this part. I think when 4 times its executed its setting one event . one counter is there its getting ++ when reaches 4 its setting one event , other task who is waiting for that event i.e. TASK(Led_event) is then getting executed but some how its not returning to previous task.that previous task is getting terminated.
as per first view whatever code available on link , I am not able to open .zip file
Code:
TASK(Led_blinking)
{
if (done == 0)
{
PORTEbits.RE1 = 1;
done = 1;
}
else
{
PORTEbits.RE1 = 0;
done = 0;
}
counter++;
if (counter == 4)
{
SetEvent(LEDEVENT, LED_EVENT); // here event getting set check if using breakpint if TASK(Led_event) is getting executed
counter = 0;
}
TerminateTask();
}
I will suggest you to put breakpoint in TASK(Led_event) and check from there where its going
Unfortunately the zip file didnt open up at your end. To brief about the zip file, it has only the first task defined in it. As explained in the link, it is left with the user to create the second task and third task and so on (based on the instructions). The third task is TASK(Led_event). This task is executed through an event LED_EVENT, which is set from the second task TASK(Led_blinking), based on 4 blinking counts.
But in my above posted attempt, I have only created second task (addition to existing first task at the zip code). Since there is no third task (TASK(Led_event)), I have not implemented the 'counter' variable at first hand. Hence no setting a new event (LED_EVENT).
In simple, the first tasks turns ON an LED. The second task, TASK(Led_blinking), blinks another LED (continuously). But it doesn't do it continuously. It does it for first four times. Fifth time... it was well before the blinking delay time the tasks is called, and the control goes in to 'NO TASK is ACTIVE' mode permanently. [This is what I infer as I debugged]