Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PICos18 RTOS issue with 18F4520

Status
Not open for further replies.

divakar.raj

Newbie level 2
Joined
Aug 11, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,347
Hi all, I have worked on various peripherals of PIC18F4520 microcontroller, but I am new to RTOS. To begin with, I am trying with "PICos18".

I followed the exact instruction given in the below link, to create two tasks. One tasks to turn ON an LED and the other task to blink another LED:
https://softelec.pagesperso-orange....utorial/Projects_RTOS_PICOS18_tutorial_us.htm

I have downloaded the PICos18 source from:
https://softelec.pagesperso-orange.fr/Projects/RTOS/PICOS18/PICOS18_v1_11.zip

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)

Thanks,
Divakar Raj R
 

hi

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
 

Hi.

Thanks for your time and reply.

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]

TASK(Led_blinking)
{
if (done == 0)
{
PORTEbits.RE1 = 1;
done = 1;
}
else
{
PORTEbits.RE1 = 0;
done = 0;
}

TerminateTask();

I am new to RTOS and I am kinda more curious in resolving it. Looking for your inputs.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top