Program coding procedure in c language, Task description procedure, 1 program coding procedure in c language – Renesas 70 User Manual

Page 78: 1 task description procedure

Advertising
background image

Chapter 5 Detailed Applications

- 68 -

5.1 Program Coding Procedure in C Language

5.1.1

Task Description Procedure

1. Describe the task as a function.

To register the task for the MR308, enter its function name in the configuration file. When, for instance,
the function name "task()" is to be registered as the task ID number 3, proceed as follows.


task[3]{

name

=

ID_task;


entry_address = task();


stack_size

= 100;


priority

= 3;


};

2. At the beginning of file, be sure to include "itron.h",”kernel.h” which is in system directory

as well as "kernel_id.h" which is in the current directory. That is, be sure to enter the fol-
lowing two lines at the beginning of file.


#include <itron.h>

#include

<kernel.h>

#include "kernel_id.h"

3. No return value is provided for the task start function. Therefore, declare the task start

function as a void function.

4. A function that is declared to be static cannot be registered as a task.

5. It isn't necessary to describe ext_tsk() at the exit of task start function.

44

If you exit the task

from the subroutine in task start function, please describe ext_tsk() in the subroutine.

6. It is also possible to describe the task startup function, using the infinite loop.


#include

<itron.h>

#include

<kernel.h>

#include "kernel_id.h"


void task(void)

{


/* process */


}

Figure 5.1 Example Infinite Loop Task Described in C Language


#include

<itron.h>

#include

<kernel.h>

#include "kernel_id.h"


void task(void)

{

for(;;){

/*

process

*/


}

}

Figure 5.2 Example Task Terminating with ext_tsk() Described in C Language

44

The task is ended by ext_tsk() automatically if #pramga TASK is declared in the MR308. Similarly, it is ended by ext_tsk when returned

halfway of the function by return sentence.

Advertising