EasyManua.ls Logo

Texas Instruments MSP430

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
155
The variable task in the main loop is used to switch between different tasks, each task having same
time frame and priority. This is called a task scheduling.
switch(task)
{
case 1:
{
switch(i)
{
case 0:
{
P1OUT &= ~BIT0;
break;
}
default:
{
P1OUT |= BIT0;
break;
}
}
break;
}
case 2:
{
_delay_cycles(1);
s++;
if(s > 20000)
{
P1OUT ^= BIT6;
s = 0;
}
break;
}
default:
{
if((P1IN & BIT3) != BIT3)
{
i ^= BIT0;
}
break;
}
}
Task 1 lights P1.0 LED based on the logic state of the user button. Task 0 checks the state of the user
button. Task 2 blinks P1.6 LED independent of the other tasks. The total time for the completion of all
these processes is about 1.5 milliseconds a very short time. In this method, no task waits for other
tasks. The whole process is so fast to human eyes that everything this code does will appear to occur
parallelly.

Table of Contents

Other manuals for Texas Instruments MSP430

Related product manuals