Pumpkin, Inc.

Pumpkin User Forums

OS_Yield and OS_Delay

If you can't make Salvo do what you want it to do, post it here.

OS_Yield and OS_Delay

Postby 1064453 » Wed Aug 02, 2006 10:05 am

hi AEK:

Can I have OS_Yield and OS_delay
in a same task definition?
TQ.

code:
void TaskRotate(void)
{ if (INTF == 0)
{
RB1 = 1;
for(;;)
OS_Yield(TaskRotate1);
}
else if (INTF == 1)
{
for(;;)
OS_Delay(50,TaskRotate1);
}
}

You can have as many OS_Xyz()'s in a task as you like.

But the code above won't work -- you'll be stuck in infinite loops. Use

code:
void TaskRotate(void)
{
for (;;)
{
if (INTF == 0)
{
RB1 = 1;
OS_Yield(TaskRotate1);
}
else if (INTF == 1)
{
OS_Delay(50,TaskRotate1);
}
}
}

Even this code is junk, however, because you're polling the INTF flag. Write an ISR instead that triggers a task via OSSignalXyz().

-

[This message has been edited by aek (edited August 03, 2006).]

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: OS_Yield and OS_Delay

Postby aek » Thu Aug 03, 2006 12:35 am

Oops, sorry, I edited you post after fixing the code. So my comments are interspersed with your original post ...
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: OS_Yield and OS_Delay

Postby 1064453 » Mon Aug 07, 2006 8:19 am


Hi AEK:

When I make the code below, I
got the error message
"Error[845] C:MCprojectWork6main.c
14 : multiply defined
symbol "_TaskRotate1"
Please advice.
TQ.

code:
#include <salvo.h>
#define BS_INTF OSECBP(1)


_OSLabel(TaskRotate1)

void TaskRotate(void)
{

RB1=1;
for(; ;)
{
OS_WaitBinSem(BS_INTF,OSNO_TIMEOUT,TaskRotate1);
OS_Delay(1000,TaskRotate1);
INTF=0;
RB1=1;

}


}


void main(void)
{

OSInit();
TRISB = 0b00000001;
RBPU =0;
GIE =1;
INTE =1;
INTEDG =0;

OSCreateTask(TaskRotate,OSTCBP(1),1);
OSEi();
for (; ;)
OSSched();
}


#include <salvo.h>
#define TMR0_RELOAD 156
#define BS_INTF OSECBP(1)
void interrupt IntVector(void)
{

if(INTF == 1)
{
RB1=0;
OSSignalBinSem(BS_INTF);
}


if (T0IE && T0IF)
{
T0IF =0;
TMR0 -= TMR0_RELOAD;
OSTimer();
}

}



--

[This message has been edited by aek (edited August 07, 2006).]

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: OS_Yield and OS_Delay

Postby aek » Mon Aug 07, 2006 10:55 am

Is this one file?

If so, do not #include <salvo.h> twice ...

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: OS_Yield and OS_Delay

Postby 1064453 » Thu Aug 10, 2006 11:10 am

Hi AEK:

IT is two separate file
main.c and isr.c


quote:
Originally posted by aek:
Is this one file?

If so, do not #include <salvo.h> twice ...


1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: OS_Yield and OS_Delay

Postby 1064453 » Fri Aug 11, 2006 11:13 am

quote:
Originally posted by aek:
Is this one file?

If so, do not #include <salvo.h> twice ...



-------------------------------------------

void Task_Trigger(void)
{
for(;
{
if (RB0 == 0)
{
OSSignalMsg(MSG_Trigger,(OStypeMsgP) &CodeA);
OS_Yield(Task_Trigger1);
}
else if (RB1 == 0)
{

OSSignalMsg(MSG_Trigger,(OStypeMsgP) &CodeB);
OS_Yield(Task_Trigger1);
}

}

}


I got error message Error[845] C:MCproject8CCPmain.c 28 : multiply defined symbol "_Task_Trigger1"
Please advice.

-

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: OS_Yield and OS_Delay

Postby 1064453 » Fri Aug 11, 2006 11:26 am


I have figured out, need
to use

_OSLabel(TaskOne1) and
_OSLabel(TaskOne2)

for OSCreateTask(TaskOne,1,1)

withing the same { }.
If not, you will get multiple defintion
error.

--

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron