Renesas 70 Manual De Usuario

Descargar
Página de 162
Chapter 8 Sample Program Description 
   
- 142 - 
8.1  Overview of Sample Program 
As an example application of MR308, the following shows a program that outputs a string to the standard output 
device from one task and another alternately. 
Table 8.1  
Functions in the Sample Program 
Function 
Name 
Type ID 
No. 
Priority
Description 
main() 
Task 
Starts task1 and task2. 
task1() 
Task 
Outputs "task1 running." 
task2() 
Task 
Outputs "task2 running." 
cyh1() 
Handler 
 
Wakes up task1(). 
 
The content of processing is described below. 
• 
The main task starts task1, task2, and cyh1, and then terminates itself. 
• 
task1 operates in order of the following. 
1. Gets 
semaphore. 
2.  Goes to a wakeup wait state. 
3.  Outputs "task1 running." 
4.  Frees the semaphore. 
• 
task2 operates in order of the following. 
1. Gets 
semaphore. 
2.  Outputs "task2 running." 
3.  Frees the semaphore. 
cyh1 starts every 100 ms to wake up task1.