REJ10J1025-0200Z M3T-MR308/4 V.4.00 User’s Manual Real-time OS for M16C/70,80,M32C/80 Series Rev.2.
Active X, Microsoft, MS-DOS, Visual Basic, Visual C++, Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. IBM and AT are registered trademarks of International Business Machines Corporation. Intel and Pentium are registered trademarks of Intel Corporation. Adobe, Acrobat, and Acrobat Reader are trademarks of Adobe Systems Incorporated. TRON is an abbreviation of "The Real-time Operating system Nucleus.
Preface The M3T-MR308/4(abbreviated as MR308) is a real-time operating system1 for the M16C/70,80, M32C/80 series microcomputers. The MR308 conforms to the µITRON Specification.2 This manual describes the procedures and precautions to observe when you use the MR308 for programming purposes. For the detailed information on individual service call procedures, refer to the MR308 Reference Manual.
Contents Chapter 1 User’s Manual Organization .................................................................................................... - 1 - Chapter 2 General Information ................................................................................................................. - 3 - 2.1 2.2 2.3 Objective of MR308 Development...................................................................................................... - 4 Relationship between TRON Specification and MR308......
4.2 Development Procedure Example.................................................................................................... - 62 4.2.1 Applications Program Coding................................................................................................... - 62 4.2.2 Configuration File Preparation ................................................................................................ - 64 4.2.3 Configurator Execution....................................................................
Warning messages .............................................................................................................................................. - 131 Other messages................................................................................................................................................... - 131 - 6.3 6.4 Editing makefile .............................................................................................................................
List of Figures Figure 3.1 Relationship between Program Size and Development Period...................................- 10 Figure 3.2 Microcomputer-based System Example(Audio Equipment) ....................................... - 11 Figure 3.3 Example System Configuration with Real-time OS(Audio Equipment) ....................- 12 Figure 3.4 Time-division Task Operation .......................................................................................- 13 Figure 3.
Figure 5.2 Example Task Terminating with ext_tsk() Described in C Language........................- 68 Figure 5.3 Example of Kernel(OS-dependent) Interrupt Handler................................................- 70 Figure 5.4 Example of Non-kernel(OS-independent) Interrupt Handler.....................................- 71 Figure 5.5 Example Cyclic Handler Written in C Language ........................................................- 72 Figure 5.6 Example Infinite Loop Task Described in Assembly Language...
List of Tables Table 3-1 Table 3-2 Table 3-3 Table 3.4 Table 5.1 Table 5.2 Table 6.1 Table 6.2 Table 6.3 Table 8.1 Task Context and Non-task Context .....................................................................- 27 Invocable Service Calls in a CPU Locked State ...................................................- 29 CPU Locked and Dispatch Disabled State Transitions Relating to dis_dsp and loc_cpu - 29 List of the service call can be issued from the task and handler.......................
Chapter 1 User’s Manual Organization
Chapter 1 User’s Manual Organization The MR308 User’s Manual consists of nine chapters and thee appendix. • Chapter 2 General Information Outlines the objective of MR308 development and the function and position of the MR308. • Chapter 3 Introduction to MR308 Explains about the ideas involved in MR308 operations and defines some relevant terms. • Chapter 4 Applications Development Procedure Overview Outlines the applications program development procedure for the MR308.
Chapter 2 General Information
Chapter 2 General Information 2.1 Objective of MR308 Development In line with recent rapid technological advances in microcomputers, the functions of microcomputer-based products have become complicated. In addition, the microcomputer program size has increased. Further, as product development competition has been intensified, manufacturers are compelled to develop their microcomputer-based products within a short period of time.
Chapter 2 General Information 7. Timer control is made easier. To perform processing at 10 ms intervals, the microcomputer timer function was formerly used to periodically initiate an interrupt. However, as the number of usable microcomputer timers was limited, timer insufficiency was compensated for by, for instance, using one timer for a number of different processing operations.
Chapter 2 General Information 2.2 Relationship between TRON Specification and MR308 The TRON Specification is an abbreviation for The Real-time Operating system Nucleus specification. It denotes the specifications for the nucleus of a real-time operating system. The TRON Project, which is centered on TRON Specification design, is pushed forward under the leadership of Dr. Ken Sakamura at University of Tokyo. As one item of this TRON Project, the ITRON Specification is promoted.
Chapter 2 General Information 2.3 MR308 Features The MR308 offers the following features. 1. Real-time operating system conforming to the µITORN Specification. The MR308 is designed in compliance with the µITRON Specification which incorporates a minimum of the ITRON Specification functions so that such functions can be incorporated into a one-chip microcomputer.
Chapter 3 Introduction to MR308
Chapter 3 Introduction to MR308 3.1 Concept of Real-time OS This section explains the basic concept of real-time OS. 3.1.1 Why Real-time OS is Necessary In line with the recent advances in semiconductor technologies, the single-chip microcomputer ROM capacity has increased. ROM capacity of 32K bytes. As such large ROM capacity microcomputers are introduced, their program development is not easily carried out by conventional methods. Fig.3.
Chapter 3 Introduction to MR308 Key input microcomputer Remote control microcomputer LED illumination microcomputer Arbiter microcomputer Volume control microcomputer Monitor microcomputer Mechanical control microcomputer Figure 3.2 Microcomputer-based System Example(Audio Equipment) Using independent microcomputers for various functions as indicated in the above example offers the following advantages. 1. Individual programs are small so that program development is easy. 2.
Chapter 3 Introduction to MR308 Key input Task Remote control Task LED illumination Task real-time OS Volume control Task Monitor Task Mechanical control Task Figure 3.3 Example System Configuration with Real-time OS(Audio Equipment) In other words, the real-time OS is the software that makes a one-microcomputer system look like operating a number of microcomputers.
Chapter 3 Introduction to MR308 3.1.2 Operating Principles of Real-time OS The real-time OS is the software that makes a one-microcomputer system look like operating a number of microcomputers. You should be wondering how the real-time OS makes a one-microcomputer system function like a number of microcomputers. As shown in Figure 3.4 the real-time OS runs a number of tasks according to the time-division system.
Chapter 3 Introduction to MR308 In the state shown in Figure 3.5, it appears to the programmer that the key input task or its microcomputer is halted while another task assumes execution control. Task execution restarts at the point of last interruption as the register contents prevailing at the time of the last interruption are recovered.
Chapter 3 Introduction to MR308 Memory map Register R0 Remote control Task PC SP R0 Key input Task Stack section PC SP R0 LED illumination Task PC SP Real-time OS SFR SP Figure 3.7 Task Register Area Figure 3.8 shows the register and stack area of one task in detail. In the MR308, the register of each task is stored in a stack area as shown in Figure 3.8. This figure shows the state prevailing after register storage.
Chapter 3 Introduction to MR308 3.2 Service Call How does the programmer use the real-time OS in a program? First, it is necessary to call up a real-time OS function from the program in some way or other. Calling a real-time OS function is referred to as a service call. Task activation and other processing operations can be initiated by such a service call (See Figure 3.9). Real-time OS Key input Task Service call Remote control task Task switching Figure 3.
Chapter 3 Introduction to MR308 3.2.1 Service Call Processing When a service call is issued, processing takes place in the following sequence.8 1. The current register contents are saved. 2. The stack pointer is changed from the task type to the real-time OS (system) type. 3. Processing is performed in compliance with the request made by the service call. 4. The task to be executed next is selected. 5. The stack pointer is changed to the task type. 6.
Chapter 3 Introduction to MR308 3.2.2 Task Designation in Service call Each task is identified by the ID number internally in MR308. For example, the system says, "Start the task having the task ID number 1." However, if a task number is directly written in a program, the resultant program would be very low in readability. If, for instance, the following is entered in a program, the programmer is constantly required to know what the No. 2 task is.
Chapter 3 Introduction to MR308 3.3 Task This section describes how tasks are managed by MR308. 3.3.1 Task Status The real-time OS monitors the task status to determine whether or not to execute the tasks. Figure 3.12 shows the relationship between key input task execution control and task status. When there is a key input, the key input task must be executed. That is, the key input task is placed in the execution (RUNNING) state. While the system waits for key input, task execution is not needed.
Chapter 3 Introduction to MR308 MPU execlusive right acquisition READY state RUNNING state MPU execlusive right relinquishment WAITING l Entering the WAITING state state WAITING state SUSPENDED state clear request from other task SUSPEND request from other task Forced termination request from other task WAITING-SUSPENDED state SUSPEND request from other task SUSPENDED state clear request Forced termination request from other task WAITING clear t state SUSPENDED state DORMANT state Task activa
Chapter 3 Introduction to MR308 to the ready queue 13 is placed in the RUNNING state. ♦ ♦ ♦ ♦ ♦ A currently executed task has normally terminated itself.14 A currently executed task has placed itself in the WAITING state.15 A currently executed task has changed its own priority so that the priority of a different READY task is rendered higher.
Chapter 3 Introduction to MR308 4. SUSPENDED state When the sus_tsk system call is issued from a task in the RUNNING state or the isus_tsk system call is issued from a handler, the READY task designated by the system call or the currently executed task enters the SUSPENDED state. If a task in the WAITING state is placed in this situation, it goes into the WAITING-SUSPENDED state.
Chapter 3 Introduction to MR308 3.3.2 Task Priority and Ready Queue In the real-time OS, several tasks may simultaneously request to be executed. In such a case, it is necessary to determine which task the system should execute first. To properly handle this kind of situation, the system organizes the tasks into proper execution priority and starts execution with a task having the highest priority.
Chapter 3 Introduction to MR308 3.3.3 Task Priority and Waiting Queue In The standard profiles in µITRON 4.0 Specification support two waiting methods for each object. In one method, tasks are placed in a waiting queue in order of priority (TA_TPRI attribute); in another, tasks are placed in a waiting queue in order of FIFO (TA_TFIFO). Figure 3.15 and Figure 3.16 depict the manner in which tasks are placed in a waiting queue in order of "taskD," "taskC," "taskA," and "taskB." ID No.
Chapter 3 Introduction to MR308 3.3.4 Task Control Block(TCB) The task control block (TCB) refers to the data block that the real-time OS uses for individual task status, priority, and other control purposes. The MR308 manages the following task information as the task control block • Task connection pointer Task connection pointer used for ready queue formation or other purposes.
Chapter 3 Introduction to MR308 TCB TCB TCB Task Connection pointer Status Priority SP Wake-up counter Flag wait mode Time-out counter or Flag wait pattern Timer queue Connection pointer This area is allocated only when the timeout function is used. Flag wait pattern Figure 3.
Chapter 3 Introduction to MR308 3.4 System States 3.4.1 Task Context and Non-task Context The system runs in either context state, "task context" or "non-task context." The differences between the task content and non-task context are shown in Table 3-1. Task Context and Non-task Context.
Chapter 3 Introduction to MR308 Task System clock interrupt handler Cyclic handler Alarm handler Subroutine call Timer interrupt RTS Figure 3.18 Cyclic Handler/Alarm Handler Activation 3.4.2 Dispatch Enabled/Disabled States The system assumes either a dispatch enabled state or a dispatch disabled state. In a dispatch disabled state, no task scheduling is performed. Nor can service calls be invoked that may cause the service call issuing task to enter a wait state.
Chapter 3 Introduction to MR308 3.4.3 CPU Locked/Unlocked States The system assumes either a CPU locked state or a CPU unlocked state. In a CPU locked state, all external interrupts are disabled against acceptance, and task scheduling is not performed either. The system can be placed into a CPU locked state or a CPU unlocked state by the loc_cpu(iloc_cpu) or unl_cpu(iunl_cpu) service call, respectively. Whether the system is in a CPU locked state can be known by the sns_loc service call.
Chapter 3 Introduction to MR308 3.5 MR308 Kernel Structure 3.5.1 Module Structure The MR308 kernel consists of the modules shown in Figure 3.19. Each of these modules is composed of functions that exercise individual module features. The MR308 kernel is supplied in the form of a library, and only necessary features are linked at the time of system generation. More specifically, only the functions used are chosen from those which comprise these modules and linked by means of the Linkage Editor LN308.
Chapter 3 Introduction to MR308 3.5.2 Module Overview The MR308 kernel modules are outlined below. • Scheduler Forms a task processing queue based on task priority and controls operation so that the high-priority task at the beginning in that queue (task with small priority value) is executed. • Task Management Module Exercises the management of various task states such as the RUNNING, READY, WAIT, and SUSPENDED state.
Chapter 3 Introduction to MR308 3.5.3 Task Management Function The task management function is used to perform task operations such as task start/stop and task priority updating. The MR308 kernel offers the following task management function service calls. • Activate Task (act_tsk, iact_tsk) Activates the task, changing its status from DORMANT to either READY or RUNNING. In this service call, unlike in sta_tsk(ista_tsk), startup requests are accumulated, but startup code cannot be specified.
Chapter 3 Introduction to MR308 Priority 1 Task A Task B 3 Task C Task B n Task E Task F 2 Task D When the priority of task B has been changed from 3 to 1 Figure 3.21 Alteration of task priority ID Number 1 2 3 taskA Priority 1 taskB taskC taskB Priority 2 Priority 3 Priority 4 n When the priority of Task B is changed into 4 Figure 3.22 Task rearrangement in a waiting queue • Reference task priority (get_pri, iget_pri) Gets the priority of a task.
Chapter 3 Introduction to MR308 3.5.4 Synchronization functions attached to task The task-dependent synchronization functions attached to task is used to accomplish synchronization between tasks by placing a task in the WAIT, SUSPENDED, or WAIT-SUSPENDED state or waking up a WAIT state task. The MR308 offers the following task incorporated synchronization service calls.
Chapter 3 Introduction to MR308 only one forcible wait request to be nested, if sus_tsk is issued to a task in a forcible wait state, the error E_QOVR is returned. (See Figure 3.25). E_QOVR sus_tsk sus_tsk rsm_tsk Task RUNNING state WAITINGSUSPENDED state WAITING state Number of suspension request READY state SUSPENDED state 0 1 WAITING state 1 0 Figure 3.
Chapter 3 Introduction to MR308 • ♦ Timeout wait state ♦ Wait state entered by slp_tsk service call (+ timeout included) ♦ Event flag (+ timeout included) wait state ♦ Semaphore (+ timeout included) wait state ♦ Message (+ timeout included) wait state ♦ Data transmission (+ timeout included) wait state ♦ Data reception (+ timeout included) wait state ♦ Fixed–size memory block (+ timeout included) acquisition wait state ♦ Short data transmission (+ timeout included) wait state ♦ Short da
Chapter 3 Introduction to MR308 3.5.5 Synchronization and Communication Function (Semaphore) The semaphore is a function executed to coordinate the use of devices and other resources to be shared by several tasks in cases where the tasks simultaneously require the use of them. When, for instance, four tasks simultaneously try to acquire a total of only three communication lines as shown in Figure 3.28, communication line-to-task connections can be made without incurring contention.
Chapter 3 Introduction to MR308 • Reference Semaphore Status (ref_sem, iref_sem) Refers the status of the target semaphore. Checks the count value and existence of the wait task for the target semaphore. Figure 3.30 shows example task execution control provided by the wai_sem and sig_sem service calls. wai_sem Task sig_sem wai_sem Task wai_sem Task wai_sem Task WAIT state Semaphore Counter 3 2 1 0 x Figure 3.
Chapter 3 Introduction to MR308 3.5.6 Synchronization and Communication Function (Eventflag) The eventflag is an internal facility of MR308 that is used to synchronize the execution of multiple tasks. The eventflag uses a flag wait pattern and a 16-bit pattern to control task execution. A task is kept waiting until the flag wait conditions set are met.
Chapter 3 Introduction to MR308 TaskA Flag queue TaskB TaskC 0xFF AND 0x0F AND TaskD TaskE TaskF 0xFF OR 0x10 OR Flag pattern 0 Wait pattern Wait mode 0x0F OR 0xFF AND set_flg TaskB TaskD Flag pattern 0x0F Figure 3.
Chapter 3 Introduction to MR308 3.5.7 Synchronization and Communication Function (Data Queue) The data queue is a mechanism to perform data communication between tasks. In Figure 3.32, for example, task A can transmit data to the data queue and task B can receive the transmitted data from the data queue. Data Data Data Data Data Task A Task B Figure 3.32 Data queue Data in width of 32 bits can be transmitted to this data queue. The data queue has the function to accumulate data.
Chapter 3 Introduction to MR308 3.5.8 Synchronization and Communication Function (Mailbox) The mailbox is a mechanism to perform data communication between tasks. In Figure 3.33, for example, task A can drop a message into the mailbox and task B can retrieve the message from the mailbox. Since mailbox-based communication is achieved by transferring the beginning address of a message from a task to another, this mode of communication is performed at high speed independently of the message size.
Chapter 3 Introduction to MR308 Message queue T_MSG header T_MSG header Message A Message B T_MSG header Message C Figure 3.34 Message queue There are following data queue service calls that are provided by the MR308 kernel. • Send to Mailbox (snd_mbx, isnd_mbx) Transmits a message. Namely, a message is dropped into the mailbox. • Receive from Mailbox (rcv_mbx, trcv_mbx) Receives a message. Namely, a message is retrieved from the mailbox.
Chapter 3 Introduction to MR308 3.5.9 Memory pool Management Function The memorypool management function provides system memory space (RAM space) dynamic control. This function is used to manage a specific memory area (memorypool), dynamically obtain memory blocks from the memorypool as needed for tasks or handlers, and release unnecessary memory blocks to the memorypool. The MR308 supports two types of memorypool management functions, one for fixed-size and the other for variable-size.
Chapter 3 Introduction to MR308 Variable-size Memory Pool Management Function The technique that allows you to arbitrary define the size of memory block acquirable from the memory pool is termed Variable-size scheme. The MR308 manages memory in terms of four fixed-size memory block sizes. The MR308 calculates the size of individual blocks based on the maximum memory block size to be acquired. You specify the maximum memory block size using the configuration file. e.g.
Chapter 3 Introduction to MR308 200 bytes TaskA Rounding Memorypool pget_blk 200 bytes 224 bytes Figure 3.36 pget_mpl processing • Release Acquire Variable-size Memory Block (rel_mpl) Releases a acquired memory block by pget_mpl service call. TaskA Memorypool Memorypool rel_blk top of address Figure 3.
Chapter 3 Introduction to MR308 3.5.10 Time Management Function The time management function provides system time management, time reading36, time setup37, and the functions of the alarm handler, which actuates at preselected times, and the cyclic handler, which actuates at preselected time intervals. The MR308 kernel requires one timer for use as the system clock. There are following time management service calls that are provided by the MR308 kernel.
Chapter 3 Introduction to MR308 at the fifth occurrence of the time tick. • Set System Time (set_tim) • Reference System Time (get_tim) The system time indicates an elapsed time from when the system was reset by using 48-bit data. The time is expressed in ms units.
Chapter 3 Introduction to MR308 3.5.11 Cyclic Handler Function The cyclic handler is a time event handler that is started every startup cycle after a specified startup phase has elapsed. The cyclic handler may be started with or without saving the startup phase. In the former case, the cyclic handler is started relative to the point in time at which it was generated. In the latter case, the cyclic handler is started relative to the point in time at which it started operating. Figure 3.39 and Figure 3.
Chapter 3 Introduction to MR308 3.5.12 Alarm Handler Function The alarm handler is a time event handler that is started only once at a specified time. Use of the alarm handler makes it possible to perform time-dependent processing. The time of day is specified by a relative time. Figure 3.41 shows a typical operation of the alarm handler. Alarm handler created Start operating Start operating Stop operating Activation Activation time time Handler starts Handler does not start Figure 3.
Chapter 3 Introduction to MR308 3.5.13 • System Status Management Function Rotate Task Precedence (rot_rdq, irot_rdq) This service call establishes the TSS (time-sharing system). That is, if the ready queue is rotated at regular intervals, round robin scheduling required for the TSS is accomplished (See Figure 3.42) Priority 1 taskA 2 3 n taskB taskC taskD taskE taskF Move the end of the queue Figure 3.
Chapter 3 Introduction to MR308 3.5.14 Interrupt Management Function The interrupt management function provides a function to process requested external interrupts in real time. The interrupt management service calls provided by the MR308 kernel include the following: • Returns from interrupt handler (ret_int) The ret_int service call activates the scheduler to switch over tasks as necessary when returning from the interrupt handler.
Chapter 3 Introduction to MR308 3.5.15 System Configuration Management Function This function inspects the version information of MR308. • 3.5.16 References Version Information(ref_ver, iref_ver) The ref_ver service call permits the user to get the version information of MR308. This version information can be obtained in the standardized format of µITRON specification. Extended Function (Short Data Queue) The short data queue is a function outside the scope of µITRON 4.0 Specification.
Chapter 3 Introduction to MR308 3.5.17 Extended Function (Reset Function) The reset function is a function outside the scope of µITRON 4.0 Specification. It initializes the mailbox, data queue, and memory pool, etc. • Clear Data Queue Area (vrst_dtq) Initializes the data queue. If there are any tasks waiting for transmission, they are freed from WAITING state and the error code EV_RST is returned. • Clear Mailbox Area (vrst_mbx) Initializes the mailbox.
Chapter 3 Introduction to MR308 3.5.18 Service calls That Can Be Issued from Task and Handler Some service calls can be issued from a task, others can be issued from non-task context, and still others can be issued from both. These service calls are listed in Table 3.4. Table 3.
Chapter 3 Introduction to MR308 Service Call Task Context Non-task Context sig_sem isig_sem wai_sem twai_sem pol_sem ipol_sem ref_sem iref_sem set_flg iset_flg clr_flg iclr_flg wai_flg twai_flg pol_flg ipol_flg ref_flg iref_flg snd_dtq tsnd_dtq psnd_dtq ipsnd_dtq fsnd_dtq ifsnd_dtq rcv_dtq trcv_dtq prcv_dtq iprcv_dtq ref_dtq iref_dtq snd_mbx isnd_mbx rcv_mbx trcv_mbx prcv_mbx iprcv_mbx ref_mbx iref_mbx o x o o o x o x o x o x o o o x o x o o o x o x o o o x o x o x o o o x o x x o x x x o x o x o x o
Chapter 3 Introduction to MR308 Service Call Task Context Non-task Context get_mpf tget_mpf pget_mpf rel_mpf irel_mpf ref_mpf iref_mpf ipget_mpf pget_mpl rel_mpl ref_mpl iref_mpl set_tim iset_tim get_tim iget_tim sta_cyc ista_cyc stp_cyc istp_cyc ref_cyc iref_cyc sta_alm ista_alm stp_alm istp_alm ref_alm iref_alm rot_rdq irot_rdq get_tid iget_tid loc_cpu iloc_cpu unl_cpu iunl_cpu dis_dsp ena_dsp sns_ctx sns_loc sns_dsp sns_dpn o o o o x o x x o o o x o x o x o x o x o x o x o x o x o x o x o x o x o o
Chapter 3 Introduction to MR308 Service Call Task Context Non-task Context ref_ver iref_ver vsnd_dtq vtsnd_dtq vpsnd_dtq vipsnd_dtq vfsnd_dtq vifsnd_dtq vrcv_dtq vtrcv_dtq vprcv_dtq viprcv_dtq vref_dtq viref_dtq vrst_mpf vrst_mpl vrst_mbx vrst_dtq vrst_vdtq o x o o o x o x o o o x o x o o o o o x o x x x o x o x x x o x o x x x x x - 58 -
Chapter 4 Applications Development Procedure Overview
Chapter 4 Applications Development Procedure Overview 4.1 Overview Application programs for MR308 should generally be developed following the procedure described below. 1. Generating a project When using HEW40, create a new project using MR308 on HEW. 2. Coding the application program Write the application program in code form using C or assembly language. If necessary, correct the sample startup program (crt0mr.a30) and section definition file (c_sec.inc or asm_sec.inc). 3.
Chapter 4 Applications Development Procedure Overview HEW Configuration file C standard header file MR308 include file kernel.h Configurator cfg308 Include file kernel_id.h Include file mr308.inc Application include file Application C source Application Assembler source System data definition file sys_ram.inc, sys_rom.inc Startup program start.a30, crt0mr.a30 C compiler Jamp table file mrtable.a30 nc308 Relocatable Assembler as308 Create Jamp table utility mr308tbl Systemcall file ( .
Chapter 4 Applications Development Procedure Overview 4.2 Development Procedure Example This chapter outlines the development procedures on the basis of a typical MR308 application example. 4.2.1 Applications Program Coding Figure 4.2 shows a program that simulates laser beam printer operations. Let us assume that the file describing the laser beam printer simulation program is named lbp.c. This program consists of the following three tasks and one interrupt handler.
Chapter 4 Applications Development Procedure Overview #include #include #include "kernel_id.
Chapter 4 Applications Development Procedure Overview 4.2.2 Configuration File Preparation Create a configuration file which has defined in it the task entry address, stack size, etc. Use of the GUI configurator available for MR308 helps to create a configuration file easily without having to learn how to write it. Figure 4.3 Configuration File Example shows an example configuration file for a laser beam printer simulation program (filename "lbp.cfg").
Chapter 4 Applications Development Procedure Overview 4.2.3 Configurator Execution When using HEW, select "Build all," which enables the user to execute the procedures described in 4.2.3, "Executing the Configurator," and 4.2.4, "System Generation." Execute the configurator cfg308 to generate system data definition files (sys_rom.inc, sys_ram.inc), include files (mr308.inc, kernel_id.h), and a system generation procedure description file (makefile) from the configuration file. A> cfg308 -mv lbp.
Chapter 5 Detailed Applications
Chapter 5 Detailed Applications 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.
Chapter 5 Detailed Applications 7. To specify a task, use the string written in the task definition item “name” of the configuration file.45 wup_tsk(ID_main); 8. To specify an event flag, semaphore, or mailbox, use the respective strings defined in the configuration file. For example, if an event flag is defined in the configuration file as shown below, flag[1]{ name }; = ID_abc; To designate this eventflag, proceed as follows. set_flg(ID_abc,&setptn); 9.
Chapter 5 Detailed Applications 5.1.2 Writing a Kernel (OS Dependent) Interrupt Handler When describing the kernel (OS-dependent) interrupt handler in C language, observe the following precautions. 1. Describe the kernel(OS-dependent) interrupt handler as a function 47 2. Be sure to use the void type to declare the interrupt handler start function return value and argument. 3. At the beginning of file, be sure to include "itron.h",”kernel.h” which is in the system directory as well as "kernel_id.
Chapter 5 Detailed Applications 5.1.3 Writing Non-kernel (OS-independent ) Interrupt Handler When describing the non-kernel(OS-independent) interrupt handler in C language, observe the following precautions. 1. Be sure to declare the return value and argument of the interrupt handler start function as a void type. 2. No service call can be issued from a non-kernel(an OS-independent) interrupt handler. NOTE: If this restriction is not observed, the software may malfunction. 3.
Chapter 5 Detailed Applications 5.1.4 Writing Cyclic Handler/Alarm Handler When describing the cyclic or alarm handler in C language, observe the following precautions. 1. Describe the cyclic or alarm handler as a function.50 2. Be sure to declare the return value and argument of the interrupt handler start function as a void type. 3. At the beginning of file, be sure to include "itron.h",”kernel.h” which is in the system directory as well as "kernel_id.h" which is in the current directory. 4.
Chapter 5 Detailed Applications 5.2 Program Coding Procedure in Assembly Language This section describes how to write an application using the assembly language. 5.2.1 Writing Task This section describes how to write an application using the assembly language. 1. Be sure to include "mr308.inc" at the beginning of file. 2. For the symbol indicating the task start address, make the external declaration.51 3.
Chapter 5 Detailed Applications 8. Set a task that is activated at MR308 system startup in the configuration file 52 The relationship between task ID numbers and tasks(program) is defined in the configuration file.
Chapter 5 Detailed Applications 5.2.2 Writing Kernel(OS-dependent) Interrupt Handler When describing the kernel(OS-dependent) interrupt handler in assembly language, observe the following precautions 1. At the beginning of file, be sure to include "mr308.inc" which is in the system directory. 2. For the symbol indicating the interrupt handler start address, make the external declaration(Global declaration).53 3.
Chapter 5 Detailed Applications 5.2.3 Writing Non-kernel(OS-independent) Interrupt Handler 1. For the symbol indicating the interrupt handler start address, make the external declaration (public declaration). 2. Make sure that the registers used in a handler are saved at the entry and are restored after use. 3. Be sure to end the handler by REIT instruction. 4. No service calls can be issued from a non-kernel(an OS-independent) interrupt handler.
Chapter 5 Detailed Applications 5.2.4 Writing Cyclic Handler/Alarm Handler When describing the cyclic or alarm handler in Assembly Language, observe the following precautions. 1. At the beginning of file, be sure to include "mr308.inc" which is in the system directory. 2. For the symbol indicating the handler start address, make the external declaration.55 3. Always use the RTS instruction (subroutine return instruction) to return from cyclic handlers and alarm handlers. For examples: .INCLUDE .
Chapter 5 Detailed Applications 5.3 The Use of INT Instruction MR308 has INT instruction interrupt numbers reserved for issuing service calls as listed in Table 5.2. For this reason, when using software interrupts in a user application, do not use interrupt numbers 63 through 55 and be sure to use some other numbers. Table 5.2 Interrupt No.
Chapter 5 Detailed Applications 5.5 Regarding Interrupts 5.5.1 Types of Interrupt Handlers MR308's interrupt handlers consist (OS-independent) interrupt handlers. of kernel(OS-dependent) interrupt handlers and non-kernel The following shows the definition of each type of interrupt handler.
Chapter 5 Detailed Applications 5.5.3 Controlling Interrupts Interrupt enable/disable control in a service call is accomplished by IPL manipulation. The IPL value in a service call is set to the kernel mask level(OS interrupt disable level = system.IPL) in order to disable interrupts for the kernel(OS-dependent) interrupt handler. In sections where all interrupts can be enabled, it is returned to the initial IPL value when the service call was invoked. Figure 5.
Chapter 5 Detailed Applications When the I flag before issuing a service call is 1 Task or Handler Service call issued I flag 1 0 1 IPL 4 system.IPL 4 service call processing Task or Handler 1 system.IPL 4 When the I flag before issuing a service call is 0 Task or Handler Service call issued I flag 0 IPL 4 service call processing Task or Handler 0 system.IPL 4 0 system.IPL 4 Figure 5.
Chapter 5 Detailed Applications 5.6 Regarding Delay Dispatching MR308 has four service calls related to delay dispatching. • dis_dsp • ena_dsp • loc_cpu • unl_cpu The following describes task handling when dispatch is temporarily delayed by using these service calls. 1. When the execution task in delay dispatching is preempted While dispatch is disabled, even under conditions where the task under execution should be preempted, no time is dispatched to new tasks that are in an executable state.
Chapter 5 Detailed Applications 5.7 Regarding Initially Activated Task MR308 permits the user to specify a task that starts from a READY state at system startup time. To do this, add TA_STA as task attribute. This specification should be set in a configuration file. For details on how to set, refer to page - 105 -.
Chapter 5 Detailed Applications 5.8 Modifying MR308 Startup Program MR308 comes with two types of startup programs as described below. • start.a30 This startup program is used when you created a program using the assembly language. • crt0mr.a30 This startup program is used when you created a program using the C language. This program is derived from "start.a30" by adding an initialization routine in C language. The startup programs perform the following: • Initialize the processor after a reset.
Chapter 5 Detailed Applications 5.8.1 C Language Startup Program (crt0mr.a30) Figure 5.14 C Language Startup Program (crt0mr.a30) shows the C language startup program(crt0mr.a30).
Chapter 5 Detailed Applications 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 MOV.L #FROM_,A0 MOV.L #TO_,A1 MOV.L #(sizeof SECT_ & 0FFFFFFH), R3R1 XCHG.W R1,R3 _loop: SMOVF.B CMP.W #0,R1 JEQ _end MOV.B [A0],[A1] ADD.L #1,A1 ADD.L #1,A0 MOV.W #0FFFFH,R3 SUB.
Chapter 5 Detailed Applications 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 ;-------------------------------------------------------BCOPY data_FEI_top,data_FE_top,data_FE BCOPY data_FOI_top,data_FO_top,data_FO LDC LDC #__Sys_Sp,SP #__
Chapter 5 Detailed Applications 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 JSR.W .ENDIF __init_alh .IF CYCLIC_HANDLER .GLB __init_cyh JSR.W __init_cyh .ENDIF .IF __NUM_MPF ; Fixed Memory Pool .GLB __init_mpf JSR.W __init_mpf .ENDIF ;*A1* .
Chapter 5 Detailed Applications The following explains the content of the C language startup program (crt0mr.a30). 1. Incorporate a section definition file [13 in Figure 5.14] 2. Incorporate an include file for MR308 [14 in Figure 5.14] 3. Incorporate a system ROM area definition file [15 in Figure 5.14] 4. Incorporate a system RAM area definition file [16 in Figure 5.14] 5. This is the initialization program __SYS_INITIAL that is activated immediately after a reset. [99 - 256 in Figure 5.
Chapter 5 Detailed Applications 5.9 Memory Allocation This section describes how memory is allocated for the application program data. Use the section file provided by MR308 to set memory allocation. MR308 comes with the following two types of section files: • asm_sec.inc This file is used when you developed your applications with the assembly language. Refer to page - 91 - for details about each section. • c_sec.inc This file is used when you developed your applications with the C language. c_sec.
Chapter 5 Detailed Applications 5.9.1 Section Allocation of start.a30 The section allocation of the sample startup program for the assembly language "start.a30" is defined in "asm_sec.inc". Edit "asm_sec.inc" if section reallocation is required. The following explains each section that is defined in the sample section definition file "asm_sec.inc". • MR_RAM_DBG section This section stores the MR308's Debug functions RAM data. This section must be mapped the internal area.
Chapter 5 Detailed Applications 5.9.2 Section Allocation of crt0mr.a30 The section allocation of the sample startup program for the C language "crt0mr.a30" is defined in "c_sec.inc". Edit "c_sec.inc" if section reallocation is required. The sections defined in the sample section definition file "c_sec.inc" include the following sections that are defined in the section definition file "asm_sec.inc" of the sample startup program for the assembly language.
Chapter 5 Detailed Applications 000000H SFR 000400H MR_RAM_DBG Section generated by NC308 MR_RAM_NE MR_RAM_NO MR_RAM Section generated by NC308 stack Section generated by NC308 Section generated by NC308 0FF0000H Section generated by NC308 MR_KERNEL MR_CIF MR_ROM 0FFFE00H data_NE bss_NE data_NO bss_NO rom_NE rom_NO MR_HEAP 0FFFD00H data_SE bss_SE data_SO bss_SO data_FE bss_FE data_FO bss_FO rom_FE rom_FO data_SEI data_SOI data_NEI data_NOI data_FEI data_FOI This section is no linked when the p
Chapter 5 Detailed Applications 5.10 Using in M16C/70 Series When you use M16C/70 series, please be sure to set up the following options. Refer to the manual of each tool for detailed explanation of these options.
Chapter 6 Using Configurator
Chapter 6 Using Configurator 6.1 Configuration File Creation Procedure When applications program coding and startup program modification are completed, it is then necessary to register the applications program in the MR308 system. This registration is accomplished by the configuration file. 6.1.1 Configuration File Data Entry Format This chapter describes how the definition data are entered in the configuration file.
Chapter 6 Using Configurator Table 6.2 Operator () - (Unary_minus) ∗/% + - (Binary_minus) Operators Priority High Low Direction of computation From left to right From right to left From left to right From loft to right Numerical value examples are presented below.
Chapter 6 Using Configurator • 10ms • 10.5ms It is also well to remember that the time must not begin with . (period).
Chapter 6 Using Configurator 6.1.
Chapter 6 Using Configurator 2. Maximum value of priority (value of lowest priority) [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] 63 Define the maximum value of priority used in MR308's application programs. This must be the value of the highest priority used. 3.
Chapter 6 Using Configurator 8. Maximum message priority value [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] None Define the maximum value of message priority. [( System Clock Definition Procedure )] << Format >> // System Clock Definition clock{ mpu_clock = MPU clock ; timer = Timers used for system clock ; IPL = System clock interrupt priority level ; }; << Content >> 1.
Chapter 6 Using Configurator [( Definition respective maximum numbers of items )] This definition is to be given only in forming the separate ROMs.59 Here, define respective maximum numbers of items to be used in two or more applications.
Chapter 6 Using Configurator 5. The maximum number of semaphores defined [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] None Define the maximum number of semaphores defined. 6. The maximum number of fixed-size memory pools defined [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] None 7. The maximum number of variable length memory blocks defined.
Chapter 6 Using Configurator [( Task definition )] << Format >> // Tasks Definition task[ ID No. ]{ name = entry_address = stack_size = priority = context = stack_section = initial_start = exinf = }; : : ID name ; Start task of address ; User stack size of task ; Initial priority of task ; Registers used ; Section name in which the stack is located ; TA_ACT attribute (initial startup state) ; Extended information ; The ID number must be in the range of 1 to 255. The ID number can be omitted.
Chapter 6 Using Configurator 3. User stack size of task [( Definition format )] Numeric value [( Definition range )] 12 or more [( Default value )] 256 Define the user stack size for each task. The user stack means a stack area used by each individual task. MR308 requires that a user stack area be allocated for each task, which amount to at least 12 bytes. 4.
Chapter 6 Using Configurator The task startup code of the initial startup task is 0. 8. Extended information [( Definition format )] Numeric value [( Definition range )] 0 to 0xFFFFFFFF [( Default value )] 0 Define the extended information of a task. This information is passed to the task as argument when it is restarted by a queued startup request, for example. [( Eventflag definition )] This definition is necessary to use Eventflag function. << Format >> // Eventflag Definition flag[ ID No.
Chapter 6 Using Configurator 3. Initial value of the event flag [( Definition format )] Numeric value [( Definition range )] 0 to 0xFFFF [( Default value )] 0 Specify the initial bit pattern of the event flag. 4. Multi-wait attribute [( Definition format )] Symbol [( Definition range )] TA_WMUL or TA_WSGL [( Default value )] TA_WSGL Specify whether multiple tasks can be enqueued in the eventflag waiting queue.
Chapter 6 Using Configurator 2. Selecting a semaphore waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TPRI [( Default value )] TA_TFIFO Select a method in which tasks wait for the semaphore. If TA_TFIFO is selected, tasks are enqueued in order of FIFO. If TA_TPRI is selected, tasks are enqueued in order of priority beginning with the one that has the highest priority. 3.
Chapter 6 Using Configurator 2. Number of data [( Definition format )] Numeric Value [( Definition range )] 0 to 0x1FFF [( Default value )] 0 Specify the number of data that can be transmitted. What should be specified here is the number of data, and not a data size. 3. Selecting a data queue waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TRPI [( Default value )] TA_TFIFO Select a method in which tasks wait for data queue transmission.
Chapter 6 Using Configurator 3. Selecting a data queue waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TRPI [( Default value )] TA_TFIFO Select a method in which tasks wait for short data queue transmission. If TA_TFIFO is selected, tasks are enqueued in order of FIFO. If TA_TPRI is selected, tasks are enqueued in order of priority beginning with the one that has the highest priority.
Chapter 6 Using Configurator 4. Maximum message priority [( Definition format )] Numeric Value [( Definition range )] 1 to "maximum value of message priority" that was specified in "definition of maximum number of items" [( Default value )] 1 Specify the maximum priority of message in the mailbox. [( Fixed-size memory pool definition )] This definition must always be set when the fixed-size memory pool function is to be used. << Format >> // Fixed Memory pool Definition memorypool[ ID No.
Chapter 6 Using Configurator 4. Size (in bytes) [( Definition format )] Numeric value [( Definition range )] 4 to 65,535 [( Default value )] 256 Define the size of the memory pool per block. The RAM size to be used as a memory pool is determined by this definition: (number of blocks) x (size) in bytes. 5.
Chapter 6 Using Configurator 3. Section name [( Definition format )] Symbol [( Definition range )] None [( Default value )] MR_HEAP Define the name of the section in which the memory pool is located. The section defined here must always have an area allocated for it in the section file (asm_sec.inc or c_sec.inc). If no section names are defined, the memory pool is located in the MR_HEAP section. 4.
Chapter 6 Using Configurator << Content >> Define the following for each cyclic handler ID number. 1. ID name [( Definition format )] Symbol [( Definition range )] None [( Default value )] None Define the name by which the memory pool is specified in a program. 2. Activation cycle [( Definition format )] Numeric value [( Definition range )] 1 to 32767 [( Default value )] None Define the activation cycle at which time the cyclic handler is activated periodically.
Chapter 6 Using Configurator 7. Extended information [( Definition format )] Numeric value [( Definition range )] 1 to 0xFFFFFFFF [( Default value )] 0 Define the extended information of the cyclic handler. This information is passed as argument to the cyclic handler when it starts. [( Alarm handler definition )] This definition is necessary to use Alarm handler function. << Format >> // Alarm Handlar Definition alarm_hand[ ID No.
Chapter 6 Using Configurator [( Interrupt vector definition )] This definition is necessary to use Interrupt function. << Format >> // Interrupt Vector Definition interrupt_vector[ Vector No. ]{ os_int = Kernel-managed (OS dependent) interrupt handler ; entry_address = Start address ; pragma_switch = Switch passed to PRAGMA extended function ; }; : : The vector number can be written in the range of 0 to 63 and 247 to 255.
Chapter 6 Using Configurator specified at the same time. [Precautions] 1. Regarding the method for specifying a register bank A kernel (OS dependent) interrupt handler that uses register bank 1 cannot be written in C language. Such an interrupt handler can only be written in assembly language. When writing in assembly language, make sure the statements at the entry and exit of the interrupt handler are written as shown below. (Always be sure to clear the B flag before issuing the ret_int service call.
Chapter 6 Using Configurator Table 6.
Chapter 6 Using Configurator 6.1.3 Configuration File Example The following is the configuration file example. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 //////////////////////////////////////////////////////////////////////////////// // // kernel.cfg : building file for MR308 Ver.4.
Chapter 6 Using Configurator 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 wait_queue clear_attribute wait_multi = TA_TFIFO; = NO; = TA_WMUL; }; flag[2]{ name = ID_flg3; initial_pattern = 0x0000ffff; wait_queue = TA_TPRI; clear_attribute = YES; wait_multi = TA
Chapter 6 Using Configurator 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 name = wait_queue section = siz_block = num_block = ID_mpf1; = TA_TFIFO; MR_RAM; 16; 5; }; memorypool[2]{ name = ID_mpf2; wait_queue = TA_TPRI; section = MR_RAM
Chapter 6 Using Configurator 235 236 237 238 239 240 241 242 243 entry_address = alm2; name = ID_alm2; exinf = 0x12345678; }; // // End of Configuration // - 122 -
Chapter 6 Using Configurator 6.2 Configurator Execution Procedures 6.2.1 Configurator Overview The configurator is a tool that converts the contents defined in the configuration file into the assembly language include file, etc.Figure 6.1 outlines the operation of the configurator. When used on HEW, the configurator is automatically started, and an application program is built. 1. Executing the configurator requires the following input files: • Configuration file (XXXX.
Chapter 6 Using Configurator Configuration File xxx.cfg Default Configuration File default.cfg System Data Difinition File sys_ram.inc, sys_rom.inc makefile Template File makefile.dos cfg308 System generation File makefile,Makefile makefile Template File Include File sys_ram.inc, mr308.inc mr308.inc,kernel_id.h MR308 Version File version Figure 6.
Chapter 6 Using Configurator 6.2.2 Setting Configurator Environment Before executing the configurator, check to see if the environment variable "LIB308" is set correctly. The configurator cannot be executed normally unless the following files are present in the directory indicated by the environment variable "LIB308": • Default configuration file (default.cfg) This file can be copied to the current directory for use. In this case, the file in the current directory is given priority.
Chapter 6 Using Configurator 6.2.3 Configurator Start Procedure Start the configurator as indicated below. A> cfg308 [-vmV] Configuration file name Normally, use the extension .cfg for the configuration file name. Command Options -v Option Displays the command option descriptions and detailed information on the version. -V Option Displays the information on the files generated by the command.
Chapter 6 Using Configurator 6.2.4 makefile generate Function The configurator follows the procedure below to generate makefile. 1. Examine the source file's dependency relationship. Assuming that the files bearing extensions .c and .a30 in the current directory respectively to be the C language and the assembly language files, the configurator examines the dependency relationship of the files to be included by those.
Chapter 6 Using Configurator 6.2.5 Precautions on Executing Configurator The following lists the precautions to be observed when executing the configurator: • If you have re-run the configurator, always be sure to execute make clean or delete all object files (extension .r30) and execute the make command. In this case, an error may occur during linking. • Do not modify the startup program name and the section definition file name.
Chapter 6 Using Configurator 6.2.6 Configurator Error Indications and Remedies If any of the following messages is displayed, the configurator is not normally functioning. Therefore, correct the configuration file as appropriate and the execute the configurator again. Error messages cfg308 Error : syntax error near line xxx (xxxx.cfg) There is an syntax error in the configuration file. cfg308 Error : not enough memory Memory is insufficient.
Chapter 6 Using Configurator service call of system definition item. cfg308 Error : system timer's vector conflict near line xxx A different vector is defined for the system clock timer interrupt vector. Confirm the vector No.x for interrupt vector definition. cfg308 Error : XXXX is not defined (xxxx.cfg) "XXXX" item must be set in your configuration file. cfg308 Error : system's default is not defined These items must be set int the default configuration file.
Chapter 6 Using Configurator Warning messages The following message are a warning. A warning can be ignored providing that its content is understood. cfg308 Warning : system is not defined (xxxx.cfg) cfg308 Warning : system.XXXX is not defined (xxxx.cfg) System definition or system definition item XXXX is omitted in the configuration file. cfg308 Warning : system.message_size is not defined (xxxx.cfg) The message size definition is omitted in the system definition.
Chapter 6 Using Configurator 6.3 Editing makefile Here you edit makefile the configurator generated, and set compilation options, libraries, and so on. The procedure for setting them is given below. 1. NC308WA command options You define command options of the C compiler in "CFLAGS". Be sure to define the "-c" option. 2. AS308 command options You define command options of the assembler in "ASFLAGS". 3. LN308 command options You define command options of the linker in "LDFLAGS".
Chapter 6 Using Configurator 6.4 About an error when you execute make The following warning message of mr308tbl is displayed when you execute make. mr308tbl Warning : You need not specify systime.timeout YES in configuration file Unless the following service calls are used, there is no need to set "Timeout=YES" in the system definition of a configuration file.
Chapter 7 Application Creation Guide
Chapter 7 Application Creation Guide 7.1 Processing Procedures for System Calls from Handlers When a service call is issued from a handler, task switching does not occur unlike in the case of a service call from a task. However, task switching occurs when a return from a handler 62 is made. The processing procedures for service calls from handlers are roughly classified into the following three types. 1. A service call from a handler that caused an interrupt during task execution 2.
Chapter 7 Application Creation Guide 7.1.1 System Calls from a Handler That Caused an Interrupt during Task Execution Scheduling (task switching) is initiated by the ret_int service call 63(See Figure 7.1). TaskA Interrupt handler OS Interrupt Save Registers system call processing iset_flg Restore Registers ret_int Task selection SP <= User TaskB Scheduler Restore Registers Figure 7.
Chapter 7 Application Creation Guide 7.1.2 System Calls from a Handler That Caused an Interrupt during System Call Processing Scheduling (task switching) is initiated after the system returns to the interrupted service call processing (See Figure 7.2). TaskA OS Interrupt handler wup_tsk Save Registers SP <= System Save Registers Interrupt iset_flg system call processing Restore Registers Task selection SP <= User ret_int Restore Registers TaskB Figure 7.
Chapter 7 Application Creation Guide 7.1.3 System Calls from a Handler That Caused an Interrupt during Handler Execution Let us think of a situation in which an interrupt occurs during handler execution (this handler is hereinafter referred to as handler A for explanation purposes).
Chapter 7 Application Creation Guide 7.2 Stacks 7.2.1 System Stack and User Stack The MR308 provides two types of stacks: system stack and user stack. • User Stack One user stack is provided for each task. Therefore, when writing applications with the MR308, it is necessary to furnish the stack area for each task. • System Stack This stack is used within the MR308 (during service call processing).
Chapter 8 Sample Program Description
Chapter 8 Sample Program Description 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 Function Name main() Type Task task1() ID No. Functions in the Sample Program Priority Description 1 1 Starts task1 and task2. Task 2 2 Outputs "task1 running." task2() Task 3 3 Outputs "task2 running." cyh1() Handler 1 Wakes up task1().
Chapter 8 Sample Program Description 8.2 Program Source Listing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 /************************************************************************* * MR308 smaple program * * COPYRIGHT(C) 2003(2005) RENESAS TECHNOLOGY CORPORATION * AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED * * * $Id: demo.c,v 1.
Chapter 8 Sample Program Description 8.3 Configuration File 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 //************************************************************************* // // COPYRIGHT(C) 2003,2005 RENESAS TECHNOLOGY CORPORATION // AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED // // MR308 System Configuration File. // "$Id: smp.cfg,v 1.
Chapter 9 Separate ROMs
Chapter 9 Separate ROMs 9.1 How to Form Separate ROMs This chapter describes how to form the MR308's kernel and application programs into separate ROMs. Figure 9.1 shows an instance in which the sections common to two different applications together with the kernel are allocated in the kernel ROM and the applications are allocated in separate ROMs. Here is how to divide a ROM based on this example. 1. System configuration Here you set up a system configuration of application programs.
Chapter 9 Separate ROMs kernel ROM (Internal ROM) MR_KERNEL Application ROM1 Startup Program MR_CIF MR308 kernel program MR308’s ROM data MR_ROM C language I/F routine App_prog Task of ID=1 Task2 Use Function : Mailbox : Eventflag Task3 Fix Interrupt Vector area Number of Task4 Task4 Interrupt vector area Application ROM2 MR_ROM MR_CIF MR308’s ROM data application change C language I/F routine App_prog Task1 Use Function Task2 : Mailbox : Eventflag Task3 : semaphore Task4 Numbe
Chapter 9 Separate ROMs Here you change the section files (c_sec.inc, asm_sec.inc), and set addresses of programs you locate in the application ROM. In this instance, the respective first addresses of the sections given below must agree with each other between two applications. Also, you need to invariably locate the MR_ROM section at the beginning of the application ROM. The sequence of other sections are free of restrictions.
Chapter 9 Separate ROMs e.g. mr308tbl \product\app1 \product\app2 8. Generating a system You execute the make command to generate a system.65 9. Carrying out steps 4 through 8 with respect to application 2 allows you to generate the system for application 2. The steps given above allows you to form the separate ROMs. 65 If the file mrtable.a30 is not held in the current directory, execute make command to generate a system.
Real-time OS for M16C/70,80,M32C/80 Series M3T-MR308/4 User's Manual Publication Date: Nov. 1, 2005 Rev.2.00 Published by: Sales Strategic Planning Div. Renesas Technology Corp. Edited by: Application Engineering Department 1 Renesas Solutions Corp. © 2005. Renesas Technology Corp. and Renesas Solutions Corp.
M3T-MR308/4 User's Manual