rtos lab report

8
RTOS LAB REPORT First step: Loading the project on the Coldfire board. 1. How many tasks are usable in this application? #define OS_MAX_TASKS 10u /* Max. number of tasks in your application, MUST be >= 2 */ So it’s 10 tasks. 2. What timer is used for ticks generating? PIT0 3. How much is the timer work frequency? How much is the tick duration? Verify the coherency between the two values. OS_TICKS_PER_SEC 100u 4. Lines of Code added: MCF_PIT0_PMR = 30000; MCF_PIT0_PCSR=(MCF_PIT_PCSR_EN|MCF_PIT_PCSR_RLD|MCF_PIT_PCSR_PIF|MCF_PIT_PC SR_PIE|MCF_PIT_PCSR_PRE(3)); MCF_PIT0_PCSR&=~ (MCF_PIT_PCSR_OVW|MCF_ PIT_PCSR_DBG|MCF_PIT_PCSR_DOZE); 5. Put a breakpoint in My_Task1() on the var++ line; Run several time, wha t do you see ? The breakpoint is reached every second in the given program so the program runs fine until the breakpoint is reached. We c an see the value at the breakpoint. 6. The following code was added in the program to get the hyperlink network : INT8U retval; uart_init( 0, 48000,19200); uart_outstring(0,"Bonjour "); 7. The code for the counter is : int X; char buffer1[20]; X = sprintf(buffer1, "\r Count is %d", var); uart_outstring(0,buffer1); 8. To kill the ticks, the code was changed as follows : MCF_PIT0_PCSR|=(MCF_PIT_PCS R_EN|MCF_PIT_PCSR_RLD|MCF _PIT_PCSR_PIF|MCF_PIT_P CSR_PRE(3));

Upload: gokul-gopakumar

Post on 04-Apr-2018

226 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 1/8

RTOS LAB REPORT

First step: Loading the project on the Coldfire board.

1.  How many tasks are usable in this application?

#define OS_MAX_TASKS 10u /* Max. number of tasks in your application, MUST be

>= 2 */

So it’s 10 tasks. 

2.  What timer is used for ticks generating?

PIT0

3.  How much is the timer work frequency? How much is the tick duration? Verify the coherency

between the two values.

OS_TICKS_PER_SEC 100u

4.  Lines of Code added:

MCF_PIT0_PMR = 30000;

MCF_PIT0_PCSR=(MCF_PIT_PCSR_EN|MCF_PIT_PCSR_RLD|MCF_PIT_PCSR_PIF|MCF_PIT_PC

SR_PIE|MCF_PIT_PCSR_PRE(3));

MCF_PIT0_PCSR&=~ (MCF_PIT_PCSR_OVW|MCF_PIT_PCSR_DBG|MCF_PIT_PCSR_DOZE);

5.  Put a breakpoint in My_Task1() on the var++ line; Run several time, what do you see ?

The breakpoint is reached every second in the given program so the program runs fine until

the breakpoint is reached. We can see the value at the breakpoint.

6.  The following code was added in the program to get the hyperlink network :

INT8U retval;

uart_init( 0, 48000,19200);

uart_outstring(0,"Bonjour ");

7.  The code for the counter is :

int X;

char buffer1[20];

X = sprintf(buffer1, "\r Count is %d", var);

uart_outstring(0,buffer1);

8.  To kill the ticks, the code was changed as follows :

MCF_PIT0_PCSR|=(MCF_PIT_PCSR_EN|MCF_PIT_PCSR_RLD|MCF_PIT_PCSR_PIF|MCF_PIT_PCSR_PRE(3));

Page 2: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 2/8

MCF_PIT0_PCSR&=~(MCF_PIT_PCSR_OVW|MCF_PIT_PCSR_DBG|MCF_PIT_PCSR_DOZE|MCF

 _PIT_PCSR_PIE);

At first, the scheduler tries to find the next highest priority task ready to run but finds none

as the only task (MyTask1()) is blocked by the OSTimeDlyHMSM(). Later the scheduler ends

up calling the idle task which calls the Idle Hook indefinitely in an endless loop.

9.  In order to calculate the context switching time, following changes were made in the

program:

MCF_GPIO_PORTTC |= 0x02;

Was added in myTask1() before the Dly function. All the other tasks were suppressed. In the

Idle Hook function the following line was uncommented:

MCF_GPIO_PORTTC &=~ 0x02;

Then using logicport the context switching time was calculated. It came out to be 11.62µs

Second step: Project modification on the Coldfire board.

1.  Modify the program to blink the PTA0 led of the Coldfire in place of increase a variable.

static void myTask1(void *pdata) {

INT8U retval;

pdata=pdata; /* dummy usage to avoid compiler warning */

while (TRUE) /* Task body, ALWAYS written as an infinite loop */

{

// MCF_GPIO_PORTTC |= 0x02;retval=OSTimeDlyHMSM(0,0,2,0); /* Delay for hr,min,sec,ms */

Page 3: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 3/8

Page 4: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 4/8

int i;

uart_init( 0, 48000,19200);

pdata=pdata; /* dummy usage to avoid compiler warning */

while (TRUE) /* Task body, ALWAYS written as an infinite loop */

{ ch='a';

MCF_GPIO_PORTTA ^= 0x04;

for(i=0;i<20;i++)

{

uart_putchar(0,ch);

ch++;

uart_putchar(0,' ');

}

OSTimeDly(20);

var++;

} /* end while */

}

Page 5: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 5/8

 

4.  Change the transmit baudrate in the UART initialization as in the Hyperterminal

connexion for working at 110 bauds. Launch the application. What happens? Why?

The transmission rate is very slow so we get jargon.

Page 6: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 6/8

5.  The program code was changed as follows:

static void myTask2(void *pdata) {

INT8U retval;

uart_init( 0, 48000,19200);

pdata=pdata; /* dummy usage to avoid compiler warning */

while (TRUE) /* Task body, ALWAYS written as an infinite loop */

{

uart_outstring(0,"This is String 1 ");

retval=OSTimeDlyHMSM(0,0,1,0); /* Delay for hr,min,sec,ms */

uart_outstring(0,"This is String 2 ");

retval=OSTimeDlyHMSM(0,0,1,0);MCF_GPIO_PORTTA ^= 0x02;

} /* end while */

}

static void myTask3(void *pdata)

{

INT8U retval;

uart_init( 0, 48000,19200);

pdata=pdata; /* dummy usage to avoid compiler warning */

while (TRUE) /* Task body, ALWAYS written as an infinite loop */

{

MCF_GPIO_PORTTA ^= 0x04;

uart_outstring(0,"This is String 3 ");

retval=OSTimeDlyHMSM(0,0,1,0);

uart_outstring(0,"This is String 4 ");

retval=OSTimeDlyHMSM(0,0,1,0);

OSTimeDly(20);

var++;

} /* end while */

Page 7: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 7/8

}

The following output was obtained:

Inference: Task 2 is run, once delay is encountered the next high priority task, i.e., Task 3 is run.

When the OS Tick is encountered the tasks go back to the original priority and Task 2 is executed and

this goes on.

The lines of code added to make the semaphore work are as follows:

OS_EVENT *sem;

OS_EVENT *sem1;

Task 2:

OSSemPend(sem1,0,0);

uart_outstring(0,"This is String 1 ");

retval=OSTimeDlyHMSM(0,0,1,0); /* Delay for hr,min,sec,ms */

uart_outstring(0,"This is String 2 ");

retval=OSTimeDlyHMSM(0,0,1,0);

OSSemPost(sem);

Page 8: Rtos Lab Report

7/31/2019 Rtos Lab Report

http://slidepdf.com/reader/full/rtos-lab-report 8/8

Task 3:

OSSemPend(sem,0,0);

uart_outstring(0,"This is String 3 ");

retval=OSTimeDlyHMSM(0,0,1,0);

uart_outstring(0,"This is String 4 ");retval=OSTimeDlyHMSM(0,0,1,0);

OSSemPost(sem1);

sem=OSSemCreate(0);

sem1=OSSemCreate(1);

The output obtained is as below:

Third step: Interrupt control with MicroC.