Page 1 of 1

PC and Methods

PostPosted: Thu Apr 02, 2009 8:25 am
by brodie677
Hi,

I'm still trying to get a feel for how Salvo works, and have a few questions regarding how the stack is manipulated. If the following code were to run on an 8 bit PIC other than the PIC18, how does the PC value get saved so that after TaskA executes the call OS_Yield(), it returns to the next intruction which is a call to another method myFunction(). I'm just really curious as to how the PC value is saved with those models of the PIC's. Also another question that stemmed from this situation, will the call to myFuction() end in a disaster? Also would code like this be supported with the PIC24 devices and the C30 compiler?

void myFunction(void)
{
OS_Yield();
}

void TaskA( void )
{
while (1)
{
OS_Yield();
myFunction();
}
}


Re: PC and Methods

PostPosted: Thu Apr 02, 2009 9:03 am
by aek
Salvo's internals are laid bare at the assembly level -- all you have to do is build a project, and trace through the assembly (e.g. in MPLAB's sim) to see how it's done.

Salvo application code is _identical_ for every target supported. So what works for PIC18 also works for PIC24, PIC32, MSP430, ARM7, ... at the user level, in C. Underneath, of course, the code can be quite different.

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


Re: PC and Methods

PostPosted: Sun Apr 05, 2009 5:11 am
by Phil W
Besides, what you are trying to do in salvo is illegal. You cannot perform a context switching action in a function called from a task. You must be at task level before doing so.

PhilW