Renesas Emulator System M3T-MR100 User Manual
Renesas Emulator System M3T-MR100 User Manual

Renesas Emulator System M3T-MR100 User Manual

Real-time os for r32c/100 series
Table of Contents

Advertisement

Quick Links

To our customers,
st
On April 1
, 2010, NEC Electronics Corporation merged with Renesas Technology
Corporation, and Renesas Electronics Corporation took over all the business of both
companies. Therefore, although the old company name remains in this document, it is a valid
Renesas Electronics document. We appreciate your understanding.
Issued by: Renesas Electronics Corporation (http://www.renesas.com)
Send any inquiries to http://www.renesas.com/inquiry.
Old Company Name in Catalogs and Other Documents
Renesas Electronics website:
http://www.renesas.com
st
April 1
, 2010
Renesas Electronics Corporation

Advertisement

Table of Contents
loading

Summary of Contents for Renesas Emulator System M3T-MR100

  • Page 1 On April 1 , 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the old company name remains in this document, it is a valid Renesas Electronics document. We appreciate your understanding.
  • Page 2 Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific”...
  • Page 3 M3T-MR100/4 V.1.00 User’s Manual Real-time OS for R32C/100 Series Rev.1.00 2007.09...
  • Page 4 These materials are intended as a reference to assist our customers in the selection of the Renesas Technology product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any other rights, belonging to Renesas Technology Corporation, Renesas Solutions Corporation or a third party.
  • Page 5 MR100 Reference Manual. Requirements for MR100 Use When creating programs based on the MR100, it is necessary to purchase the following product of Renesas. • C-compiler package for R32C/100 series microcomputers (abbreviated as NC100) Document List The following sets of documents are supplied with the MR100.
  • Page 7: Table Of Contents

    Contents Requirements for MR100 Use ...i Document List...i Right of Software Use ...i Contents... iii List of Figures ... viii List of Tables ... xi User’s Manual Organization... - 1 - General Information ... - 3 - Objective of MR100 Development... - 3 - Relationship between TRON Specification and MR100...
  • Page 8 4.1.8 Synchronization and Communication Function (Mailbox) ... - 48 - 4.1.9 Memory pool Management Function(Fixed-size Memory pool) ... - 50 - 4.1.10 Variable-size Memory Pool Management Function ... - 51 - 4.1.11 Time Management Function... - 54 - 4.1.12 Cyclic Handler Function ... - 56 - 4.1.13 Alarm Handler Function...
  • Page 9 wai_flg Wait for eventflag... - 113 - pol_flg Wait for eventflag(polling)... - 113 - ipol_flg Wait for eventflag(polling, handler only)... - 113 - twai_flg Wait for eventflag(with timeout)... - 113 - ref_flg Reference eventflag status ... - 116 - iref_flg Reference eventflag status (handler only)...
  • Page 10 ref_alm Reference alarm handler status... - 166 - iref_alm Reference alarm handler status (handler only) ... - 166 - 5.12 System Status Management Function ... - 168 - rot_rdq Rotate task precedence... - 169 - irot_rdq Rotate task precedence (handler only) ... - 169 - get_tid Reference task ID in the RUNNING state...
  • Page 11 7.2.3 Writing Non-kernel Interrupt Handler... - 216 - 7.2.4 Writing Cyclic Handler/Alarm Handler ... - 216 - Modifying MR100 Startup Program... - 218 - 7.3.1 C Language Startup Program (crt0mr.a30)... - 219 - Memory Allocation ... - 224 - 7.4.1 Section used by the MR100...
  • Page 12 List of Figures Figure 3.1 Relationship between Program Size and Development Period...- 7 - Figure 3.2 Microcomputer-based System Example(Audio Equipment) ...- 8 - Figure 3.3 Example System Configuration with Real-time OS(Audio Equipment) ...- 9 - Figure 3.4 Time-division Task Operation ...- 10 - Figure 3.5 Task Execution Interruption and Resumption ...- 11 - Figure 3.6 Task Switching ...
  • Page 13 Figure 6.3 Configuration File Example ...- 209 - Figure 6.4 Configurator Execution ...- 209 - Figure 6.5 System Generation...- 210 - Figure 7.1 Example Infinite Loop Task Described in C Language ...- 211 - Figure 7.2 Example Task Terminating with ext_tsk() Described in C Language...- 212 - Figure 7.3 Example of Kernel Interrupt Handler...- 213 - Figure 7.4 Example of Non-kernel Interrupt Handler ...- 213 - Figure 7.5 Example Cyclic Handler Written in C Language ...- 214 -...
  • Page 15: List Of Tables

    List of Tables Table 3.1 Task Context and Non-task Context ...- 28 - Table 3.2 Invocable Service Calls in a CPU Locked State...- 30 - Table 3.3 CPU Locked and Dispatch Disabled State Transitions Relating to dis_dsp and loc_cpu- 30 - Table 5.1 Specifications of the Task Management Function ...- 63 - Table 5.2 List of Task Management Function Service Call...- 63 - Table 5.3 Specifications of the Task Dependent Synchronization Function ...- 84 -...
  • Page 17: User's Manual Organization

    User’s Manual Organization The MR100 User’s Manual consists of nine chapters and thee appendix. • 2 General Information Outlines the objective of MR100 development and the function and position of the MR100. • 3 Introduction to Kernel Explains about the ideas involved in MR100 operations and defines some relevant terms. •...
  • Page 19: General Information

    However, the conventional methods are not adequate for the purpose of solving the problems. Under these circumstances, it is necessary to introduce a new system named real-time OS To answer the above-mentioned demand, Renesas has developed a real-time operating system, tradenamed MR100, for use with the R32C/100 series of 32-bit microcomputers .
  • Page 20 the greater part of program debugging can be initiated simply by observing the small modules. 4. Timer control is made easier. To perform processing at 10 ms intervals, the microcomputer timer function was formerly used to periodically in- itiate 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.
  • Page 21: Relationship Between Tron Specification And Mr100

    2.2 Relationship between TRON Specification and MR100 MR100 is the real-time operating system developed for use with the R32C/10 series of 32-bit microcomputers compliant with µITRON 4.0 Specification. µITRON 4.0 Specification stipulates standard profiles as an attempt to ensure software portability.
  • Page 22: Mr100 Features

    2.3 MR100 Features The MR100 offers the following features. 1. Real-time operating system conforming to the μITORN Specification. The MR100 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. As the μITRON Specification is a subset of the ITRON Specification, most of the knowledge obtained from published ITRON textbooks and ITRON seminars can be used as is.
  • Page 23: Introduction To Kernel

    Introduction to Kernel 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 in- creased. ROM capacity of 32K bytes. As such large ROM capacity microcomputers are introduced, their program development is not easily carried out by con- ventional methods.
  • Page 24: Figure 3.2 Microcomputer-Based System Example(Audio Equipment)

    Key input microcomputer Volume 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 advan- tages. 1. Individual programs are small so that program development is easy. 2.
  • Page 25: Figure 3.3 Example System Configuration With Real-Time Os(Audio Equipment)

    Key input Remote control LED illumination Task Task Task real-time Volume control Monitor Mechanical Task control Task 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.
  • Page 26: Operating Principles Of Kernel

    3.1.2 Operating Principles of Kernel A kernel is the core program of real-time OS. The kernel is the software that makes a one-microcomputer system look like operating a number of microcomputers. You should be wondering how the kernel makes a one-microcomputer system function like a number of microcomputers.
  • Page 27: Figure 3.5 Task Execution Interruption And Resumption

    Key input Task Remote control Task Figure 3.5 Task Execution Interruption and Resumption 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.
  • Page 28: Figure 3.7 Task Register Area

    Register Remote control Task Key input Task LED illumination Task Real-time Figure 3.7 Task Register Area Memory map - 12 - Stack section...
  • Page 29: Figure 3.8 Actual Register And Stack Area Management

    Figure 3.8 shows the register and stack area of one task in detail. In the MR100, 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. Register not stored Key input Task...
  • Page 30 3.2 Service Call How does the programmer use the kernel functions in a program? First, it is necessary to call up kernel function from the program in some way or other. Calling a kernel 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). Key input Task Service call...
  • Page 31: Service Call Processing

    3.2.1 Service Call Processing When a service call is issued, processing takes place in the following sequence. 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.
  • Page 32: Processing Procedures For Service Calls From Handlers

    3.2.2 Processing Procedures for Service 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 The processing procedures for service calls from handlers are roughly classified into the following three types.
  • Page 33: Figure 3.11 Processing Procedure For A Service Call A Handler That Caused An Interrupt During Task

    Service Calls from a Handler That Caused an Interrupt during Task Execution (See Figure 3.11). Scheduling (task switching) is initiated by the ret_int service call TaskA Interrupt handler Interrupt Save Registers Service call processing iset_flg Restore Registers ret_int Task selection Scheduler SP <= User TaskB...
  • Page 34: Figure 3.12 Processing Procedure For A Service Call From A Handler That Caused An Interrupt During Service Call Processing

    Service Calls from a Handler That Caused an Interrupt during Service Call Processing Scheduling (task switching) is initiated after the system returns to the interrupted service call processing (See Figure 3.12). TaskA wup_tsk Save Registers SP <= System Interrupt Task selection SP <= User Restore Registers TaskB...
  • Page 35: Service Calls From A Handler That Caused An Interrupt During Handler Execution

    Service 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). When task switching is called for as a handler (hereinafter referred to as handler B) that caused an interrupt during handler A execution issued a service call, task switching does not take place during the exe- cution of the service call (ret_int service call) returned from handler B, but is effected by the ret_int service call from han- dler A (See Figure 3.13).
  • Page 36: Object

    3.3 Object The object operated by the service call of a semaphore, a task, etc. is called an "object." An object is identified by the ID number 3.3.1 The specification method of the object in a service call Each task is identified by the ID number internally in MR100. For example, the system says, "Start the task having the task ID number 1."...
  • Page 37: Task

    3.4 Task This section describes how tasks are managed by MR100. 3.4.1 Task Status The real-time OS monitors the task status to determine whether or not to execute the tasks. Figure 3.15 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.
  • Page 38: Figure 3.16 Mr100 Task Status Transition

    READY state WAITING SUSPENDED state clear request from other task SUSPEND request from other task SUSPENDED state clear request Forced termination request from other task Task activation 1. RUNNING state In this state, the task is being executed. Since only one microcomputer is used, it is natural that only one task is being executed.
  • Page 39 ♦ A currently executed task has placed itself in the WAITING state. ♦ A currently executed task has changed its own priority by chg_pri or ichg_pri service call so that the priority of a different READY task is rendered higher. ♦...
  • Page 40 tasks in the RUNNING, READY, or WAITING state. PENDED state, an error code is returned. 5. WAITING-SUSPENDED If a suspend request is issued to a task currently in a WAITING state, the task goes to a WAITING-SUSPENDED state. If a suspend request is issued to a task that has been placed into a WAITING state for a wait request by the slp_tsk, wai_flg, wai_sem, rcv_mbx, snd_dtq, rcv_dtq, vsnd_dtq, vrcv_dtq, get_mpf, tslp_tsk, twai_flg, twai_sem, trcv_mbx, tsnd_dtq, trcv_dtq, vtsnd_dtq, vtrcv_dtq or tget_mpf service call, the task goes to a WAIT- ING-SUSPENDED state.
  • Page 41: Task Priority And Ready Queue

    3.4.2 Task Priority and Ready Queue In the kernel, 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.
  • Page 42: Task Priority And Waiting Queue

    3.4.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).
  • Page 43: Figure 3.20 Task Control Block

    3.4.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 oth- er control purposes. The MR100 manages the following task information as the task control block •...
  • Page 44: System States

    3.5 System States 3.5.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. Invocable service call Task scheduling Stack...
  • Page 45: Figure 3.21 Cyclic Handler/Alarm Handler Activation

    Task Timer interrupt Figure 3.21 Cyclic Handler/Alarm Handler Activation System clock interrupt handler Cyclic handler Alarm handler Subroutine call - 29 -...
  • Page 46: Figure 3.9 Service Call

    3.5.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 sched- uling is performed. Nor can service calls be invoked that may cause the service call issuing task to enter a wait state. The system can be placed into a dispatch disabled state or a dispatch enabled state by the dis_dsp or ena_dsp service call, respectively.
  • Page 47: Regarding Interrupts

    3.6 Regarding Interrupts 3.6.1 Types of Interrupt Handlers MR100's interrupt handlers consist of kernel interrupt handlers and non-kernel interrupt handlers. The following shows the definition of each type of interrupt handler. • Kernel interrupt handler An interrupt handler whose interrupt priority level is lower than a kernel interruption mask level is called kernel interrupt handler.
  • Page 48: Controlling Interrupts

    3.6.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 interrupt han- dler.
  • Page 49: Figure 3.24 Interrupt Control In A Service Call That Can Be Issued From A Task-Independent

    As shown in Figure 3.23 and Figure 3.24, the interrupt enable flag and IPL change in a service call. For this reason, if you want to disable interrupts in a user application, Renesas does not recommend using the method for manipulating the inter- rupt disable flag and IPL to disable the interrupts.
  • Page 50: Stacks

    3.7 Stacks 3.7.1 System Stack and User Stack The MR100 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 MR100, it is necessary to furnish the stack area for each task.
  • Page 51: Kernel

    Kernel 4.1.1 Module Structure The MR100 kernel consists of the modules shown in Figure 4.1. Each of these modules is composed of functions that exer- cise individual module features. The MR100 kernel is supplied in the form of a library, and only necessary features are linked at the time of system genera- tion.
  • Page 52: Module Overview

    4.1.2 Module Overview The MR100 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. •...
  • Page 53: Task Management Function

    4.1.3 Task Management Function The task management function is used to perform task operations such as task start/stop and task priority updating. The MR100 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, un- like in sta_tsk(ista_tsk), startup requests are accumulated, but startup code cannot be specified.
  • Page 54: Figure 4.3 Alteration Of Task Priority

    Priority ID Number 1 2 taskA 3 Priority 1 n When the priority of Task B is changed into 4 Figure 4.4 Task rearrangement in a waiting queue • Reference task priority (get_pri, iget_pri) Gets the priority of a task. •...
  • Page 55: Synchronization Functions Attached To Task

    4.1.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 MR100 offers the following task incorporated synchronization service calls. •...
  • Page 56: Figure 4.7 Forcible Wait Of A Task And Resume

    • Suspend task (sus_tsk, isus_tsk) • Resume suspended task (rsm_tsk, irsm_tsk) These service calls forcibly keep a task suspended for execution or resume execution of a task. If a suspend re- quest is issued to a task in READY state, the task is placed into SUSPENDED state; if issued to a task in WAIT ING state, the task is placed into WAITING-SUSPENDED state.
  • Page 57: Figure 4.8 Forcible Wait Of A Task And Forcible Resume

    • Forcibly resume suspended task (frsm_tsk, ifrsm_tsk) Clears the number of suspension requests nested to 0 and forcibly resumes execution of a task. Since MR100 al- lows only one suspension request to be nested, this service call behaves the same way as rsm_tsk and irsm_tsk..(See Figure 4.8).
  • Page 58: Figure 4.9 Dly_Tsk Service Call

    • Delay task (dly_tsk) Keeps a task waiting for a finite length of time. Figure 4.9 shows an example in which execution of a task is kept waiting for 10 ms by the dly_tsk service call. The timeout value should be specified in ms units, and not in time tick units.
  • Page 59: Synchronization And Communication Function (Semaphore)

    4.1.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 4.10, communication line-to-task connections can be made without incurring contention.
  • Page 60: Figure 4.11 Semaphore Counter

    • 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 se- maphore. Figure 4.12 shows example task execution control provided by the wai_sem and sig_sem service calls. Task Task Task...
  • Page 61: Synchronization And Communication Function (Eventflag)

    4.1.6 Synchronization and Communication Function (Eventflag) The eventflag is an internal facility of MR100 that is used to synchronize the execution of multiple tasks. The eventflag uses a flag wait pattern and a 32-bit pattern to control task execution. A task is kept waiting until the flag wait conditions set are met.
  • Page 62: Figure 4.13 Task Execution Control By The Eventflag

    Figure 4.13 shows an example of task execution control by the eventflag using the wai_flg and set_flg service calls. The eventflag has a feature that it can wake up multiple tasks collectively at a time. In Figure 4.13, there are six tasks linked one to another, task A to task F. When the flag pattern is set to 0xF by the set_flg service call, the tasks that meet the wait conditions are removed sequentially from the top of the queue.
  • Page 63: Synchronization And Communication Function (Data Queue)

    4.1.7 Synchronization and Communication Function (Data Queue) The data queue is a mechanism to perform data communication between tasks. In Figure 4.14, for example, task A can transmit data to the data queue and task B can receive the transmitted data from the data queue. Data Task A Data in width of 32 bits can be transmitted to this data queue.
  • Page 64: Synchronization And Communication Function (Mailbox)

    4.1.8 Synchronization and Communication Function (Mailbox) The mailbox is a mechanism to perform data communication between tasks. In Figure 4.15, 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 start address of a message from a task to another, this mode of communication is performed at high speed independently of the message size.
  • Page 65: Figure 4.16 Message Queue

    Message queue There are following data queue service calls that are provided by the MR100 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. At this time, if the mailbox has no mes- sages in it, the task is kept waiting until a message is sent to the mailbox.
  • Page 66: Memory Pool Management Function(Fixed-Size Memory Pool)

    4.1.9 Memory pool Management Function(Fixed-size Memory pool) A fixed-size memory pool is the memory of a certain decided size. The memory block size is specified at the time of a con- figuration. Figure 4.17 is a figure about the example of a fixed-size memory pool of operation. •...
  • Page 67: Variable-Size Memory Pool Management Function

    4.1.10 Variable-size Memory Pool Management Function A variable-size memory pool refers to the one in which a memory block of any desired size can be acquired from the mem- ory pool. The MR100 permits one of the following two memory pool management methods to be selected before the mem- ory pool is used.
  • Page 68: Figure 4.18 Pget_Mpl Processing

    [[Comparison of Two Management Methods]] • Processing speed Generally speaking, the normal block method is faster in memory allocation/deallocation processing than the small block method. • Memory usage efficiency If the difference between the maximum and minimum sizes of memory to be acquired is 8 times or more, the small block method is higher in memory usage efficiency than the other method.
  • Page 69: Figure 4.19 Rel_Mpl Processing

    TaskA Memorypool Memorypool rel_mpl top of address Figure 4.19 rel_mpl processing • Reference Acquire Variable-size Memory Pool Status (ref_mpl, iref_mpl) Checks the total free area of the memory pool, and the size of the maximum free area that can immediately be acquired.
  • Page 70: Time Management Function

    4.1.11 Time Management Function The time management function provides system time management, time reading alarm handler, which actuates at preselected times, and the cyclic handler, which actuates at preselected time intervals. The MR100 kernel requires one timer for use as the system clock. There are following time management service calls that are provided by the MR100 kernel.
  • Page 71 If the timeout value is not a multiple of time tick interval The timer times out at the (timeout value / time tick interval) + second time tick. For example, if the time tick interval is 10 ms and the specified timeout value is 35 ms, then the timer times out at the fifth oc- currence of the time tick.
  • Page 72: Cyclic Handler Function

    4.1.12 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.
  • Page 73: Alarm Handler Function

    4.1.13 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.
  • Page 74: System Status Management Function

    4.1.14 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 inter- vals, round robin scheduling required for the TSS is accomplished (See Figure 4.24) Priority 1...
  • Page 75: Interrupt Management Function

    4.1.15 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 MR100 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.
  • Page 76: System Configuration Management Function

    4.1.16 System Configuration Management Function This function inspects the version information of MR100. • References Version Information(ref_ver, iref_ver) The ref_ver service call permits the user to get the version information of MR100. This version information can be obtained in the standardized format of µITRON specification. 4.1.17 Extended Function (Short Data Queue) The short data queue is a function outside the scope of µITRON 4.0 Specification.
  • Page 77: Extended Function (Reset Function)

    4.1.18 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.
  • Page 79: Service Call Reffernce

    Service call reffernce 5.1 Task Management Function Specifications of the task management function of MR100 are listed in Table 5.1 below. The task description languages in item No. 4 are those specified in the GUI configurator. They are not output to a configuration file, nor are the MR100 ker- nel concerned with them.
  • Page 80 Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a following meaning. ♦ T: Can be called from task context ♦ N: Can be called from non-task context ♦...
  • Page 81 act_tsk iact_tsk ER ercd = act_tsk( ID tskid ); ER ercd = iact_tsk( ID tskid ); tskid ercd .include mr100.inc act_tsk TSKID iact_tsk TSKID TSKID ID number of the task to be started Register name Content after service call is issued Error code Task ID E_QOVR...
  • Page 82 This service call starts the task indicated by tskid. The started task goes from DORMANT state to READY state or RUN- NING state. The following lists the processing performed on startup. 1. Initializes the current priority of the task. 2. Clears the number of queued wakeup requests. 3.
  • Page 83: Can_Act Cancel Task Activation Request

    can_act ican_act ER_UINT actcnt = can_act( ID tskid ); ER_UINT actcnt = ican_act( ID tskid ); tskid ER_UINT actcnt > 0 actcnt < 0 .include mr100.inc can_act TSKID ican_act TSKID TSKID ID number of the task to cancel Register Content after service call is issued name R2R0 Canceled startup request count or error code...
  • Page 84 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task1() ER_UINT actcnt; actcnt = can_act( ID_task2 ); void task2() ext_tsk(); <<Example statement in assembly language>> .INCLUDE mr100.inc .GLB task task: can_act #ID_TASK2 - 68 -...
  • Page 85 sta_tsk ista_tsk ER ercd = sta_tsk( ID tskid,VP_INT stacd ); ER ercd = ista_tsk ( ID tskid,VP_INT stacd ); tskid VP_INT stacd ercd .include mr100.inc sta_tsk TSKID,STACD ista_tsk TSKID,STACD TSKID ID number of the target task STATCD Task start code Register name Content after service call is issued Error code...
  • Page 86 This service call starts the task indicated by tskid. In other words, it places the specified task from DORMANT state into READY state or RUNNING state. This service call does not enqueue task activation requests. Therefore, if a task activa- tion request is issued while the target task is not DORMANT state, the error code E_OBJ is returned to the service call is- suing task.
  • Page 87 ext_tsk ER ercd = ext_tsk(); None Not return from this service call .include mr100.inc ext_tsk None Not return from this service call Not return from this service call This service call terminates the invoking task. In other words, it places the issuing task from RUNNING state into DOR- MANT state.
  • Page 88 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task(void) ext_tsk(); <<Example statement in assembly language>> .INCLUDE mr100.inc .GLB task task: ext_tsk - 72 -...
  • Page 89 ter_tsk ER ercd = ter_tsk( ID tskid ); tskid ercd .include mr100.inc ter_tsk TSKID TSKID ID number of the forcibly terminated task Register name Content after service call is issued Error code ID number of the target task E_OBJ Object status invalid(task indicated by tskid is an inactive state) E_ILUSE Service call improperly used task indicated by tskid is the issuing task itself) This service call terminates the task indicated by tskid.
  • Page 90 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() ter_tsk( ID_main ); <<Example statement in assembly language>> .INCLUDE mr100.inc .GLB task task: PUSH.W ter_tsk #ID_TASK3 - 74 -...
  • Page 91 chg_pri ichg_pri ER ercd = chg_pri( ID tskid, PRI tskpri ); ER ercd = ichg_pri( ID tskid, PRI tskpri ); tskid tskpri ercd .include mr100.inc chg_pri TSKID,TSKPRI ichg_pri TSKID,TSKPRI TSKID ID number of the target task TSKPRI Priority of the target task Register name Content after service call is issued Error code...
  • Page 92 The priority (base priority) of the task specified by tskid is changed to the value indicated by tskpri, and tasks are resched- uled based on the result of change. If this service call is executed on a task queued in a ready queue (including a task under execution) or a task in a wait queue in which tasks are queued in order of priority, the object task is moved to the tail end of the tasks of relevant priority in the queue.
  • Page 93: Get_Pri Reference Task Priority

    get_pri iget_pri ER ercd = get_pri( ID tskid, PRI *p_tskpri ); ER ercd = iget_pri( ID tskid, PRI *p_tskpri ); tskid *p_tskpri ercd .include mr100.inc get_pri TSKID iget_pri TSKID TSKID ID number of the target task Register name Content after service call is issued Error code Acquired task priority E_OBJ...
  • Page 94 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() PRI p_tskpri; ER ercd; ercd = get_pri( ID_task2, &p_tskpri ); <<Example statement in assembly language>> .INCLUDE mr100.inc .GLB task task: get_pri #ID_TASK2 - 78 -...
  • Page 95 ref_tsk iref_tsk ER ercd = ref_tsk( ID tskid, T_RTSK *pk_rtsk ); ER ercd = iref_tsk( ID tskid, T_RTSK *pk_rtsk ); tskid T_RTSK *pk_rtsk ercd Contents of pk_rtsk typedef struct t_rtsk{ STAT tskstat tskpri tskbpri STAT tskwait wobjid lefttmo UINT actcnt UINT wupcnt UINT...
  • Page 96 This service call inspects the status of the task indicated by tskid and returns the current information on that task to the area pointed to by pk_rtsk as a return parameter. If TSK_SELF is specified, the status of the issuing task itself is inspected. If TSK_SELF is specified for tskid in non-task context, operation of the service call cannot be guaranteed.
  • Page 97 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RTSK rtsk; ER ercd; ercd = ref_tsk( ID_main, &rtsk ); <<Example statement in assembly language>> _refdata: .blkb .include mr100.inc .GLB task task: PUSH.W PUSH.L ref_tsk #TSK_SELF,#_refdata - 81 -...
  • Page 98 ref_tst iref_tst ER ercd = ref_tst( ID tskid, T_RTST *pk_rtst ); ER ercd = iref_tst( ID tskid, T_RTST *pk_rtst ); tskid T_RTST *pk_rtst ercd Contents of pk_rtsk typedef struct t_rtst{ STAT tskstat STAT tskwait } T_RTST; .include mr100.inc ref_tst TSKID, PK_RTST iref_tst TSKID, PK_RTST TSKID ID number of the target task...
  • Page 99 This service call inspects the status of the task indicated by tskid and returns the current information on that task to the area pointed to by pk_rtst as a return value. If TSK_SELF is specified, the status of the issuing task itself is inspected. If TSK_SELF is specified for tskid in non-task context, operation of the service call cannot be guaranteed.
  • Page 100: Table 5.3 Specifications Of The Task Dependent Synchronization Function

    5.2 Task Dependent Synchronization Function Specifications of the task-dependent synchronization function are listed in below. Table 5.3 Specifications of the Task Dependent Synchronization Function Item Maximum value of task wakeup request count Maximum number of nested forcible task wait requests count Table 5.4 List of Task Dependent Synchronization Service Call Service Call slp_tsk...
  • Page 101 slp_tsk tslp_tsk ER ercd = slp_tsk(); ER ercd = tslp_tsk( TMO tmout ); slp_tsk None tslp_tsk tmout ercd .include mr100.inc slp_tsk tslp_tsk TMO Timeout value tslp_tsk Register name Content after service call is issued Error code R6R4 Timeout value slp_tsk Register name Content after service call is issued Error code...
  • Page 102 This service call places the issuing task itself from RUNNING state into sleeping wait state. The task placed into WAIT- ING state by execution of this service call is released from the wait state in the following cases: When a task wakeup service call is issued from another task or an interrupt The error code returned in this case is E_OK.
  • Page 103 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( slp_tsk() != E_OK ) error(“Forced wakeup\n”); if( tslp_tsk( 10 ) == E_TMOUT ) error(“time out\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task: slp_tsk PUSHM R6R4 tslp_tsk...
  • Page 104: Wup_Tsk Wakeup Task

    wup_tsk iwup_tsk ER ercd = wup_tsk( ID tskid ); ER ercd = iwup_tsk( ID tskid ); tskid ercd .include mr100.inc wup_tsk TSKID iwup_tsk TSKID TSKID ID number of the target task Register name Content after service call is issued Error code ID number of the target task E_OBJ E_QOVR...
  • Page 105 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( wup_tsk( ID_main ) != E_OK ) printf(“Can’t wakeup main()\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W wup_tsk #ID_TASK1 - 89 -...
  • Page 106: Can_Wup Cancel Wakeup Request

    can_wup ican_wup ER_UINT wupcnt = can_wup( ID tskid ); ER_UINT wupcnt = ican_wup( ID tskid ); tskid ER_UINT wupcnt > 0 wupcnt <0 .include mr100.inc can_wup TSKID ican_wup TSKID TSKID ID number of the target task Register name Content after service call is issued R2R0 Error code,Canceled wakeup request count E_OBJ...
  • Page 107 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() ER_UINT wupcnt; wupcnt = can_wup(ID_main); if( wup_cnt > 0 ) printf(“wupcnt = %d\n”,wupcnt); <<Example statement in assembly language>> .include mr100.inc .GLB task task: can_wup #ID_TASK3 - 91 -...
  • Page 108 rel_wai Release task from waiting irel_wai Release task from waiting (handler only) ER ercd = rel_wai( ID tskid ); ER ercd = irel_wai( ID tskid ); tskid ercd .include mr100.inc rel_wai TSKID irel_wai TSKID TSKID ID number of the target task Register name Content after service call is issued Error code...
  • Page 109 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( rel_wai( ID_main ) != E_OK ) error(“Can’t rel_wai main()\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W rel_wai #ID_TASK2 - 93 -...
  • Page 110: Sus_Tsk Suspend Task

    sus_tsk isus_tsk ER ercd = sus_tsk( ID tskid ); ER ercd = isus_tsk( ID tskid ); tskid ercd .include mr100.inc sus_tsk TSKID isus_tsk TSKID TSKID ID number of the target task Register name Content after service call is issued Error code ID number of the target task E_OBJ E_QOVR...
  • Page 111 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( sus_tsk( ID_main ) != E_OK ) printf(“Can’t suspend task main()\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W sus_tsk #ID_TASK2 - 95 -...
  • Page 112: Rsm_Tsk Resume Suspended Task

    rsm_tsk irsm_tsk frsm_tsk ifrsm_tsk ER ercd = rsm_tsk( ID tskid ); ER ercd = irsm_tsk( ID tskid ); ER ercd = frsm_tsk( ID tskid ); ER ercd = ifrsm_tsk( ID tskid ); tskid ercd .include mr100.inc rsm_tsk TSKID irsm_tsk TSKID frsm_tsk TSKID ifrsm_tsk TSKID TSKID...
  • Page 113 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task1() if( rsm_tsk( ID_main ) != E_OK ) printf(“Can’t resume main()\n”); if(frsm_tsk( ID_task2 ) != E_OK ) printf(“Can’t forced resume task2()\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task:...
  • Page 114 dly_tsk ER ercd = dly_tsk(RELTIM dlytim); RELTIM dlytim ercd .include mr100.inc dly_tsk RELTIM RELTIM Delay time Register name Content after service call is issued Error code R6R4 Delay time E_RLWAI This service call temporarily stops execution of the issuing task itself for a duration of time specified by dlytim to place the task from RUNNING state into WAITING state.
  • Page 115 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( dly_tsk() != E_OK ) error(“Forced wakeup\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSHM R6R4 dly_tsk #500 - 99 -...
  • Page 116: Table 5.5 Specifications Of The Semaphore Function

    5.3 Synchronization & Communication Function (Semaphore) Specifications of the semaphore function of MR100 are listed in Table 5.5. Table 5.5 Specifications of the Semaphore Function Semaphore ID Maximum number of resources Semaphore attribute Table 5.6 List of Semaphore Function Service Call Service Call sig_sem [S][B]...
  • Page 117: Sig_Sem Release Semaphore Resource

    sig_sem isig_sem ER ercd = sig_sem( ID semid ); ER ercd = isig_sem( ID semid ); semid ercd .include mr100.inc sig_sem SEMID isig_sem SEMID SEMID Semaphore ID number to which returned Register name Content after service call is issued Error code Semaphore ID number to which returned E_QOVR This service call releases one resource to the semaphore indicated by semid.
  • Page 118 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( sig_sem( ID_sem ) == E_QOVR ) error(“Overflow\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W sig_sem #ID_SEM2 - 102 -...
  • Page 119 wai_sem pol_sem ipol_sem twai_sem ER ercd = wai_sem( ID semid ); ER ercd = pol_sem( ID semid ); ER ercd = ipol_sem( ID semid ); ER ercd = twai_sem( ID semid, TMO tmout ); semid tmout ercd .include mr100.inc wai_sem SEMID pol_sem SEMID ipol_sem SEMID twai_sem SEMID,TMO...
  • Page 120 This service call acquires one semaphore resource from the semaphore indicated by semid. If the semaphore resource count is equal to or greater than 1, the semaphore resource count is decremented by 1, and the service call issuing task continues execution. On the other hand, if the semaphore count value is 0, the wai_sem or twai_sem service call invoking task is enqueued in a waiting queue for that semaphore.
  • Page 121 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() if( wai_sem( ID_sem ) != E_OK ) printf(“Forced wakeup\n”); if( pol_sem( ID_sem ) != E_OK ) printf(“Timeout\n”); if( twai_sem( ID_sem, 10 ) != E_OK ) printf(“Forced wakeup or Timeout”n”); <<Example statement in assembly language>>...
  • Page 122: Ref_Sem Reference Semaphore Status

    ref_sem iref_sem ER ercd = ref_sem( ID semid, T_RSEM *pk_rsem ); ER ercd = iref_sem( ID semid, T_RSEM *pk_rsem ); semid T_RSEM *pk_rsem ercd T_RSEM *pk_rsem Contents of pk_rsem typedef struct t_rsem{ wtskid UINT semcnt } T_RSEM; .include mr100.inc ref_sem SEMID, PK_RSEM iref_sem SEMID, PK_RSEM SEMID ID number of the target semaphore...
  • Page 123 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RSEM rsem; ER ercd; ercd = ref_sem( ID_sem1, &rsem ); <<Example statement in assembly language>> _ refsem: .blkb .include mr100.inc .GLB task task: PUSH.W PUSH.L ref_sem #ID_SEM1,#_refsem - 107 -...
  • Page 124: Table 5.7 Specifications Of The Eventflag Function

    5.4 Synchronization & Communication Function (Eventflag) Specifications of the eventflag function of MR100 are listed in Table 5.7. Table 5.7 Specifications of the Eventflag Function Item Event0flag ID Number of bits comprising eventflag Eventflag attribute Table 5.8 List of Eventflag Function Service Call Service Call set_flg [S][B]...
  • Page 125: Set_Flg Set Eventflag

    set_flg iset_flg ER ercd = set_flg( ID flgid, FLGPTN setptn ); ER ercd = iset_flg( ID flgid, FLGPTN setptn ); flgid FLGPTN setptn ercd .include mr100.inc set_flg FLGID,SETPTN iset_flg FLGID,SETPTN FLGID ID number of the eventflag to be set SETPTN Bit pattern to be set Register name Content after service call is issued...
  • Page 126 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task(void) set_flg( ID_flg,(FLGPTN)0xff000000 ); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W PUSH.L set_flg #ID_FLG3,#0ff000000H - 110 -...
  • Page 127 clr_flg iclr_flg ER ercd = clr_flg( ID flgid, FLGPTN clrptn ); ER ercd = iclr_flg( ID flgid, FLGPTN clrptn ); flgid FLGPTN clrptn ercd .include mr100.inc clr_flg FLGID,CLRPTN iclr_flg FLGID,CLRPTN FLGID ID number of the eventflag to be cleared CLRPTN Bit pattern to be cleared Register name Content after service call is issued...
  • Page 128 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task(void) clr_flg( ID_flg,(FLGPTN) 0xf0f0f0f0); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W PUSH.L clr_flg #ID_FLG1,#0f0f0f0f0H - 112 -...
  • Page 129 wai_flg pol_flg ipol_flg twai_flg ER ercd = wai_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn ); ER ercd = pol_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn ); ER ercd = ipol_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn ); ER ercd = twai_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn, flgid FLGPTN...
  • Page 130 E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out E_ILUSE Service call improperly used (Tasks present waiting for TA_WSGL attribute eventflag) This service call waits until the eventflag indicated by flgid has its bits specified by waiptn set according to task-awaking conditions indicated by wfmode.
  • Page 131 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() UINT flgptn; if(wai_flg(ID_flg2, (FLGPTN)0x00000ff0, TWF_ANDW, &flgptn)!=E_OK) error(“Wait Released\n”); if(pol_flg(ID_flg2, (FLGPTN)0x00000ff0, TWF_ORW, &flgptn)!=E_OK) printf(“Not set EventFlag\n”); if( twai_flg(ID_flg2, (FLGPTN)0x00000ff0, TWF_ANDW, &flgptn, 5) != E_OK ) error(“Wait Released\n”); <<Example statement in assembly language>> .include mr100.inc .GLB task...
  • Page 132: Ref_Flg Reference Eventflag Status

    ref_flg iref_flg ER ercd = ref_flg( ID flgid, T_RFLG *pk_rflg ); ER ercd = iref_flg( ID flgid, T_RFLG *pk_rflg ); flgid T_RFLG *pk_rflg ercd T_RFLG *pk_rflg Contents of pk_rflg typedef struct t_rflg{ wtskid FLGPTN flgptn } T_RFLG; .include mr100.inc ref_flg FLGID, PK_RFLG iref_flg FLGID, PK_RFLG FLGID...
  • Page 133 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RFLG rflg; ER ercd; ercd = ref_flg( ID_FLG1, &rflg ); <<Example statement in assembly language>> _ refflg: .blkb .include mr100.inc .GLB task task: PUSH.W PUSH.L ref_flg #ID_FLG1,#_refflg - 117 -...
  • Page 134: Table 5.9 Specifications Of The Data Queue Function

    5.5 Synchronization & Communication Function (Data Queue) Specifications of the data queue function of MR100 are listed in Table 5.9. Table 5.9 Specifications of the Data Queue Function Item Data queue ID Capacity (data bytes) in data queue area Data size Data queue attribute Table 5.10 List of Dataqueue Function Service Call Service Call...
  • Page 135 snd_dtq psnd_dtq ipsnd_dtq tsnd_dtq fsnd_dtq ifsnd_dtq ER ercd = snd_dtq( ID dtqid, VP_INT data ); ER ercd = psnd_dtq( ID dtqid, VP_INT data ); ER ercd = ipsnd_dtq( ID dtqid, VP_INT data ); ER ercd = tsnd_dtq( ID dtqid, VP_INT data, TMO tmout ); ER ercd = fsnd_dtq( ID dtqid, VP_INT data );...
  • Page 136 E_RLWAI E_TMOUT E_ILUSE EV_RST This service call sends the 4-byte data indicated by data to the data queue indicated by dtqid. If any task is kept waiting for reception in the target data queue, the data is not stored in the data queue and instead sent to the task at the top of the recep- tion waiting queue, with which the task is released from the reception wait state.
  • Page 137 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” VP_INT data[10]; void task(void) if( snd_dtq( ID_dtq, data[0]) == E_RLWAI ){ error(“Forced released\n”); if( psnd_dtq( ID_dtq, data[1])== E_TMOUT ){ error(“Timeout\n”); if( tsnd_dtq( ID_dtq, data[2], 10 ) != E_ TMOUT ){ error(“Timeout \n”);...
  • Page 138 rcv_dtq Receive from data queue prcv_dtq Receive from data queue (polling) iprcv_dtq Receive from data queue (polling, handler only) trcv_dtq Receive from data queue (with timeout) ER ercd = rcv_dtq( ID dtqid, VP_INT *p_data ); ER ercd = prcv_dtq( ID dtqid, VP_INT *p_data ); ER ercd = iprcv_dtq( ID dtqid, VP_INT *p_data );...
  • Page 139 This service call receives data from the data queue indicated by dtqid and stores the received data in the area pointed to by p_data. If data is present in the target data queue, the data at the top of the queue or the oldest data is received. This results in creating a free space in the data queue area, so that a task enqueued in a transmission waiting queue is released from WAITING state, and starts sending data to the data queue area.
  • Page 140 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” VP_INT data; if( rcv_dtq( ID_dtq, &data ) != E_RLWAI ) error(“forced wakeup\n”); if( prcv_dtq( ID_dtq, &data ) != E_TMOUT ) error(“Timeout\n”); if( trcv_dtq( ID_dtq, &data, 10 ) != E_TMOUT ) error(“Timeout \n”);...
  • Page 141: Ref_Dtq Reference Data Queue Status

    ref_dtq iref_dtq ER ercd = ref_dtq( ID dtqid, T_RDTQ *pk_rdtq ); ER ercd = iref_dtq( ID dtqid, T_RDTQ *pk_rdtq ); dtqid T_RDTQ *pk_rdtq ercd T_RDTQ *pk_rdtq Contents of pk_rdtq typedef struct t_rdtq{ stskid wtskid UINT sdtqcnt } T_RDTQ; .include mr100.inc ref_dtq DTQID, PK_RDTQ iref_dtq DTQID, PK_RDTQ...
  • Page 142 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RDTQ rdtq; ER ercd; ercd = ref_dtq( ID_DTQ1, &rdtq ); <<Example statement in assembly language>> _ refdtq: .blkb .include mr100.inc .GLB task task: PUSH.W PUSH.L ref_dtq #ID_DTQ1,#_refdtq - 126 -...
  • Page 143: Table 5.11 Specifications Of The Mailbox Function

    5.6 Synchronization & Communication Function (Mailbox) Specifications of the mailbox function of MR100 are listed in Table 5.11. Table 5.11 Specifications of the Mailbox Function Item Mailbox ID Mailbox priority Mailbox attribute Table 5.12 List of Mailbox Function Service Call Service Call snd_mbx [S][B]...
  • Page 144: Snd_Mbx Send To Mailbox

    snd_mbx isnd_mbx ER ercd = snd_mbx( ID mbxid, T_MSG *pk_msg ); ER ercd = isnd_mbx( ID mbxid, T_MSG *pk_msg ); mbxid T_MSG *pk_msg ercd .include mr100.inc snd_mbx MBXID,PK_MBX isnd_mbx MBXID,PK_MBX MBXID ID number of the mailbox to which transmitted PK_MBX Message to be transmitted (address) Register name Content after service call is issued...
  • Page 145 <<Example format of a message>> typedef struct user_msg{ T_MSG t_msg; data[16]; } USER_MSG; <<Example format of a message with priority included>> typedef struct user_msg{ T_MSG_PRI } USER_MSG; <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” typedef struct pri_message T_MSG_PRI msgheader;...
  • Page 146 rcv_mbx Receive from mailbox prcv_mbx Receive from mailbox (polling) iprcv_mbx Receive from mailbox (polling, handler only) trcv_mbx Receive from mailbox (with timeout) ER ercd = rcv_mbx( ID mbxid, T_MSG **ppk_msg ); ER ercd = prcv_mbx( ID mbxid, T_MSG **ppk_msg ); ER ercd = iprcv_mbx( ID mbxid, T_MSG **ppk_msg );...
  • Page 147 This service call receives a message from the mailbox indicated by mbxid and stores the start address of the received mes- sage in the area pointed to by ppk_msg. T_MSG** should be specified with a 32-bit address. If data is present in the tar- get mailbox, the data at the top of the mailbox is received.
  • Page 148 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” typedef struct fifo_message T_MSG head; char body[12]; } FIFO_MSG; void task() FIFO_MSG *msg; if( rcv_mbx((T_MSG **)&msg, ID_mbx) == E_RLWAI ) error(“forced wakeup\n”); if( prcv_mbx((T_MSG **)&msg, ID_mbx) != E_TMOUT ) error(“Timeout\n”);...
  • Page 149: Ref_Mbx Reference Mailbox Status

    ref_mbx iref_mbx ER ercd = ref_mbx( ID mbxid, T_RMBX *pk_rmbx ); ER ercd = iref_mbx( ID mbxid, T_RMBX *pk_rmbx ); mbxid T_RMBX *pk_rmbx ercd T_RMBX *pk_rmbx Contents of pk_rmbx typedef struct t_rmbx{ wtskid T_MSG *pk_msg } T_RMBX; .include mr100.inc ref_mbx MBXID, PK_RMBX iref_mbx MBXID, PK_RMBX MBXID...
  • Page 150 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RMBX rmbx; ER ercd; ercd = ref_mbx( ID_MBX1, &rmbx ); <<Example statement in assembly language>> .include mr100.inc .GLB task _ refmbx: .blkb task: PUSH.W PUSH.L ref_mbx #ID_MBX1,#_refmbx - 134 -...
  • Page 151: Table 5.13 Specifications Of The Fixed-Size Memory Pool Function

    5.7 Memory Pool Management Function (Fixed-size Memory Pool) Specifications of the fixed-size memory pool function of MR100 are listed in Table 5.13. The memory pool area to be acquired can be specified by a section name for each memory pool during configuration. Table 5.13 Specifications of the Fixed-size memory pool Function Item Fixed-size memory pool ID...
  • Page 152: Get_Mpf Aquire Fixed-Size Memory Block

    get_mpf pget_mpf ipget_mpf tget_mpf ER ercd = get_mpf( ID mpfid, VP *p_blk ); ER ercd = pget_mpf( ID mpfid, VP *p_blk ); ER ercd = ipget_mpf( ID mpfid, VP *p_blk ); ER ercd = tget_mpf( ID mpfid, VP *p_blk,TMO tmout ); mpfid *p_blk tmout...
  • Page 153 get_mpf,pget_mpf,ipget_mpf Register name Content after service call is issued Error code R3R1 Start address of the acquired memory block ID number of the target fixed-size memory pool to be acquired tget_mpf Register name Content after service call is issued Error code R3R1 Start address of the acquired memory block ID number of the target fixed-size memory pool to be acquired...
  • Page 154 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” p_blk; void task() if( get_mpf(ID_mpf ,&p_blk) != E_OK ){ error(“Not enough memory\n”); if( pget_mpf(ID_mpf ,&p_blk) != E_OK ){ error(“Not enough memory\n”); if( tget_mpf(ID_mpf ,&p_blk, 10) != E_OK ){ error(“Not enough memory\n”); <<Example statement in assembly language>>...
  • Page 155: Rel_Mpf Release Fixed-Size Memory Block

    rel_mpf irel_mpf ER ercd = rel_mpf( ID mpfid, VP blk ); ER ercd = irel_mpf( ID mpfid, VP blk); mpfid ercd .include mr100.inc rel_mpf MPFID,BLK irel_mpf MPFID,BLK MPFID ID number of the fixed-size memory pool to be released Start address of the memory block to be returned Register name Content after service call is issued Error code...
  • Page 156 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() p_blf; if( get_mpf(ID_mpf1,&p_blf) != E_OK ) error(“Not enough memory \n”); rel_mpf(ID_mpf1,p_blf); <<Example statement in assembly language>> .include mr100.inc .GLB task _g_blk: .blkb 4 task: PUSH.W get_mpf #ID_MPF1 MOV.L R3R1,_g_blk PUSH.W...
  • Page 157 ref_mpf iref_mpf ER ercd = ref_mpf( ID mpfid, T_RMPF *pk_rmpf ); ER ercd = iref_mpf( ID mpfid, T_RMPF *pk_rmpf ); mpfid T_RMPF *pk_rmpf ercd T_RMPF *pk_rmpf Contents of pk_rmpf typedef struct t_rmpf{ wtskid UINT fblkcnt } T_RMPF; .include mr100.inc ref_mpf MPFID,PK_RMPF iref_mpf MPFID,PK_RMPF MPFID...
  • Page 158 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RMPF rmpf; ER ercd; ercd = ref_mpf( ID_MPF1, &rmpf ); <<Example statement in assembly language>> .include mr100.inc .GLB task _ refmpf: .blkb task: PUSH.W PUSH.L ref_mpf #ID_MPF1,#_refmpf - 142 -...
  • Page 159: Table 5.15 Specifications Of The Variable-Size Memory Pool Function

    5.8 Memory Pool Management Function (Variable-size Memory Pool) Specifications of the Variable-size Memory pool function of MR100 are listed in Table 5.15. The memory pool area to be acquired can be specified by a section name for each memory pool during configuration. Table 5.15 Specifications of the Variable-size memory Pool Function Item Variable-size memory pool ID...
  • Page 160 pget_mpl ER ercd = pget_mpl( ID mplid, UINT blksz, VP *p_blk ); mplid UINT blksz *p_blk ercd *p_blk .include mr100.inc pget_mpl MPLID,BLKSZ MPLID ID number of the target Variable-size Memory pool to be acquired BLKSZ Memory size to be acquired (in bytes) Register name Content after service call is issued Error code...
  • Page 161 This service call acquires a memory block from the variable-size memory pool indicated by mplid and stores the start address of the acquired memory block in the variable p_blk. The content of the acquired memory block is in- determinate. If the specified variable-size memory pool has no memory blocks in it, the task returns immediately and responds to the call with the error code E_TMOUT.
  • Page 162 rel_mpl ER ercd = rel_mpl( ID mplid, VP blk ); mplid ID number of Variable-size Memory pool of the memory block to be released Start address of the memory block to be returned ercd .include mr100.inc rel_mpl MPLID,BLK MPLID ID number of Variable-size Memory pool of the memory block to be released Start address of the memory block to be returned Register name Content after service call is issued...
  • Page 163 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() p_blk; if( get_mpl(ID_mpl1, 200, &p_blk) != E_OK ) error(“Not enough memory \n”); rel_mpl(ID_mp1,p_blk); <<Example statement in assembly language>> .include mr100.inc .GLB task _g_blk: .blkb 4 task: PUSH.W pget_mpl #ID_MPL1,#200 MOV.L...
  • Page 164: Ref_Mpl Reference Variable-Size Memory Pool Status

    ref_mpl Reference variable-size memory pool status iref_mpl Reference variable-size memory pool status ER ercd = ref_mpl( ID mplid, T_RMPL *pk_rmpl ); ER ercd = iref_mpl( ID mplid, T_RMPL *pk_rmpl ); mplid T_RMPL *pk_rmpl ercd T_RMPL *pk_rmpl Contents of pk_rmpl typedef struct t_rmpl{ wtskid...
  • Page 165 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RMPL rmpl; ER ercd; ercd = ref_mpl( ID_MPL1, &rmpl ); <<Example statement in assembly language>> .include mr100.inc .GLB task _ refmpl: .blkb task: PUSH.W PUSH.L ref_mpl #ID_MPL1,_refmpl - 149 -...
  • Page 166: Table 5.17 Specifications Of The Time Management Function

    5.9 Time Management Function Specifications of the time management function of MR100 are listed in Table 5.17. Table 5.17 Specifications of the Time Management Function System time value Unit of system time value System time updating cycle Initial value of system time (at initial startup) Table 5.18 List of Time Management Function Service Call Service Call get_tim...
  • Page 167: Set_Tim Set System Time

    set_tim iset_tim ER ercd = set_tim( SYSTIM *p_systim ); ER ercd = iset_tim( SYSTIM *p_systim ); SYSTIM *p_systim Contents of p_systim typedef struct t_systim { utime ltime } SYSTIM; ercd .include mr100.inc set_tim PK_TIM iset_tim PK_TIM PK_TIM Pointer to the packet that indicates the system time to be set Register name Content after service call is issued Error code...
  • Page 168 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() SYSTIME time; time.utime = 0; time.ltime = 0; set_tim( &time ); <<Example statement in assembly language>> .include mr100.inc .GLB task _g_systim: .WORD 1111H .LWORD 22223333H task: PUSHM set_tim #_g_systim /* Time data storing variable */ /* Sets upper time data */...
  • Page 169: Get_Tim Reference System Time

    get_tim iget_tim ER ercd = get_tim( SYSTIM *p_systim ); ER ercd = iget_tim( SYSTIM *p_systim ); SYSTIM *p_systim ercd SYSTIM *p_systim Contents of p_systim typedef struct t_systim { utime ltime } SYSTIM; .include mr100.inc get_tim PK_TIM iget_tim PK_TIM PK_TIM Pointer to the packet to which current system time is returned Register name Content after service call is issued Error code...
  • Page 170 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() SYSTIME time; get_tim( &time ); <<Example statement in assembly language>> .include mr100.inc .GLB task _g_systim: .blkb task: PUSHM get_tim #_g_systim /* Time data storing variable */ /* Refers to the system time */ - 154 -...
  • Page 171 isig_tim This service call updates the system time. The isig_tim is automatically started every tick_time interval(ms) if the system clock is defined by the configuration file. The application cannot call this function because it is not implementing as service call. When a time tick is supplied, the kernel is processed as follows: (1) Updates the system time (2) Starts an alarm handler...
  • Page 172: Table 5.19 Specifications Of The Cyclic Handler Function

    5.10 Time Management Function (Cyclic Handler) Specifications of the cyclic handler function of MR100 are listed in Table 5.19. The cyclic handler description languages in item No. 4 are those specified in the GUI configurator. They are not output to a configuration file, nor are the MR100 ker- nel concerned with them.
  • Page 173: Sta_Cyc Start Cyclic Handler Operation

    sta_cyc ista_cyc ER ercd = sta_cyc( ID cycid ); ER ercd = ista_cyc( ID cycid ); cycid ercd .include mr100.inc sta_cyc CYCNO ista_cyc CYCNO CYCNO ID number of the cyclic handler to be operated Register name Content after service call is issued Error code ID number of the cyclic handler to be operated None...
  • Page 174 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() sta_cyc ( ID_cyc1 ); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W sta_cyc #ID_CYC1 - 158 -...
  • Page 175 stp_cyc istp_cyc ER ercd = stp_cyc( ID cycid ); ER ercd = istp_cyc( ID cycid ); cycid ercd .include mr100.inc stp_cyc CYCNO istp_cyc CYCNO CYCNO ID number of the cyclic handler to be stopped Register name Content after service call is issued Error code ID number of the cyclic handler to be stopped None...
  • Page 176: Ref_Cyc Reference Cyclic Handler Status

    ref_cyc iref_cyc ER ercd = ref_cyc( ID cycid, T_RCYC *pk_rcyc ); ER ercd = iref_cyc( ID cycid, T_RCYC *pk_rcyc ); cycid T_RCYC *pk_rcyc ercd T_RCYC *pk_rcyc Contents of pk_rcyc typedef struct t_rcyc{ STAT cycstat RELTIM lefttim } T_RCYC; .include mr100.inc ref_cyc ID,PK_RCYC iref_cyc ID,PK_RCYC...
  • Page 177 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RCYC rcyc; ER ercd; ercd = ref_cyc( ID_CYC1, &rcyc ); <<Example statement in assembly language>> .include mr100.inc .GLB task _ refcyc: .blkb task: PUSH.W PUSH.L ref_cyc #ID_CYC1,#_refcyc - 161 -...
  • Page 178: Table 5.21 Specifications Of The Alarm Handler Function

    5.11 Time Management Function (Alarm Handler) Specifications of the alarm handler function of MR100 are listed in Table 5.21. The alarm handler description languages in item No. 4 are those specified in the GUI configurator. They are not output to a configuration file, nor are the MR100 ker- nel concerned with them.
  • Page 179: Sta_Alm Start Alarm Handler Operation

    sta_alm ista_alm ER ercd = sta_alm( ID almid, RELTIM almtim ); ER ercd = ista_alm( ID almid, RELTIM almtim ); almid RELTIM almtim ercd .include mr100.inc sta_alm ALMID,ALMTIM ista_alm ALMID,ALMTIM ALMID ID number of the alarm handler to be operated ALMTIM Alarm handler startup time (relative time) Register name...
  • Page 180 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() sta_alm ( ID_alm1,100 ); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W PUSHM R6R4 sta_alm #ID_ALM1,#100 - 164 -...
  • Page 181 stp_alm istp_alm ER ercd = stp_alm( ID almid ); ER ercd = istp_alm( ID almid ); almid ercd .include mr100.inc stp_alm ALMID istp_alm ALMID ALMID ID number of the alarm handler to be stopped Register name Content after service call is issued Error code ID number of the alarm handler to be stopped None...
  • Page 182: Ref_Alm Reference Alarm Handler Status

    ref_alm iref_alm ER ercd = ref_alm( ID almid, T_RALM *pk_ralm ); ER ercd = iref_alm( ID almid, T_RALM *pk_ralm ); almid T_RALM *pk_ralm ercd T_RALM *pk_ralm Contents of pk_ralm typedef struct t_ralm{ STAT almstat RELTIM lefttim } T_RALM; .include mr100.inc ref_alm ALMID,PK_RALM iref_alm ALMID,PK_RALM...
  • Page 183 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() T_RALM ralm; ER ercd; ercd = ref_alm( ID_ALM1, &ralm ); <<Example statement in assembly language>> .include mr100.inc .GLB task _ refalm: .blkb task: PUSH.W PUSH.L ref_alm #ID_ALM1,#_refalm - 167 -...
  • Page 184: Table 5.23 List Of System Status Management Function Service Call

    5.12 System Status Management Function Table 5.23 List of System Status Management Function Service Call Service Call rot_rdq [S][B] irot_rdq [S][B] get_tid [S][B] iget_tid loc_cpu [S][B] iloc_cpu unl_cpu [S][B] iunl_cpu dis_dsp [S][B] ena_dsp [S][B] sns_ctx sns_loc sns_dsp sns_dpn Notes: • [S]: Standard profile service calls [B]: Basic profile service calls •...
  • Page 185 rot_rdq irot_rdq ER ercd = rot_rdq( PRI tskpri ); ER ercd = irot_rdq( PRI tskpri ); tskpri ercd .include mr100.inc rot_rdq TSKPRI irot_rdq TSKPRI TSKPRI Task priority to be rotated Register name Content after service call is issued Error code Task priority to be rotated None Rotate task precedence...
  • Page 186 This service call rotates the ready queue whose priority is indicated by tskpri. In other words, it relocates the task enqueued at the top of the ready queue of the specified priority by linking it to behind the tail of the ready queue, thereby switching over the executed tasks that have the same priority.
  • Page 187: Get_Tid Reference Task Id In The Running State

    get_tid iget_tid ER ercd = get_tid( ID *p_tskid ); ER ercd = iget_tid( ID *p_tskid ); *p_tskid ercd *p_tskid .include mr100.inc get_tid iget_tid None Register name Content after service call is issued Error code Acquired task ID None This service call returns the task ID currently in RUNNING state to the area pointed to by p_tskid. If this service call is issued from a task, the ID number of the issuing task is returned.
  • Page 188: Loc_Cpu Lock The Cpu

    loc_cpu iloc_cpu ER ercd = loc_cpu(); ER ercd = iloc_cpu(); None ercd .include mr100.inc loc_cpu iloc_cpu None Register name Content after service call is issued Error code None This service call places the system into a CPU locked state, thereby disabling interrupts and task dispatches. The features of a CPU locked state are outlined below.
  • Page 189: Loc_Cpu

    <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() loc_cpu(); <<Example statement in assembly language>> .include mr100.inc .GLB task task: loc_cpu - 173 -...
  • Page 190: Er Ercd Terminated Normally (E_Ok)

    unl_cpu iunl_cpu ER ercd = unl_cpu(); ER ercd = iunl_cpu(); None ercd .include mr100.inc unl_cpu iunl_cpu None Register name Content after service call is issued Error code None This service call frees the system from a CPU locked state that was set by the loc_cpu or iloc_cpu service call. If the unl_cpu service call is issued from a dispatching enabled state, task scheduling is performed.
  • Page 191 dis_dsp ER ercd = dis_dsp(); None ercd .include mr100.inc dis_dsp None Register name Content after service call is issued Error code None This service call places the system into a dispatching disabled state. The features of a dispatching disabled state are outlined below.
  • Page 192 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() dis_dsp(); <<Example statement in assembly language>> .include mr100.inc .GLB task task: dis_dsp - 176 -...
  • Page 193: Ena_Dsp Enables Dispatching

    ena_dsp ER ercd = ena_dsp(); None ercd .include mr100.inc ena_dsp None Register name Content after service call is issued Error code None This service call frees the system from a dispatching disabled state that was set by the dis_dsp service call. As a result, task scheduling is resumed when the system has entered a task execution state.
  • Page 194: Sns_Ctx

    sns_ctx BOOL state = sns_ctx(); None BOOL state .include mr100.inc sns_ctx None Register name Content after service call is issued TRUE:Non-Task context FALSE: Task context None This service call returns TRUE when it is invoked from non-task context, or returns FALSE when invoked from task con- text.
  • Page 195: Sns_Loc

    sns_loc BOOL state = sns_loc(); None BOOL state .include mr100.inc sns_loc None Register name Content after service call is issued TRUE: CPU locked state FALSE:CPUCPU unlocked state None This service call returns TRUE when the system is in a CPU locked state, or returns FALSE when the system is in a CPU unlocked state.
  • Page 196: Sns_Dsp

    sns_dsp BOOL state = sns_dsp(); None BOOL state .include mr100.inc sns_dsp None Register name Content after service call is issued TRUE: Dispatching disabled state FALSE: Dispatching enabled state None This service call returns TRUE when the system is in a dispatching disabled state, or returns FALSE when the system is in a dispatching enabled state.
  • Page 197: Sns_Dpn

    sns_dpn BOOL state = sns_dpn(); None BOOL state .include mr100.inc sns_dpn None Register name Content after service call is issued TRUE: Dispatching pending state FALSE: Not dispatching pending state None This service call returns TRUE when the system is in a dispatching pending state, or returns FALSE when the system is not in a dispatching pending state.
  • Page 198: Table 5.24 List Of Interrupt Management Function Service Call

    5.13 Interrupt Management Function Table 5.24 List of Interrupt Management Function Service Call Service Call ret_int Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a following meaning. ♦...
  • Page 199 ret_int This service call cannot be written in C language. .include mr100.inc ret_int None Not return to the interrupt handler that issued this service call. This service call performs the processing necessary to return from an interrupt handler. Depending on return processing, it activates the scheduler to switch tasks from one to another.
  • Page 200: Table 5.25 List Of System Configuration Management Function Service Call

    5.14 System Configuration Management Function Table 5.25 List of System Configuration Management Function Service Call Service Call ref_ver iref_ver Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a following meaning. ♦...
  • Page 201 ref_ver iref_ver ER ercd = ref_ver( T_RVER *pk_rver ); ER ercd = iref_ver( T_RVER *pk_rver ); T_RVER *pk_rver Contents of pk_rver typedef struct t_rver { maker prid spver prver prno[4] } T_RVER; ercd .include mr100.inc ref_ver PK_VER iref_ver PK_VER PK_VER Pointer to the packet to which version information is returned Register name Content after service call is issued...
  • Page 202 This service call reads out information about the version of the currently executing kernel and returns the result to the area pointed to by pk_rver. The following information is returned to the packet pointed to by pk_rver. maker The code H’0115 denoting Renesas Technology Corporation is returned. prid The internal identification code IDH’0014 of the M3T-MR100 is returned. spver The code H’5403 denoting that the kernel is compliant with µITRON Specification Ver 4.03.00 is returned.
  • Page 203: Table 5.26 Specifications Of The Short Data Queue Function

    5.15 Extended Function (Short Data Queue) Specifications of the Short data queue function of MR100 are listed in Table 5.26. This function is outside the scope of µITRON 4.0 Specification. Table 5.26 Specifications of the Short Data Queue Function Item Data queue ID Capacity (data bytes) in data queue area Data size...
  • Page 204 vsnd_dtq vpsnd_dtq vipsnd_dtq vtsnd_dtq vfsnd_dtq vifsnd_dtq ER ercd = vsnd_dtq( ID vdtqid, H data ); ER ercd = vpsnd_dtq( ID vdtqid, H data ); ER ercd = vipsnd_dtq( ID vdtqid, H data ); ER ercd = vtsnd_dtq( ID vdtqid, H data, TMO tmout ); ER ercd = vfsnd_dtq( ID vdtqid, H data );...
  • Page 205 E_RLWAI E_TMOUT E_ILUSE EV_RST This service call sends the signed 2-byte data indicated by data to the Short data queue indicated by vdtqid. If any task is kept waiting for reception in the target Short data queue, the data is not stored in the Short data queue and instead sent to the task at the top of the reception waiting queue, with which the task is released from the reception wait state.
  • Page 206 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” H data[10]; void task(void) if( vsnd_dtq( ID_dtq, data[0]) == E_RLWAI ){ error(“Forced released\n”); if( vpsnd_dtq( ID_dtq, data[1])== E_TMOUT ){ error(“Timeout\n”); if( vtsnd_dtq( ID_dtq, data[2], 10 ) != E_ TMOUT ){ error(“Timeout \n”);...
  • Page 207 vrcv_dtq Receive from Short data queue vprcv_dtq Receive from Short data queue (polling) viprcv_dtq Receive from Short data queue (polling,handler only) vtrcv_dtq Receive from Short data queue (with timeout) ER ercd = vrcv_dtq( ID dtqid, H *p_data ); ER ercd = vprcv_dtq( ID dtqid, H *p_data ); ER ercd = viprcv_dtq( ID dtqid, H *p_data );...
  • Page 208 This service call receives data from the Short data queue indicated by vdtqid and stores the received data in the area pointed to by p_data. If data is present in the target Short data queue, the data at the top of the queue or the oldest data is received. This results in creating a free space in the Short data queue area, so that a task enqueued in a transmission waiting queue is released from WAITING state, and starts sending data to the Short data queue area.
  • Page 209 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task() H data; if( vrcv_dtq( ID_dtq, &data ) != E_RLWAI ) error(“forced wakeup\n”); if( vprcv_dtq( ID_dtq, &data ) != E_TMOUT ) error(“Timeout\n”); if( vtrcv_dtq( ID_dtq, &data, 10 ) != E_TMOUT ) error(“Timeout\n”);...
  • Page 210 vref_dtq Reference Short data queue status viref_dtq Reference Short data queue status (handler only) ER ercd = vref_dtq( ID vdtqid, T_RDTQ *pk_rdtq ); ER ercd = viref_dtq( ID vdtqid, T_RDTQ *pk_rdtq ); vdtqid T_RDTQ *pk_rdtq ercd T_RDTQ *pk_rdtq Contents of pk_rdtq typedef struct t_rdtq{...
  • Page 211 This service call returns various statuses of the Short data queue indicated by vdtqid. stskid Returned to stskid is the ID number of the task at the top of a transmission waiting queue (the next task to be de- queued). If no tasks are kept waiting, TSK_NONE is returned. wtskid Returned to wtskid is the ID number of the task at the top of a reception waiting queue (the next task to be de- queued).
  • Page 212: Table 5.28 List Of Reset Function Service Call

    5.16 Extended Function (Reset Function) This function initializes the content of an object. This function is outside the scope of µITRON 4.0 Specification. Service Call vrst_dtq Clear data queue area vrst_vdtq Clear Short data queue area vrst_mbx Clear mailbox area vrst_mpf Clear fixed-size memory pool area vrst_mpl...
  • Page 213 vrst_dtq ER ercd = vrst_dtq( ID dtqid ); dtqid ercd .include mr100.inc vrst_dtq DTQID DTQID Data queue ID to be cleared Register name Content after service call is issued Error code Data queue ID to be cleared None This service call clears the data stored in the data queue indicated by dtqid. If the data queue area has no more areas to be added and tasks are enqueued in a data transmission waiting queue, all of the tasks enqueued in the data transmission wait- ing queue are released from WAITING state.
  • Page 214 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task1(void) vrst_dtq( ID_dtq1 ); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W vrst_dtq #ID_DTQ1 - 198 -...
  • Page 215 vrst_vdtq ER ercd = vrst_vdtq( ID vdtqid ); vdtqid ercd .include mr100.inc vrst_vdtq VDTQID VDTQID Short data queue ID to be cleared Register name Content after service call is issued Error code Short data queue ID to be cleared None This service call clears the data stored in the Short data queue indicated by vdtqid.
  • Page 216 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task1(void) vrst_vdtq( ID_vdtq1 ); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W vrst_vdtq #ID_VDTQ1 - 200 -...
  • Page 217 vrst_mbx ER ercd = vrst_mbx( ID mbxid ); mbxid ercd .include mr100.inc vrst_mbx MBXID MBXID Mailbox ID to be cleared Register name Content after service call is issued Error code Mailbox ID to be cleared None This service call clears the messages stored in the mailbox indicated by mbxid. This service call can be issued only from task context.
  • Page 218 <<Example statement in C language>> #include <itron.h> #include <kernel.h> #include “kernel_id.h” void task1(void) vrst_mbx( ID_mbx1 ); <<Example statement in assembly language>> .include mr100.inc .GLB task task: PUSH.W vrst_mbx #ID_MBX1 - 202 -...
  • Page 219 vrst_mpf ER ercd = vrst_mpf( ID mpfid ); mpfid ercd .include mr100.inc vrst_mpf MPFID MPFID Fixed-size memory pool ID to be cleared Register name Content after service call is issued Error code Fixed-size memory pool ID to be cleared None This service call initializes the fixed-size memory pool indicated by mpfid.
  • Page 220 vrst_mpl ER ercd = vrst_mpl( ID mplid ); mplid ercd .include mr100.inc vrst_mpl MPLID Variable-size memory pool ID to be cleared MPLID Register name Content after service call is issued Error code Variable-size memory pool ID to be cleared None This service call initializes the variable-size memory pool indicated by mplid.
  • Page 221: Applications Development Procedure Overview

    Applications Development Procedure Overview 6.1 Overview Application programs for MR100 should generally be developed following the procedure described below. 1. Generating a project When using HEW , create a new project using MR100 on HEW. 2. Coding the application program Write the application program in code form using C or assembly language.
  • Page 222: Figure 6.1 Mr100 System Generation Detail Flowchart

    C standard MR100 include file header file Application include file Application C source C compiler nc100 Relocatable Assembler as100 C standard Application object Library Linkage Editor ln100 Absolute module Load module converter lmc100 ROM write format Figure 6.1 MR100 System Generation Detail Flowchart Configuration file Configurator kernel.h...
  • Page 223: Development Procedure Example

    6.2 Development Procedure Example This chapter outlines the development procedures on the basis of a typical MR100 application example. 6.2.1 Applications Program Coding Figure 6.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.
  • Page 224: Configuration File Preparation

    #include <itron.h> #include <kernel.h> #include "kernel_id.h" void main() /* main task */ printf("LBP start simulation \n"); sta_tsk(ID_idle,1); sta_tsk(ID_image,1); sta_tsk(ID_printer,1); /* activate printer engine task */ void image() /* activate image expansion task */ while(1){ wai_flg(ID_pagein,waiptn,TWF_ANDW, &flgptn);/* wait for 1-page input */ printf("...
  • Page 225: System Generation

    (mr100.inc, kernel_id.h), and a system generation procedure description file (makefile) from the configuration file. A> cfg100 -v lbp.cfg MR100 system configurator V.1.00.18 Copyright 2003,2005 RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED. MR100 version ==> V.1.01 Release 01 A> 6.2.4 System generation Execute the make command to generate the system.
  • Page 226: Writing Rom

    A> make -f makefile as100 -F -Dtest=1 crt0mr.a30 nc100 -c task.c ln100 @ln100.sub A> 6.2.5 Writing ROM Using the lmc30 load module converter, convert the absolute module file into a ROM writable format and then write it into ROM. Or read the file into the debugger and debug it. Figure 6.5 System Generation - 210 -...
  • Page 227: Detailed Applications

    Detailed Applications 7.1 Program Coding Procedure in C Language 7.1.1 Task Description Procedure 1. Describe the task as a function. To register the task for the MR100, 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 entry_address...
  • Page 228: Writing A Kernel (Os Dependent) Interrupt Handler

    #include <itron.h> #include <kernel.h> #include "kernel_id.h" void task(void) Figure 7.2 Example Task Terminating with ext_tsk() Described in C Language 7. To specify a task, use the string written in the task definition item “name” of the configura- tion file. wup_tsk(ID_main); 8.
  • Page 229: Writing Non-Kernel Interrupt Handler

    1. Describe the kernel interrupt handler as a function 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 di- rectory as well as "kernel_id.h"...
  • Page 230: Figure 7.5 Example Cyclic Handler Written In C Language

    1. Describe the cyclic or alarm handler as a function. 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 di- rectory as well as "kernel_id.h"...
  • Page 231: Program Coding Procedure In Assembly Language

    7.2 Program Coding Procedure in Assembly Language This section describes how to write an application using the assembly language. 7.2.1 Writing Task This section describes how to write an application using the assembly language. 1. Be sure to include "mr100.inc" at the beginning of file. 2.
  • Page 232: Writing Kernel Interrupt Handler

    8. Set a task that is activated at MR100 system startup in the configuration file 7.2.2 Writing Kernel Interrupt Handler When describing the kernel interrupt handler in assembly language, observe the following precautions 1. At the beginning of file, be sure to include "mr100.inc" which is in the system directory. 2.
  • Page 233: Figure 7.10 Example Handler Written In Assembly Language

    1. At the beginning of file, be sure to include "mr100.inc" which is in the system directory. 2. For the symbol indicating the handler start address, make the external declaration. 3. Always use the RTS instruction (subroutine return instruction) to return from cyclic han- dlers and alarm handlers.
  • Page 234: Modifying Mr100 Startup Program

    7.3 Modifying MR100 Startup Program MR100 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"...
  • Page 235: C Language Startup Program (Crt0Mr.a30)

    Figure 7.11 shows the C language startup program(crt0mr.a30). 1 ; **************************************************************** MR100 start up program for C language COPYRIGHT(C) 2003,2006,2007 RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED MR100 8 ; **************************************************************** "$Id: crt0mr.a30 512 2007-07-09 10:11:36Z inui $"...
  • Page 236 75 ;-------------------------------------------------------- 76 ; bss zero clear 77 ;-------------------------------------------------------- ;-------------------------------------------------------; ; zero clear BSS ;-------------------------------------------------------; BZERO bss_SB8_top, bss_SB8 82 ; BZERO bss_SB16_top, bss_SB16 BZERO bss_NEAR_top, bss_NEAR BZERO bss_FAR_top, bss_FAR BZERO bss_EXT_top, bss_EXT BZERO bss_MON1_top, bss_MON1 BZERO bss_MON2_top, bss_MON2 BZERO bss_MON3_top, bss_MON3 BZERO bss_MON4_top, bss_MON4 91 ;--------------------------------------------------------...
  • Page 237 JSR.W __init_sem .ENDIF __NUM_DTQ .GLB __init_dtq JSR.W __init_dtq .ENDIF __NUM_VDTQ .GLB __init_vdtq JSR.W __init_vdtq .ENDIF __NUM_MBX .GLB __init_mbx JSR.W __init_mbx .ENDIF ALARM_HANDLER .GLB __init_alh JSR.W __init_alh .ENDIF CYCLIC_HANDLER .GLB __init_cyh JSR.W __init_cyh .ENDIF __NUM_MPF ; Fixed Memory Pool .GLB __init_mpf JSR.W __init_mpf .ENDIF...
  • Page 238: Figure 7.11 C Language Startup Program (Crt0Mr.a30)

    ; System timer interrupt handler _STMR_hdr ret_int 249 .ENDIF .END 253 ; **************************************************************** 254 ; COPYRIGHT(C) 2003,2007 RENESAS TECHNOLOGY CORPORATION 255 ; AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED ; **************************************************************** Figure 7.11 C Language Startup Program (crt0mr.a30) - 222 -...
  • Page 239 The following explains the content of the C language startup program (crt0mr.a30). 4. Incorporate a section definition file [14 in Figure 7.11] 5. Incorporate an include file for MR100 [15 in Figure 7.11] 6. Incorporate a system ROM area definition file [16 in Figure 7.11] 7.
  • Page 240: Memory Allocation

    7.4 Memory Allocation This section describes how memory is allocated for the application program data. Use the section file provided by MR100 to set memory allocation. MR100 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. •...
  • Page 241: Section Used By The Mr100

    7.4.1 Section used by the MR100 The sample section file for the C language is "asm_sec.inc". The sample section file for the assembly language is "asm_sec.inc". Edit these files if section reallocation is required. The following explains each section that is used by the MR100. •...
  • Page 243: Table 8.1 Numerical Value Entry Examples

    Using Configurator 8.1 Configuration File Creation Procedure When applications program coding and startup program modification are completed, it is then necessary to register the ap- plications program in the MR100 system. This registration is accomplished by the configuration file. 8.1.1 Configuration File Data Entry Format This chapter describes how the definition data are entered in the configuration file.
  • Page 244: Table 8.2 Operators

    It is also possible to enter operators in numerical values. Table 8.2 Operators lists the operators available. Operator (Unary_minus) ∗ (Binary_minus) Numerical value examples are presented below. • • 123 + 0x23 • (23/4 + 3) ∗ 2 • 100B + 0aH Symbol The symbols are indicated by a character string that consists of numerals, upper- and lower-case alphabetical let- ters, _(underscore), and ?, and begins with a non-numeric character.
  • Page 245: Configuration File Definition Items

    time can be entered using decimal numbers only. • 10ms • 10.5ms It is also well to remember that the time must not begin with . (period). 8.1.2 Configuration File Definition Items The following definitions are to be formulated in the configuration file •...
  • Page 246 << Content >> 1. System stack size [( Definition format )] [( Definition range )] [( Default value )] Define the total stack size used in service call and interrupt processing. 2. Maximum value of priority (value of lowest priority) [( Definition format )] [( Definition range )] [( Default value )]...
  • Page 247: System Clock Definition Procedure )]

    [( System Clock Definition Procedure )] << Format >> // System Clock Definition clock{ timer_clock timer << Content >> 1. MPU clock [( Definition format)] [( Definition range )] [( Default value )] Define the MPU operating clock frequency of the microcomputer in MHz units. 2.
  • Page 248: Definition Respective Maximum Numbers Of Items )]

    [( Definition respective maximum numbers of items )] Here, define respective maximum numbers of items to be used in two or more applications. << Format >> // Max Definition maxdefine{ the maximum number of tasks defined max_task the maximum number of eventflags defined max_flag the maximum number of data queues defined max_dtq...
  • Page 249 5. The maximum number of semaphores defined [( Definition format )] [( Definition range )] [( Default value )] Define the maximum number of semaphores defined. 6. The maximum number of fixed-size memory pools defined [( Definition format )] [( Definition range )] [( Default value )] 7.
  • Page 250: Task Definition )]

    [( Task definition )] << Format >> // Tasks Definition ID No. task[ name entry_address stack_size priority context stack_section initial_start exinf The ID number must be in the range of 1 to 255. The ID number can be omitted. If omitted, numbers are automatically assigned sequentially beginning with the smallest. <<...
  • Page 251 3. User stack size of task [( Definition format )] [( Definition range )] [( Default value )] Define the user stack size for each task. The user stack means a stack area used by each individual task. MR100 requires that a user stack area be allocated for each task, which amount to at least 12 bytes. 4.
  • Page 252: Eventflag Definition )]

    8. Extended information [( Definition format )] [( Definition range )] [( Default value )] 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.
  • Page 253: Semaphore Definition )]

    4. Multi-wait attribute [( Definition format )] [( Definition range )] [( Default value )] Specify whether multiple tasks can be enqueued in the eventflag waiting queue. If TA_WMUL is selected, the TA_WMUL attribute is added, permitting multiple tasks to be enqueued. If TA_WSGL is selected, the TA_WSGL attribute is added, prohibiting multiple tasks from being enqueued.
  • Page 254: Data Queue Definition )]

    2. Selecting a semaphore waiting queue [( Definition format )] [( Definition range )] [( Default value )] 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.
  • Page 255: Short Data Queue Definition )]

    2. Number of data [( Definition format )] [( Definition range )] [( Default value )] 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.
  • Page 256: Mailbox Definition )]

    3. Selecting a data queue waiting queue [( Definition format )] [( Definition range )] [( Default value )] Select a method in which tasks wait for short data queue transmission. If TA_TFIFO is selected, tasks are en- queued 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.
  • Page 257: Fixed-Size Memory Pool Definition )]

    4. Maximum message priority [( Definition format )] [( Definition range )] [( Default value )] 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. <<...
  • Page 258: Variable-Size Memory Pool Definition )]

    4. Size (in bytes) [( Definition format )] [( Definition range )] [( Default value )] 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.
  • Page 259 8. Section name [( Definition format )] [( Definition range )] [( Default value )] 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.
  • Page 260: Cyclic Handler Definition )]

    [( Cyclic handler definition )] This definition is necessary to use Cyclic handler function. << Format >> // Cyclic Handlar Definition ID No. cyclic_hand[ name interval_counter start phsatr phs_counter entry_address exitf The ID number must be in the range of 1 to 255. The ID number can be omitted. If omitted, numbers are automatically assigned sequentially beginning with the smallest.
  • Page 261: Alarm Handler Definition )]

    5. Activation phase [( Definition format )] [( Definition range )] [( Default value )] Define the activation phase of the cyclic handler. The time representing this startup phase must be defined in ms units. 6. Start Address [( Definition format )] [( Definition range )] [( Default value )] Define the start address of the cyclic handler.
  • Page 262: Interrupt Vector Definition )]

    2. Start address [( Definition format )] [( Definition range )] Define the start address of the alarm handler. The function name defined here causes the following declaration statement to be output in the kernel_id.h file. 3. Extended information [( Definition format )] [( Definition range )] [( Default value )] Define the extended information of the alarm handler.
  • Page 263: Fixed Interrupt Vector Definition )]

    6. Switch passed to PRAGMA extended function [( Definition format )] [( Definition range )] [( Default value )] Specify the switch to be passed to #pragma INTHANDLER or #pragma INTERRUPT. If "E" is specified, a "/E" switch is selected, in which case multiple interrupts are enabled. If "F" is specified, a "/F" switch is selected, in which case a "FREIT"...
  • Page 264: Table 8.3 List Of Vector Number And Vector Address

    Table 8.3 List of vector number and vector address Vector number Vector address FFFFFFD0H FFFFFFD4H FFFFFFD8H FFFFFFDCH FFFFFFE0H FFFFFFE4H FFFFFFE8H FFFFFFECH FFFFFFF0H FFFFFFF4H FFFFFFF8H FFFFFFFCH << Content >> 1. Start address [( Definition format )] [( Definition range )] [( Default value )] Define the entry address to the interrupt handler.
  • Page 265 [Precautions] 1. Regarding the method for specifying a register bank No kernel interrupt handlers that use the registers in register bank 1 can be written in C language. These handlers can only be written in assembly language. When writing in assembly language, write the entry and exit to and from the interrupt handler as shown below.
  • Page 266: Configuration File Example

    8.1.3 Configuration File Example The following is the configuration file example. 1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // kernel.cfg : building file for MR100 Ver.1.00 4 // 5 // Generated by M3T-MR100 GUI Configurator at 2007/02/28 19:01:20 6 // 7 //////////////////////////////////////////////////////////////////////////////// 9 // system definition 10 system{ stack_size...
  • Page 267 wait_queue = TA_TFIFO; clear_attribute = NO; wait_multi = TA_WMUL; 78 }; 79 flag[2]{ name = ID_flg3; initial_pattern = 0x0000ffff; wait_queue = TA_TPRI; clear_attribute = YES; wait_multi = TA_WMUL; 85 }; 86 flag[]{ name = ID_flg4; initial_pattern = 0x00000008; wait_queue = TA_TPRI; clear_attribute = YES;...
  • Page 268 name = ID_mpf1; wait_queue = TA_TFIFO; section = MR_RAM; siz_block = 16; num_block = 5; 160 }; 161 memorypool[2]{ name = ID_mpf2; wait_queue = TA_TPRI; section = MR_RAM; siz_block = 32; num_block = 4; 167 }; 168 memorypool[3]{ name = ID_mpf3; wait_queue = TA_TFIFO;...
  • Page 269 entry_address = alm2; name = ID_alm2; exinf = 0x12345678; 238 }; 241 // 242 // End of Configuration 243 //...
  • Page 270: Configurator Execution Procedures

    8.2 Configurator Execution Procedures 8.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 8.1 outlines the operation of the configurator. When used on HEW, the configurator is automatically started, and an application program is built. Executing the configurator requires the following input files: •...
  • Page 271: Setting Configurator Environment

    Configuration File xxx.cfg Default Configuration File default.cfg Template File sys_ram.inc, mr100.inc MR100 Version File version Service call Definition File kernel_sysint.h 8.2.2 Setting Configurator Environment Before executing the configurator, check to see if the environment variable "LIB100" is set correctly. The configurator cannot be executed normally unless the following files are present in the directory indicated by the envi- ronment variable "LIB100": •...
  • Page 272: Configurator Start Procedure

    8.2.3 Configurator Start Procedure Start the configurator as indicated below. C:\> cfg100 [-vV] [-Eipl] [-Wipl] Normally, use the extension .cfg for the configuration file name. The file name can includes space character with “”. 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.
  • Page 273: Configurator Error Indications And Remedies

    8.2.5 Configurator Error Indications and Remedies If any of the following messages is displayed, the configurator is not normally functioning. Therefore, correct the configu- ration file as appropriate and the execute the configurator again. Error messages cfg100 Error : Syntax error near line xxx (xxxx.cfg) There is an syntax error in the configuration file.
  • Page 274 cfg100 Error : System timer's vector <x>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. cfg100 Error : XXXX is not defined (xxxx.cfg) "XXXX" item must be set in your configuration file. cfg100 Error : System's default is not defined These items must be set int the default configuration file.
  • Page 275: Warning Messages

    Warning messages The following message are a warning. A warning can be ignored providing that its content is understood. cfg100 Warning : system is not defined (xxxx.cfg) cfg100 Warning : system.XXXX is not defined (xxxx.cfg) System definition or system definition item XXXX is omitted in the configuration file. cfg100 Warning : task[x].XXXX is not defined near line xxx (xxxx.cfg) The task definition item XXXX in ID number is omitted.
  • Page 276: Table 9.1 Functions In The Sample Program

    Sample Program Description 9.1 Overview of Sample Program As an example application of MR100, the following shows a program that outputs a string to the standard output device from one task and another alternately. Function Type Name main() Task task1() Task task2() Task...
  • Page 277: Program Source Listing

    9.2 Program Source Listing 1 /************************************************************************* 4 * COPYRIGHT(C) 2003(2005) RENESAS TECHNOLOGY CORPORATION 5 * AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED $Id: demo.c,v 1.2 2005/06/15 05:29:02 inui Exp $ 9 *************************************************************************/ 11 #include <itron.h> 12 #include <kernel.h> 13 #include "kernel_id.h"...
  • Page 278: Configuration File

    9.3 Configuration File 1 //************************************************************************* 2 // 3 // COPYRIGHT(C) 2003,2005 RENESAS TECHNOLOGY CORPORATION 4 // AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED 5 // 6 // MR100 System Configuration File. 7 // "$Id: smp.cfg,v 1.5 2005/06/15 05:41:54 inui Exp $"...
  • Page 280: Stack Size Calculation Method

    Stack Size Calculation Method 10.1 Stack Size Calculation Method The MR100 provides two kinds of stacks: the system stack and the user stack. The stack size calculation method differ be- tween the stacks. User stack This stack is provided for each task. Therefore, writing an application by using the MR100 requires to allocate the stack area for each stack.
  • Page 281 System Stack User satck of TaskID No.1 User satck of Stack Section TaskID No.2 User satck of TaskID No.n Figure 10.2: Layout of Stacks...
  • Page 282: User Stack Calculation Method

    10.1.1 User Stack Calculation Method User stacks must be calculated for each task. The following shows an example for calculating user stacks in cases when an application is written in the C language and when an application is written in the assembly language. When an application is written in the C language Using the stack size calculation utility of NC100, calculate the stack size of each task.
  • Page 283 Stack growing direction W hen use reg ister R2R0, R3 R1,A0(12 by tes) 4 bytes 24 byt es(PC+FL G+size of re gister s used j sr sub1 stac k size used b y sta _tsk) sta_t sk 3 6by tes(P C+F LG+size of registe rs used stac k size used by prcv _mbx ) p rc v_mb x 4 0by tes...
  • Page 284: System Stack Calculation Method

    10.1.2 System Stack Calculation Method The system stack is most often consumed when an interrupt occurs during service call processing followed by the occur- rence of multiple interrupts. The necessary size (the maximum size) of the system stack can be obtained from the fol- lowing relation: Necessary size of the system stack = α...
  • Page 285 α:The maximum system stack size among the service calls to be used. α βι:The system stack size to be used by the interrupt handler. β Interrupt Interrupt The necessary system stack Figure 10.4: System Stack Calculation Method β β...
  • Page 286 [( Stack size β i used by interrupt handlers )] The stack size used by an interrupt handler that is invoked during a service call can be calculated by the equation below. The stack size βi used by an interrupt handler is shown below. C language Using the stack size calculation utility of NC100, calculate the stack size of each interrupt handler.
  • Page 287 [( System stack size γ used by system clock interrupt handler )] When you do not use a system timer, there is no need to add a system stack used by the system clock interrupt handler. The system stack size γ used by the system clock interrupt handler is whichever larger of the two cases below: 48 + maximum size used by cyclic handler 48 + maximum size used by alarm handler 72 bytes...
  • Page 288: Table 10.1 Stack Sizes Used By Service Calls Issued From Tasks (In Bytes)

    10.2 Necessary Stack Size Table 10.1 Stack Sizes Used by Service Calls Issued from Tasks (in bytes) lists the stack sizes (system stack) used by service calls that can be issued from tasks. Table 10.1 Stack Sizes Used by Service Calls Issued from Tasks (in bytes) Service call act_tsk can_act...
  • Page 289: Table 10.2 Stack Sizes Used By Service Calls Issued From Handlers (In Bytes)

    Table 10.2 Stack Sizes Used by Service Calls Issued from Handlers (in bytes) lists the stack sizes (system stack) used by service calls that can be issued from handlers. Table 10.2 Stack Sizes Used by Service Calls Issued from Handlers (in bytes) Service call Stack size iact_tsk...
  • Page 291: Table 11.1 Interrupt Number Assignment

    Note 11.1 The Use of INT Instruction MR100 has INT instruction interrupt numbers reserved for issuing service calls as listed in Table 11.1 Interrupt Number Assignment. For this reason, when using software interrupts in a user application, do not use interrupt numbers 63 through 48 and be sure to use some other numbers.
  • Page 292: Regarding Delay Dispatching

    11.3 Regarding Delay Dispatching MR100 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. 14. When the execution task in delay dispatching should be 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.
  • Page 293: Regarding Initially Activated Task

    11.4 Regarding Initially Activated Task MR100 allows you to specify a task that starts from a READY state at system startup. This specification is made by setting the configuration file. Refer to 8.1.2 for details on how to set. - 277 -...
  • Page 295: Appendix

    Appendix 12.1 Data Type typedef signed char typedef signed short typedef signed long typedef unsigned char typedef unsigned short typedef unsigned long typedef char typedef short typedef long typedef void typedef void typedef typedef typedef typedef typedef typedef typedef typedef typedef typedef typedef...
  • Page 296: Common Constants And Packet Format Of Structure

    12.2 Common Constants and Packet Format of Structure ----Common formats---- TRUE FALSE ----Formats related to task management---- TSK_SELF TPRI_RUN typedef struct t_rtsk { STAT tskstat; tskpri; tskbpri; STAT tskwait; wid; tskatr; UINT actcnt; UINT wupcnt; UINT suscnt; } T_RTSK; typedef struct t_rtst { STAT tskstat;...
  • Page 297 ----Formats related to Variable-size Memory pool---- typedef struct t_rmpl { wtskid; SIZE fmplsz; UINT fblksz; } T_RMPL; ----Formats related to cyclic handler---- typedef struct t_rcyc { STAT cycstat; RELTIM lefttim; } T_RCYC; ----Formats related to alarm handler---- typedef struct t_ralm { STAT almstat;...
  • Page 298: Assembly Language Interface

    12.3 Assembly Language Interface When issuing a service call in the assembly language, you need to use macros prepared for invoking service calls. Processing in a service call invocation macro involves setting each parameter to registers and starting ex- ecution of a service call routine by a software interrupt. If you issue service calls directly without using a ser- vice call invocation macro, your program may not be guaranteed of compatibility with future versions of MR100.
  • Page 299 Task Dependent Synchronization Function ServiceCall INTNo. FuncCode slp_tsk wup_tsk iwup_tsk can_wup ican_wup tslp_tsk sus_tsk isus_tsk rsm_tsk irsm_tsk frsm_tsk ifrsm_tsk dly_tsk rel_wai irel_wai Synchronization & Communication Function ServiceCall INTNo. FuncCode wai_sem pol_sem ipol_sem sig_sem isig_sem twai_sem ref_sem iref_sem wai_flg twai_flg pol_flg ipol_flg set_flg iset_flg...
  • Page 300 Synchronization & Communication Function ServiceCall INTNo. FuncCode rcv_dtq prcv_dtq iprcv_dtq trcv_dtq ref_dtq iref_dtq snd_mbx isnd_mbx rcv_mbx prcv_mbx iprcv_mbx trcv_mbx ref_mbx iref_mbx Parameter R3R1 R6R4 dtqid dtqid dtqid dtqid tmout dtqid dtqid mbxid mbxid mbxid mbxid mbxid mbxid tmout mbxid mbxid - 284 - ReturnParameter R3R1...
  • Page 301 Interrupt Management Functions Parameter ServiceCall INTNo. FuncCode ret_int System State Management Functions Parameter ServiceCall INTNo. FuncCode rot_rdq irot_rdq get_tid iget_tid loc_cpu iloc_cpu dis_dsp ena_dsp unl_cpu iunl_cpu sns_ctx sns_loc sns_dsp sns_dpn ReturnParameter ReturnParameter tskpri ercd tskpri ercd ercd tskid ercd tskid ercd ercd ercd...
  • Page 302 Memorypool Management Functions Service- INT- Func- Call Code get_mpf pget_mpf ipget_mpf tget_mpf rel_mpf irel_mpf ref_mpf iref_mpf pget_mpl rel_mpl ref_mpl iref_mpl Time Management Functions ServiceCall INTNo. FuncCode 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 Parameter...
  • Page 303 System Configuration Management Functions Parameter ServiceCall INTNo. FuncCode ref_ver iref_ver Extenden Function(Reset Function) Parameter ServiceCall INTNo. FuncCode vrst_vdtq vrst_dtq vrst_mbx vrst_mpf vrst_mpl vrst_mbf Extenden Function(Short Data Queue Function) ServiceCall INTNo. FuncCode vsnd_dtq vpsnd_dtq vipsnd_dtq vfsnd_dtq vifsnd_dtq vtsnd_dtq vrcv_dtq vprcv_dtq viprcv_dtq vtrcv_dtq vref_dtq viref_dtq...
  • Page 304 - 288 -...
  • Page 305 Real-time OS for R32C/100 Series M3T-MR100/4 User's Manual Publication Date: September. 16, 2007 Sales Strategic Planning Div. Published by: Renesas Technology Corp. Application Engineering Department 1 Edited by: Renesas Solutions Corp. © 2007. Renesas Technology Corp. and Renesas Solutions Corp., Rev.1.00...
  • Page 306 M3T-MR100/4 V.1.00 User’s Manual 1753, Shimonumabe, Nakahara-ku, Kawasaki-shi, Kanagawa 211-8668 Japan REJ10J1523-0100...

This manual is also suitable for:

M3t-mr100/4 v.1.00

Table of Contents