Jump to content
tonyp12

tiny msp430 preemptive multitasking system

Recommended Posts

Yes, thanks @zeke.

But, I don’t see how the following statement works. After the equal sign, shouldn’t be there the address of some variable, e.g. the address of SP register in this case? How does casting (int*) help?

int* multistack = (int*) __get_SP_register();

And any idea why the comma after "task3" is there in the below statement? I noticed it makes "tasks" variable to be 4 and enable the while(i<tasks-1) loop to iterate 3 times. But it must have some other role, right? If not, why not write while(i<tasks) instead?

funcpnt const taskpnt[]={ task1, task2, task3,  // <- PUT YOUR TASKS HERE
}; 

Cheers..

Share this post


Link to post
Share on other sites

We have to unpack all that is going on in that get stack pointer statement.

The function getstackpointer() returns a value. The (int*) transforms that into “the address of that return value” which will be 16 bits large. Then that 16 bit address is assigned to the multi stack variable. 

 

The author is asking us to modify the list of function names in the taskpnt function since (s)he doesn’t know what we will be doing. So that is up to us. 

So task1, task2, and so on, are functions that we write to do one specific thing. Something atomic, like SwitchOnLED(LED1) or SwitchGPIO(P1-7), etc.  

Does that make sense?

Share this post


Link to post
Share on other sites

Okay, let me put it this way. The author seems to have 3 tasks, but he loops the while(i<tasks-1){...} loop only 2 times due to 'i<tasks-1' statement. My question is that is there any purpose of doing this? What happened to the remaining task? 

And, another question: why are we saving Global Interrupt Enable bit on The Stack? Where are we using it again later?

Thanks. 

Share this post


Link to post
Share on other sites

There are 3 tasks in array, and index starts with 0, so counting from 0 to 2, and all three tasks running.

   int i = 0; while (i <tasks -1) {

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...