REJ10J1523-0100 M3T-MR100/4 V.1.00 User’s Manual Real-time OS for R32C/100 Series Rev.1.
z Active X, Microsoft, MS-DOS, Visual Basic, Visual C++, Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries. z IBM and AT are registered trademarks of International Business Machines Corporation. z Intel and Pentium are registered trademarks of Intel Corporation. z Adobe, Acrobat, and Acrobat Reader are trademarks of Adobe Systems Incorporated. z TRON is an abbreviation of "The Real-time Operating system Nucleus.
Preface The M3T-MR100/4(abbreviated as MR100) is a real-time operating system 1 for the R32C/100 series microcomputers. The MR100 conforms to the μITRON Specification. 2 This manual describes the procedures and precautions to observe when you use the MR100 for programming purposes. For the detailed information on individual service call procedures, refer to the MR100 Reference Manual.
Contents Requirements for MR100 Use ......................................................................................................................................i Document List...............................................................................................................................................................i Right of Software Use ................................................................................................................................................
4.1.8 4.1.9 4.1.10 4.1.11 4.1.12 4.1.13 4.1.14 4.1.15 4.1.16 4.1.17 4.1.18 5. Synchronization and Communication Function (Mailbox) ..................................................... - 48 Memory pool Management Function(Fixed-size Memory pool) ............................................. - 50 Variable-size Memory Pool Management Function ................................................................ - 51 Time Management Function..........................................................................
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)...................................................
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....................................................................................
7.2.3 Writing Non-kernel Interrupt Handler.................................................................................. - 216 7.2.4 Writing Cyclic Handler/Alarm Handler ................................................................................. - 216 7.3 Modifying MR100 Startup Program.............................................................................................. - 218 7.3.1 C Language Startup Program (crt0mr.a30).....................................................................
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.
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 .............................................
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.
xii
1. 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. • 4 Kernel Outlines the applications program development procedure for the MR100.
2. General Information 2.1 Objective of MR100 Development In line with recent rapid technological advances in microcomputers, the functions of microcomputer-based products have become complicated. In addition, the microcomputer program size has increased. Further, as product development competition has been intensified, manufacturers are compelled to develop their microcomputer-based products within a short period of time.
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 initiate an interrupt. However, as the number of usable microcomputer timers was limited, timer insufficiency was compensated for by, for instance, using one timer for a number of different processing operations.
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.
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.
3. 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 increased. ROM capacity of 32K bytes. As such large ROM capacity microcomputers are introduced, their program development is not easily carried out by conventional methods. Figure 3.
Key input microcomputer Remote control microcomputer LED illumination microcomputer Arbiter microcomputer Volume control microcomputer Monitor microcomputer Mechanical control microcomputer Figure 3.2 Microcomputer-based System Example(Audio Equipment) Using independent microcomputers for various functions as indicated in the above example offers the following advantages. 1. Individual programs are small so that program development is easy. 2. It is very easy to use previously developed software. 3.
Key input Task Remote control Task LED illumination Task real-time OS Volume control Task Monitor Task Mechanical control Task Figure 3.3 Example System Configuration with Real-time OS(Audio Equipment) In other words, the real-time OS is the software that makes a one-microcomputer system look like operating a number of microcomputers. In the real-time OS, the individual programs, which correspond to a number of microcomputers used in a conventional system, are called tasks.
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. As shown in Figure 3.4 the kernel runs a number of tasks according to the time-division system.
Key input Task Remote control Task Program execution interrupt Program execution resumed During this interval, it appears that the key input microcomputer is haled. 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.
Memory map Register R0 Remote control Task PC SP R0 Key input Task Stack section PC SP R0 LED illumination Task PC SP Real-time OS SFR SP Figure 3.
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. SP PC Register not stored FLG FB SB A3 A2 A1 A0 Key input task stack R7R5 R6R4 Key input Task R3R1 SP R2R0 Register stored SFR Figure 3.
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). Kernel Key input Task Service call Remote control task Task switching Figure 3.
3.2.1 Service Call Processing When a service call is issued, processing takes place in the following sequence. 6 1. The current register contents are saved. 2. The stack pointer is changed from the task type to the real-time OS (system) type. 3. Processing is performed in compliance with the request made by the service call. 4. The task to be executed next is selected. 5. The stack pointer is changed to the task type. 6. The register contents are recovered to resume task execution.
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 7 is made. The processing procedures for service calls from handlers are roughly classified into the following three types. 1. A service call from a handler that caused an interrupt during task execution 2.
Service Calls from a Handler That Caused an Interrupt during Task Execution Scheduling (task switching) is initiated by the ret_int service call 8(See Figure 3.11). TaskA Interrupt handler OS Interrupt Save Registers iset_flg Service call processing Restore Registers ret_int Task selection SP <= User TaskB Scheduler Restore Registers Figure 3.
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 OS Interrupt handler wup_tsk Save Registers SP <= System Save Interrupt iset_flg Service call processing Restore Registers Task selection SP <= User ret_int Restore Registers TaskB Figure 3.
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).
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." However, if a task number is directly written in a program, the resultant program would be very low in readability.
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. That is, the key input task is placed in the execution (RUNNING) state. While the system waits for key input, task execution is not needed.
MPU execlusive right acquisition READY state RUNNING state MPU execlusive right relinquishment WAITING l Entering the WAITING state state WAITING state SUSPENDED state clear request from other task SUSPEND request from other task Forced termination request from other task WAITING-SUSPENDED state SUSPEND request from other task SUSPENDED state clear request Forced termination request from other task WAITING clear t state SUSPENDED state DORMANT state Task activation Figure 3.
♦ ♦ ♦ ♦ A currently executed task has placed itself in the WAITING state. 10 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. Due to interruption or other event occurrence, the priority of a currently executed task has been changed so that the priority of a different READY task is rendered higher.
tasks in the RUNNING, READY, or WAITING state. 12 If the suspend request is made to a task in the SUSPENDED 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.
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.
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). Figure 3.18 and Figure 3.19 depict the manner in which tasks are placed in a waiting queue in order of "taskD," "taskC," "taskA," and "taskB." ID No.
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 other control purposes. The MR100 manages the following task information as the task control block • Task connection pointer Task connection pointer used for ready queue formation or other purposes.
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. Table 3.
Task System clock interrupt handler Cyclic handler Alarm handler Subroutine call Timer interrupt RTS Figure 3.
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 scheduling is performed. Nor can service calls be invoked that may cause the service call issuing task to enter a wait state. 16 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.
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. That is, interruption priority level is from 1 to system_IPL.
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 handler. In sections where all interrupts can be enabled, it is returned to the initial IPL value when the service call was invoked. • For service calls that can be issued from only task context.
• For service calls that can be issued from only non-task context or from both task context and non-task context. When the I flag before issuing a service call is 1 Task or Handler Service call issued I flag 1 0 1 IPL 4 system.IPL 4 service call processing Task or Handler 1 system.IPL 4 When the I flag before issuing a service call is 0 Task or Handler Service call issued I flag 0 IPL 4 service call processing 0 system.IPL 4 Task or Handler 0 system.IPL 4 Figure 3.
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. • System Stack This stack is used within the MR100 (during service call processing). When a service call is issued from a task, the MR100 switches the stack from the user stack to the system stack (See Figure 3.25).
4. 4.1.1 Kernel Module Structure The MR100 kernel consists of the modules shown in Figure 4.1. Each of these modules is composed of functions that exercise 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 generation. More specifically, only the functions used are chosen from those which comprise these modules and linked by means of the Linkage Editor.
4.1.2 Module Overview The MR100 kernel modules are outlined below. • • • • • • • • • • 19 20 Scheduler Forms a task processing queue based on task priority and controls operation so that the high-priority task at the beginning in that queue (task with small priority value) is executed. Task Management Module Exercises the management of various task states such as the RUNNING, READY, WAITING, and SUSPENDED state.
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, unlike in sta_tsk(ista_tsk), startup requests are accumulated, but startup code cannot be specified.
Priority 1 Task A Task B 3 Task C Task B n Task E Task F 2 Task D When the priority of task B has been changed from 3 to 1 Figure 4.3 Alteration of task priority ID Number 1 2 3 taskA Priority 1 taskB taskC taskB Priority 2 Priority 3 Priority 4 n When the priority of Task B is changed into 4 Figure 4.4 Task rearrangement in a waiting queue • Reference task priority (get_pri, iget_pri) Gets the priority of a 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. • Put Task to sleep (slp_tsk,tslp_tsk) • Wakeup task (wup_tsk, iwup_tsk) Wakeups a task that has been placed in a WAIT state by the slp_tsk or tslp_tsk service call.
• 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 request 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.
• 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 allows only one suspension request to be nested, this service call behaves the same way as rsm_tsk and irsm_tsk..(See Figure 4.8). sus_tsk frsm_tsk Task READY state WAITING state Number of suspension requests SUSPENDED state READYstate WAITING – SUSPENDED state WAITING 0 1 state 0 Figure 4.
• 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. dly_tsk(10) Task 10msec Figure 4.
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.
• Reference Semaphore Status (ref_sem, iref_sem) Refers the status of the target semaphore. Checks the count value and existence of the wait task for the target semaphore. Figure 4.12 shows example task execution control provided by the wai_sem and sig_sem service calls. wai_sem Task sig_sem wai_sem Task wai_sem Task wai_sem Task WAIT state Semaphore Counter 3 2 1 0 x Figure 4.
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. It is possible to determine whether multiple waiting tasks can be enqueued in one eventflag waiting queue by specifying the eventflag attribute TA_WSGL or TA_WMUL.
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.
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 Data Data Data Data Task A Task B Figure 4.14 Data queue Data in width of 32 bits can be transmitted to this data queue. The data queue has the function to accumulate data.
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.
Message queue T_MSG header T_MSG header Message A Message B T_MSG header Message C Figure 4.16 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.
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 configuration. Figure 4.17 is a figure about the example of a fixed-size memory pool of operation. • Acquire Fixed-size Memory Block (get_mpf, tget_mpf) Acquires a memory block from the fixed-size memory pool that has the specified ID.
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 memory pool. The MR100 permits one of the following two memory pool management methods to be selected before the memory pool is used. 1. 2. Normal block method Small block method Each of these methods are explained below.
[[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.
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.
4.1.11 Time Management Function The time management function provides system time management, time reading 26, time setup 27, and the functions of the 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. Note, however, that the system clock is not an essential function of MR100.
3. 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 occurrence of the time tick. • Set System Time (set_tim) • Reference System Time (get_tim) The system time indicates an elapsed time from when the system was reset by using 48-bit data. The time is expressed in ms units.
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. In the latter case, the cyclic handler is started relative to the point in time at which it started operating. Figure 4.21 and Figure 4.
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. Figure 4.23 shows a typical operation of the alarm handler. Alarm handler created Start operating Start operating Stop operating Activation Activation time time Handler starts Handler does not start Figure 4.
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 intervals, round robin scheduling required for the TSS is accomplished (See Figure 4.24) Priority 1 taskA 2 3 n taskB taskC taskD taskE taskF Move the end of the queue Figure 4.
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.
4.1.16 System Configuration Management Function This function inspects the version information of MR100. • 4.1.17 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. Extended Function (Short Data Queue) The short data queue is a function outside the scope of µITRON 4.0 Specification.
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. • Clear Mailbox Area (vrst_mbx) Initializes the mailbox.
5. 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 kernel concerned with them. The task stack permits a section name to be specified for each task individually. Table 5.1 Specifications of the Task Management Function No.
Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a following meaning.
act_tsk iact_tsk Activate task Activate task (handler only) [[ C Language API ]] ER ercd = act_tsk( ID tskid ); ER ercd = iact_tsk( ID tskid ); z Parameters ID tskid ID number of the task to be started z Return parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Functional description ]] This service call starts the task indicated by tskid. The started task goes from DORMANT state to READY state or RUNNING 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. Clears the number of suspension requests. Specifying tskid=TSK_SELF(0) specifies the issuing task itself.
can_act ican_act Cancel task activation request Cancel task activation request (handler only) [[ C Language API ]] ER_UINT actcnt = can_act( ID tskid ); ER_UINT actcnt = ican_act( ID tskid ); z Parameters ID tskid ID number of the task to cancel z Return Parameters ER_UINT actcnt > 0 actcnt < 0 Canceled activation request count Error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task1() { ER_UINT actcnt; : actcnt = can_act( ID_task2 ); : } void task2() { : ext_tsk(); } <> .INCLUDE mr100.inc .
sta_tsk ista_tsk Activate task with a start code Activate task with a start code (handler only) [[ C Language API ]] ER ercd = sta_tsk( ID tskid,VP_INT stacd ); ER ercd = ista_tsk ( ID tskid,VP_INT stacd ); z Parameters ID tskid ID number of the target task VP_INT stacd Task start code z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Functional description ]] 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 activation request is issued while the target task is not DORMANT state, the error code E_OBJ is returned to the service call issuing task. This service call is effective only when the specified task is in DORMANT state.
ext_tsk Terminate invoking task [[ C Language API ]] ER ercd = ext_tsk(); z Parameters None z Return Parameters Not return from this service call [[ Assembly language API ]] .include mr100.inc ext_tsk z Parameters None z Register contents after service call is issued Not return from this service call [[ Error code ]] Not return from this service call [[ Functional description ]] This service call terminates the invoking task.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task(void) { : ext_tsk(); } <> .INCLUDE mr100.inc .
ter_tsk Terminate task [[ C Language API ]] ER ercd = ter_tsk( ID tskid ); z Parameters ID tskid ID number of the forcibly terminated task z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : ter_tsk( ID_main ); : } <> .INCLUDE mr100.inc .GLB task task: : PUSH.
chg_pri ichg_pri Change task priority Change task priority(handler only) [[ C Language API ]] ER ercd = chg_pri( ID tskid, PRI tskpri ); ER ercd = ichg_pri( ID tskid, PRI tskpri ); z Parameters ID tskid ID number of the target task PRI tskpri Priority of the target task z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Functional description ]] The priority (base priority) of the task specified by tskid is changed to the value indicated by tskpri, and tasks are rescheduled 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.
get_pri iget_pri Reference task priority Reference task priority(handler only) [[ C Language API ]] ER ercd = get_pri( ID tskid, PRI *p_tskpri ); ER ercd = iget_pri( ID tskid, PRI *p_tskpri ); z Parameters ID tskid ID number of the target task PRI *p_tskpri Pointer to the area to which task priority is returned z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { PRI p_tskpri; ER ercd; : ercd = get_pri( ID_task2, &p_tskpri ); : } <> .INCLUDE mr100.inc .
ref_tsk iref_tsk Reference task status Reference task status (handler only) [[ C Language API ]] ER ercd = ref_tsk( ID tskid, T_RTSK *pk_rtsk ); ER ercd = iref_tsk( ID tskid, T_RTSK *pk_rtsk ); z Parameters ID tskid ID number of the target task T_RTSK *pk_rtsk Pointer to the packet to which task status is returned z Return Parameters ER ercd Terminated normally (E_OK) Contents of pk_rtsk typedef struct t_rtsk{ STAT tskstat +0 PRI tskpri +2 PRI tskbpri +4 STAT tskwait +6 ID wobjid +8 TMO lefttmo
[[ Functional description ]] 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.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RTSK rtsk; ER ercd; : ercd = ref_tsk( ID_main, &rtsk ); : } <> _refdata: .blkb 26 .include mr100.inc .GLB task task: : PUSH.W R2 PUSH.
ref_tst iref_tst Reference task status (simplified version) Reference task status (simplified version, handler only) [[ C Language API ]] ER ercd = ref_tst( ID tskid, T_RTST *pk_rtst ); ER ercd = iref_tst( ID tskid, T_RTST *pk_rtst ); z Parameters ID tskid ID number of the target task T_RTST *pk_rtst Pointer to the packet to which task status is returned z Return Parameters ER ercd Terminated normally (E_OK) Contents of pk_rtsk typedef struct t_rtst{ STAT tskstat +0 STAT tskwait +2 } T_RTST; 2
[[ Functional description ]] 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. tskstat (task status) tskstat has one of the following values returned to it depending on the status of the specified task.
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 No. 1 2 Item Maximum value of task wakeup request count Maximum number of nested forcible task wait requests count Content 255 1 Table 5.4 List of Task Dependent Synchronization Service Call No.
slp_tsk tslp_tsk Put task to sleep Put task to sleep (with timeout) [[ C Language API ]] ER ercd = slp_tsk(); ER ercd = tslp_tsk( TMO tmout ); z Parameters z slp_tsk None z tslp_tsk TMO tmout Timeout value z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Functional description ]] This service call places the issuing task itself from RUNNING state into sleeping wait state. The task placed into WAITING 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. When a forcible awaking service call is issued from another task or an interrupt The error code returned in this case is E_RLWAI.
[[ Example program statement ]] <> #include #include #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”); : } <> .include mr100.inc .
wup_tsk iwup_tsk Wakeup task Wakeup task (handler only) [[ C Language API ]] ER ercd = wup_tsk( ID tskid ); ER ercd = iwup_tsk( ID tskid ); z Parameters ID tskid ID number of the target task z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : if( wup_tsk( ID_main ) != E_OK ) printf(“Can’t wakeup main()\n”); : } <> .include mr100.inc .GLB task task: : PUSH.
can_wup ican_wup Cancel wakeup request Cancel wakeup request (handler only) [[ C Language API ]] ER_UINT wupcnt = can_wup( ID tskid ); ER_UINT wupcnt = ican_wup( ID tskid ); z Parameters ID tskid ID number of the target task z Return Parameters ER_UINT wupcnt > 0 wupcnt <0 Canceled wakeup request count Error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { ER_UINT wupcnt; : wupcnt = can_wup(ID_main); if( wup_cnt > 0 ) printf(“wupcnt = %d\n”,wupcnt); : } <> .include mr100.inc .
rel_wai irel_wai Release task from waiting Release task from waiting (handler only) [[ C Language API ]] ER ercd = rel_wai( ID tskid ); ER ercd = irel_wai( ID tskid ); z Parameters ID tskid ID number of the target task z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : if( rel_wai( ID_main ) != E_OK ) error(“Can’t rel_wai main()\n”); : } <> .include mr100.inc .GLB task task: : PUSH.
sus_tsk isus_tsk Suspend task Suspend task (handler only) [[ C Language API ]] ER ercd = sus_tsk( ID tskid ); ER ercd = isus_tsk( ID tskid ); z Parameters ID tskid ID number of the target task z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : if( sus_tsk( ID_main ) != E_OK ) printf(“Can’t suspend task main()\n”); : } <> .include mr100.inc .GLB task task: : PUSH.
rsm_tsk irsm_tsk frsm_tsk ifrsm_tsk Resume suspended task Resume suspended task(handler only) Forcibly resume suspended task Forcibly resume suspended task(handler only) [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = rsm_tsk( ID tskid ); irsm_tsk( ID tskid ); frsm_tsk( ID tskid ); ifrsm_tsk( ID tskid ); z Parameters ID tskid ID number of the target task z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #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”); : } <> .include mr100.inc .GLB task task: : PUSH.W R2 rsm_tsk #ID_TASK2 : PUSH.
dly_tsk Delay task [[ C Language API ]] ER ercd = dly_tsk(RELTIM dlytim); z Parameters RELTIM dlytim Delay time z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : if( dly_tsk() != E_OK ) error(“Forced wakeup\n”); : } <> .include mr100.inc .
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 No. Item 1 2 Semaphore ID Maximum number of resources 3 Semaphore attribute Content 1-255 1-65535 TA_FIFO: TA_TPRI: Tasks enqueued in order of FIFO Tasks enqueued in order of priority Table 5.6 List of Semaphore Function Service Call No.
sig_sem isig_sem Release semaphore resource Release semaphore resource (handler only) [[ C Language API ]] ER ercd = sig_sem( ID semid ); ER ercd = isig_sem( ID semid ); z Parameters ID semid Semaphore ID number to which returned z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : if( sig_sem( ID_sem ) == E_QOVR ) error(“Overflow\n”); : } <> .include mr100.inc .GLB task task: : PUSH.
wai_sem pol_sem ipol_sem twai_sem Acquire semaphore resource Acquire semaphore resource (polling) Acquire semaphore resource (polling, handler only) Acquire semaphore resource(with timeout) [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = wai_sem( ID semid ); pol_sem( ID semid ); ipol_sem( ID semid ); twai_sem( ID semid, TMO tmout ); z Parameters ID semid Semaphore ID number to be acquired TMO tmout Timeout value (for twai_sem) z Return Parameters ER ercd Terminated normally (E_OK)
[[ Functional description ]] 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.
[[ Example program statement ]] <> #include #include #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”); : } <> .include mr100.inc .GLB task task: : PUSH.W R2 pol_sem #ID_SEM1 : PUSH.W R2 wai_sem #ID_SEM2 : PUSH.W R2 PUSH.
ref_sem iref_sem Reference semaphore status Reference semaphore status (handler only) [[ C Language API ]] ER ercd = ref_sem( ID semid, T_RSEM *pk_rsem ); ER ercd = iref_sem( ID semid, T_RSEM *pk_rsem ); z Parameters ID semid ID number of the target semaphore T_RSEM *pk_rsem Pointer to the packet to which semaphore status is returned z Return Parameters ER T_RSEM ercd *pk_rsem Terminated normally (E_OK) Pointer to the packet to which semaphore status is returned Contents of pk_rsem typedef struc
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RSEM rsem; ER ercd; : ercd = ref_sem( ID_sem1, &rsem ); : } <> _ refsem: .blkb 6 .include mr100.inc .GLB task task: : PUSH.W R2 PUSH.
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 No.
set_flg iset_flg Set eventflag Set eventflag (handler only) [[ C Language API ]] ER ercd = set_flg( ID flgid, FLGPTN setptn ); ER ercd = iset_flg( ID flgid, FLGPTN setptn ); z Parameters ID flgid ID number of the eventflag to be set FLGPTN setptn Bit pattern to be set z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task(void) { : set_flg( ID_flg,(FLGPTN)0xff000000 ); : } <> .include mr100.inc .GLB task task: : PUSH.W R2 PUSH.
clr_flg iclr_flg Clear eventflag Clear eventflag (handler only) [[ C Language API ]] ER ercd = clr_flg( ID flgid, FLGPTN clrptn ); ER ercd = iclr_flg( ID flgid, FLGPTN clrptn ); z Parameters ID flgid ID number of the eventflag to be cleared FLGPTN clrptn Bit pattern to be cleared z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task(void) { : clr_flg( ID_flg,(FLGPTN) 0xf0f0f0f0); : } <> .include mr100.inc .GLB task task: : PUSH.W R2 PUSH.
wai_flg pol_flg ipol_flg twai_flg Wait for eventflag Wait for eventflag(polling) Wait for eventflag(polling, handler only) Wait for eventflag(with timeout) [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = wai_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn ); pol_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn ); ipol_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn ); twai_flg( ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn, TMO tmout ); z Parame
[[ Error code ]] E_RLWAI E_TMOUT E_ILUSE Forced release from waiting Polling failure or timeout or timed out Service call improperly used (Tasks present waiting for TA_WSGL attribute eventflag) [[ Functional description ]] 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. Returned to the area pointed to by p_flgptn is the eventflag bit pattern at the time the task is released from WAITING state.
[[ Example program statement ]] <> #include #include #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”); : } <> .
ref_flg iref_flg Reference eventflag status Reference eventflag status (handler only) [[ C Language API ]] ER ercd = ref_flg( ID flgid, T_RFLG *pk_rflg ); ER ercd = iref_flg( ID flgid, T_RFLG *pk_rflg ); z Parameters ID flgid ID number of the target eventflag T_RFLG *pk_rflg Pointer to the packet to which eventflag status is returned z Return Parameters ER T_RFLG ercd *pk_rflg Terminated normally (E_OK) Pointer to the packet to which eventflag status is returned Contents of pk_rflg typedef struc
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RFLG rflg; ER ercd; : ercd = ref_flg( ID_FLG1, &rflg ); : } <> _ refflg: .blkb 6 .include mr100.inc .GLB task task: : PUSH.W R2 PUSH.
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 No. 1 2 3 4 Item Data queue ID Capacity (data bytes) in data queue area Data size Data queue attribute Content 1-255 0-8191 32 bits TA_TFIFO: Waiting tasks enqueued in order of FIFO TA_TPRI: Waiting tasks enqueued in order of priority Table 5.10 List of Dataqueue Function Service Call No.
snd_dtq psnd_dtq ipsnd_dtq tsnd_dtq fsnd_dtq ifsnd_dtq Send to data queue Send to data queue (polling) Send to data queue (polling, handler only) Send to data queue (with timeout) Forced send to data queue Forced send to data queue (handler only) [[ C Language API ]] ER ER ER ER ER ER ercd ercd ercd ercd ercd ercd = = = = = = snd_dtq( ID dtqid, VP_INT data ); psnd_dtq( ID dtqid, VP_INT data ); ipsnd_dtq( ID dtqid, VP_INT data ); tsnd_dtq( ID dtqid, VP_INT data, TMO tmout ); fsnd_dtq( ID dtqid, VP_INT d
[[ Error code ]] E_RLWAI Forced release from waiting E_TMOUT E_ILUSE Polling failure or timeout or timed out Service call improperly used (fsnd_dtq or ifsnd_dtq is issued for a data queue whose dtqcnt = 0) Released from WAITING state by clearing of the data queue area EV_RST [[ Functional description ]] This service call sends the 4-byte data indicated by data to the data queue indicated by dtqid.
[[ Example program statement ]] <> #include #include #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”); } : if( fsnd_dtq( ID_dtq, data[3]) != E_OK ){ error(“error\n”); } : } <> .include mr100.
rcv_dtq prcv_dtq iprcv_dtq trcv_dtq Receive from data queue Receive from data queue (polling) Receive from data queue (polling, handler only) Receive from data queue (with timeout) [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = rcv_dtq( ID dtqid, VP_INT *p_data ); prcv_dtq( ID dtqid, VP_INT *p_data ); iprcv_dtq( ID dtqid, VP_INT *p_data ); trcv_dtq( ID dtqid, VP_INT *p_data, TMO tmout ); z Parameters ID dtqid ID number of the data queue from which to receive TMO tmout Timeout value
[[ Functional description ]] 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.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { 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”); : } <> .include mr100.inc .GLB task task: : PUSH.W R2 PUSHM R6R4 trcv_dtq #ID_DTQ1,#TMO_POL : PUSH.
ref_dtq iref_dtq Reference data queue status Reference data queue status (handler only) [[ C Language API ]] ER ercd = ref_dtq( ID dtqid, T_RDTQ *pk_rdtq ); ER ercd = iref_dtq( ID dtqid, T_RDTQ *pk_rdtq ); z Parameters ID dtqid ID number of the target data queue T_RDTQ *pk_rdtq Pointer to the packet to which data queue status is returned z Return Parameters ER T_RDTQ ercd *pk_rdtq Terminated normally (E_OK) Pointer to the packet to which data queue status is returned Contents of pk_rdtq typedef
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RDTQ rdtq; ER ercd; : ercd = ref_dtq( ID_DTQ1, &rdtq ); : } <> _ refdtq: .blkb 8 .include mr100.inc .GLB task task: : PUSH.W R2 PUSH.
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 No. 1 2 3 Item Content Mailbox ID 1-255 Mailbox priority 1-255 Mailbox attribute TA_TFIFO: Waiting tasks enqueued in order of FIFO TA_TPRI: Waiting tasks enqueued in order of priority TA_MFIFO: Messages enqueued in order of FIFO TA_MPRI: Messages enqueued in order of priority Table 5.
snd_mbx isnd_mbx Send to mailbox Send to mailbox (handler only) [[ C Language API ]] ER ercd = snd_mbx( ID mbxid, T_MSG *pk_msg ); ER ercd = isnd_mbx( ID mbxid, T_MSG *pk_msg ); z Parameters ID mbxid ID number of the mailbox to which transmitted T_MSG *pk_msg Message to be transmitted z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
<> typedef struct user_msg{ T_MSG t_msg; B data[16]; } USER_MSG; /* T_MSG structure */ /* User message data */ <> typedef struct user_msg{ T_MSG_PRI t_msg; B data[16]; } USER_MSG; /* T_MSG_PRI structure */ /* User message data */ [[ Example program statement ]] <> #include #include #include “kernel_id.
rcv_mbx prcv_mbx iprcv_mbx trcv_mbx Receive from mailbox Receive from mailbox (polling) Receive from mailbox (polling, handler only) Receive from mailbox (with timeout) [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = rcv_mbx( ID mbxid, T_MSG **ppk_msg ); prcv_mbx( ID mbxid, T_MSG **ppk_msg ); iprcv_mbx( ID mbxid, T_MSG **ppk_msg ); trcv_mbx( ID mbxid, T_MSG **ppk_msg, TMO tmout ); z Parameters ID mbxid ID number of the mailbox from which to receive TMO tmout Timeout value (for trcv_m
[[ Functional description ]] This service call receives a message from the mailbox indicated by mbxid and stores the start address of the received message in the area pointed to by ppk_msg. T_MSG** should be specified with a 32-bit address. If data is present in the target mailbox, the data at the top of the mailbox is received.
[[ Example program statement ]] <> #include #include #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”); : : if( trcv_mbx((T_MSG **)&msg, ID_mbx,10) != E_TMOUT ) error(“Timeout\n”); : } <> .
ref_mbx iref_mbx Reference mailbox status Reference mailbox status (handler only) [[ C Language API ]] ER ercd = ref_mbx( ID mbxid, T_RMBX *pk_rmbx ); ER ercd = iref_mbx( ID mbxid, T_RMBX *pk_rmbx ); z Parameters ID mbxid ID number of the target mailbox T_RMBX *pk_rmbx Pointer to the packet to which mailbox status is returned z Return Parameters ER T_RMBX ercd *pk_rmbx Terminated normally (E_OK) Pointer to the packet to which mailbox status is returned Contents of pk_rmbx typedef struct t_rmbx{
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RMBX rmbx; ER ercd; : ercd = ref_mbx( ID_MBX1, &rmbx ); : } <> .include mr100.inc .GLB task _ refmbx: .blkb 6 task: : PUSH.W R2 PUSH.
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 No.
get_mpf pget_mpf ipget_mpf Aquire fixed-size memory block Aquire fixed-size memory block (polling) Aquire fixed-size memory block (polling, handler only) Aquire fixed-size memory block (with timeout) tget_mpf [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = get_mpf( ID mpfid, VP *p_blk ); pget_mpf( ID mpfid, VP *p_blk ); ipget_mpf( ID mpfid, VP *p_blk ); tget_mpf( ID mpfid, VP *p_blk,TMO tmout ); z Parameters ID mpfid ID number of the target fixed-size memory pool to be acquired VP *p_
z Register contents after service call is issued get_mpf,pget_mpf,ipget_mpf Register name Content after service call is issued R0 Error code R3R1 Start address of the acquired memory block R2 ID number of the target fixed-size memory pool to be acquired tget_mpf Register name Content after service call is issued R0 Error code R3R1 Start address of the acquired memory block R2 ID number of the target fixed-size memory pool to be acquired R6R4 Timeout value [[ Error code ]] E_RLWAI E_TMOUT EV_
[[ Example program statement ]] <> #include #include #include “kernel_id.h” VP 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”); } } <> .include mr100.inc .GLB task task: : PUSH.W R2 get_mpf #ID_MPF1 : PUSH.
rel_mpf irel_mpf Release fixed-size memory block Release fixed-size memory block (handler only) [[ C Language API ]] ER ercd = rel_mpf( ID mpfid, VP blk ); ER ercd = irel_mpf( ID mpfid, VP blk); z Parameters ID mpfid ID number of the fixed-size memory pool to be released VP blk Start address of the memory block to be returned z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { VP p_blf; if( get_mpf(ID_mpf1,&p_blf) != E_OK ) error(“Not enough memory \n”); : rel_mpf(ID_mpf1,p_blf); } <> .include mr100.inc .GLB task _g_blk: .blkb 4 task: : PUSH.W R2 get_mpf #ID_MPF1 : MOV.L R3R1,_g_blk PUSH.
ref_mpf iref_mpf Reference fixed-size memory pool status Reference fixed-size memory pool status (handler only) [[ C Language API ]] ER ercd = ref_mpf( ID mpfid, T_RMPF *pk_rmpf ); ER ercd = iref_mpf( ID mpfid, T_RMPF *pk_rmpf ); z Parameters ID mpfid Task ID waiting for memory block to be acquired T_RMPF *pk_rmpf Pointer to the packet to which fixed-size memory pool status is returned z Return Parameters ER T_RMPF ercd *pk_rmpf Terminated normally (E_OK) Pointer to the packet to which fixed-size
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RMPF rmpf; ER ercd; : ercd = ref_mpf( ID_MPF1, &rmpf ); : } <> .include mr100.inc .GLB task _ refmpf: .blkb 6 task: : PUSH.W R2 PUSH.
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 No.
pget_mpl Aquire variable-size memory block (polling) [[ C Language API ]] ER ercd = pget_mpl( ID mplid, UINT blksz, VP *p_blk ); z Parameters ID mplid ID number of the target Variable-size Memory pool to be acquired UINT blksz Memory size to be acquired (in bytes) VP *p_blk Pointer to the start address of the acquired variable memory z Return Parameters ER VP ercd *p_blk Terminated normally (E_OK) or error code Pointer to the start address of the acquired variable memory [[ Assembly language
[[ Functional description ]] 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 indeterminate. 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. This service call can be issued only from task context.
rel_mpl Release variable-size memory block [[ C Language API ]] ER ercd = rel_mpl( ID mplid, VP blk ); z Parameters ID mplid ID number of Variable-size Memory pool of the memory block to be released VP Blk Start address of the memory block to be returned z Return Parameters ER ercd Terminated normally (E_OK) or error code [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { VP p_blk; if( get_mpl(ID_mpl1, 200, &p_blk) != E_OK ) error(“Not enough memory \n”); : rel_mpl(ID_mp1,p_blk); } <> .include mr100.inc .GLB task _g_blk: .blkb 4 task: : PUSH.W R2 pget_mpl #ID_MPL1,#200 : MOV.L R3R1,_g_blk PUSH.
ref_mpl iref_mpl Reference variable-size memory pool status Reference variable-size memory pool status (handler only) [[ C Language API ]] ER ercd = ref_mpl( ID mplid, T_RMPL *pk_rmpl ); ER ercd = iref_mpl( ID mplid, T_RMPL *pk_rmpl ); z Parameters ID mplid ID number of the target variable-size memory pool T_RMPL *pk_rmpl Pointer to the packet to which variable-size memory pool status is returned z Return Parameters ER T_RMPL ercd *pk_rmpl Terminated normally (E_OK) Pointer to the packet to which
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RMPL rmpl; ER ercd; : ercd = ref_mpl( ID_MPL1, &rmpl ); : } <> .include mr100.inc .GLB task _ refmpl: .blkb 10 task: : PUSH.W R2 PUSH.
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 No. Item 1 2 3 4 Content System time value Unit of system time value System time updating cycle Initial value of system time (at initial startup) Unsigned 48 bits 1[ms] User-specified time tick updating time [ms] 000000000000H Table 5.18 List of Time Management Function Service Call No.
set_tim iset_tim Set system time Set system time (handler only) [[ C Language API ]] ER ercd = set_tim( SYSTIM *p_systim ); ER ercd = iset_tim( SYSTIM *p_systim ); z Parameters SYSTIM *p_systim Contents of p_systim typedef struct t_systim { UH utime UW ltime } SYSTIM; Pointer to the packet that indicates the system time to be set 0 +4 2 4 (16 high-order bits) (32 low-order bits) z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { SYSTIME time; /* Time data storing variable */ time.utime = 0; /* Sets upper time data */ time.ltime = 0; /* Sets lower time data */ set_tim( &time ); /* Sets the system time */ } <> .include mr100.inc .GLB task _g_systim: .WORD 1111H .
get_tim iget_tim Reference system time Reference system time (handler only) [[ C Language API ]] ER ercd = get_tim( SYSTIM *p_systim ); ER ercd = iget_tim( SYSTIM *p_systim ); z Parameters SYSTIM *p_systim Pointer to the packet to which current system time is returned z Return Parameters ER SYSTIM ercd *p_systim Contents of p_systim typedef struct t_systim { UH utime UW ltime } SYSTIM; Terminated normally (E_OK) Pointer to the packet to which current system time is returned 0 +4 2 4 (16 high-ord
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { SYSTIME time; /* Time data storing variable */ get_tim( &time ); /* Refers to the system time */ } <> .include mr100.inc .GLB task _g_systim: .
isig_tim Supply a time tick [[ Functional description ]] 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.
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 kernel concerned with them. Table 5.19 Specifications of the Cyclic Handler Function No.
sta_cyc ista_cyc Start cyclic handler operation Start cyclic handler operation (handler only) [[ C Language API ]] ER ercd = sta_cyc( ID cycid ); ER ercd = ista_cyc( ID cycid ); z Parameters ID cycid ID number of the cyclic handler to be operated z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : sta_cyc ( ID_cyc1 ); : } <> .include mr100.inc .GLB task task: : PUSH.
stp_cyc istp_cyc Stops cyclic handler operation Stops cyclic handler operation (handler only) [[ C Language API ]] ER ercd = stp_cyc( ID cycid ); ER ercd = istp_cyc( ID cycid ); z Parameters ID cycid ID number of the cyclic handler to be stopped z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
ref_cyc iref_cyc Reference cyclic handler status Reference cyclic handler status (handler only) [[ C Language API ]] ER ercd = ref_cyc( ID cycid, T_RCYC *pk_rcyc ); ER ercd = iref_cyc( ID cycid, T_RCYC *pk_rcyc ); z Parameters ID cycid ID number of the target cyclic handler T_RCYC *pk_rcyc Pointer to the packet to which cyclic handler status is returned z Return Parameters ER T_RCYC ercd *pk_rcyc Terminated normally (E_OK) Pointer to the packet to which cyclic handler status is returned Contents
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RCYC rcyc; ER ercd; : ercd = ref_cyc( ID_CYC1, &rcyc ); : } <> .include mr100.inc .GLB task _ refcyc: .blkb 6 task: : PUSH.W R2 PUSH.
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 kernel concerned with them. Table 5.21 Specifications of the Alarm Handler Function No.
sta_alm ista_alm Start alarm handler operation Start alarm handler operation (handler only) [[ C Language API ]] ER ercd = sta_alm( ID almid, RELTIM almtim ); ER ercd = ista_alm( ID almid, RELTIM almtim ); z Parameters ID almid ID number of the alarm handler to be operated RELTIM almtim Alarm handler startup time (relative time) z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : sta_alm ( ID_alm1,100 ); : } <> .include mr100.inc .GLB task task: : PUSH.
stp_alm istp_alm Stop alarm handler operation Stop alarm handler operation (handler only) [[ C Language API ]] ER ercd = stp_alm( ID almid ); ER ercd = istp_alm( ID almid ); z Parameters ID almid ID number of the alarm handler to be stopped z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
ref_alm iref_alm Reference alarm handler status Reference alarm handler status (handler only) [[ C Language API ]] ER ercd = ref_alm( ID almid, T_RALM *pk_ralm ); ER ercd = iref_alm( ID almid, T_RALM *pk_ralm ); z Parameters ID almid ID number of the target alarm handler T_RALM *pk_ralm Pointer to the packet to which alarm handler status is returned z Return Parameters ER T_RALM ercd *pk_ralm Contents of pk_ralm typedef struct t_ralm{ STAT almstat +0 RELTIM lefttim +2 Terminated normally (E_OK)
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { T_RALM ralm; ER ercd; : ercd = ref_alm( ID_ALM1, &ralm ); : } <> .include mr100.inc .GLB task _ refalm: .blkb 6 task: : PUSH.W R2 PUSH.
5.12 System Status Management Function Table 5.23 List of System Status Management Function Service Call No.
rot_rdq irot_rdq Rotate task precedence Rotate task precedence (handler only) [[ C Language API ]] ER ercd = rot_rdq( PRI tskpri ); ER ercd = irot_rdq( PRI tskpri ); z Parameters PRI tskpri Task priority to be rotated z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Functional description ]] 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. Figure 5-1 depicts the manner of how this is performed.
get_tid iget_tid Reference task ID in the RUNNING state Reference task ID in the RUNNING state (handler only) [[ C Language API ]] ER ercd = get_tid( ID *p_tskid ); ER ercd = iget_tid( ID *p_tskid ); z Parameters ID *p_tskid Pointer to task ID z Return Parameters ER ID ercd *p_tskid Terminated normally (E_OK) Pointer to task ID [[ Assembly language API ]] .include mr100.
loc_cpu iloc_cpu Lock the CPU Lock the CPU (handler only) [[ C Language API ]] ER ercd = loc_cpu(); ER ercd = iloc_cpu(); z Parameters None z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : loc_cpu(); : } <> .include mr100.inc .
unl_cpu iunl_cpu Unlock the CPU Unlock the CPU (handler only) [[ C Language API ]] ER ercd = unl_cpu(); ER ercd = iunl_cpu(); z Parameters None z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
dis_dsp Disable dispatching [[ C Language API ]] ER ercd = dis_dsp(); z Parameters None z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.inc dis_dsp z Parameters None z Register contents after service call is issued Register name Content after service call is issued R0 Error code [[ Error code ]] None [[ Functional description ]] This service call places the system into a dispatching disabled state.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task() { : dis_dsp(); : } <> .include mr100.inc .
ena_dsp Enables dispatching [[ C Language API ]] ER ercd = ena_dsp(); z Parameters None z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.inc ena_dsp z Parameters None z Register contents after service call is issued Register name Content after service call is issued R0 Error code [[ Error code ]] None [[ Functional description ]] This service call frees the system from a dispatching disabled state that was set by the dis_dsp service call.
sns_ctx Reference context [[ C Language API ]] BOOL state = sns_ctx(); z Parameters None z Return Parameters BOOL state TRUE: Non-task context FALSE: Task context [[ Assembly language API ]] .include mr100.
sns_loc Reference CPU state [[ C Language API ]] BOOL state = sns_loc(); z Parameters None z Return Parameters BOOL state TRUE: CPU locked state FALSE: CPU unlocked state [[ Assembly language API ]] .include mr100.
sns_dsp Reference dispatching state [[ C Language API ]] BOOL state = sns_dsp(); z Parameters None z Return Parameters BOOL state TRUE: Dispatching disabled state FALSE: Dispatching enabled state [[ Assembly language API ]] .include mr100.
sns_dpn Reference dispatching pending state [[ C Language API ]] BOOL state = sns_dpn(); z Parameters None z Return Parameters BOOL state TRUE: Dispatching pending state FALSE: Not dispatching pending state [[ Assembly language API ]] .include mr100.
5.13 Interrupt Management Function Table 5.24 List of Interrupt Management Function Service Call No. Service Call Function T 1 ret_int Returns from an interrupt handler Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a following meaning.
ret_int Returns from an interrupt handler (when written in assembly language) [[ C Language API ]] This service call cannot be written in C language. 36 [[ Assembly language API ]] .include mr100.inc ret_int z Parameters None [[ Error code ]] Not return to the interrupt handler that issued this service call. [[ Functional description ]] This service call performs the processing necessary to return from an interrupt handler.
5.14 System Configuration Management Function Table 5.25 List of System Configuration Management Function Service Call No. Service Call 1 2 ref_ver iref_ver Function [S] References version information T O N O Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a following meaning.
ref_ver iref_ver Reference version information Reference version information (handler only) [[ C Language API ]] ER ercd = ref_ver( T_RVER *pk_rver ); ER ercd = iref_ver( T_RVER *pk_rver ); z Parameters T_RVER *pk_rver Contents of pk_rver typedef struct t_rver { UH maker UH prid UH spver UH prver UH prno[4] } T_RVER; Pointer to the packet to which version information is returned 0 +2 +4 +6 +8 2 2 2 2 2 Kernel manufacturer code Kernel identification number ITRON specification version number Kernel v
[[ Functional description ]] 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.
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 No. 1 2 3 4 Item Content Data queue ID Capacity (data bytes) in data queue area Data size Data queue attribute 1-255 0-16383 16 bits TA_TFIFO: Waiting tasks enqueued in order of FIFO TA_TPRI: Waiting tasks enqueued in order of priority Table 5.
vsnd_dtq vpsnd_dtq vipsnd_dtq vtsnd_dtq vfsnd_dtq vifsnd_dtq Send to Short data queue Send to Short data queue (polling) Send to Short data queue (polling, handler only) Send to Short data queue (with timeout) Forced send to Short data queue Forced send to Short data queue (handler only) [[ C Language API ]] ER ER ER ER ER ER ercd ercd ercd ercd ercd ercd = = = = = = vsnd_dtq( ID vdtqid, H data ); vpsnd_dtq( ID vdtqid, H data ); vipsnd_dtq( ID vdtqid, H data ); vtsnd_dtq( ID vdtqid, H data, TMO tmout )
[[ Error code ]] E_RLWAI E_TMOUT E_ILUSE EV_RST Forced release from waiting Polling failure or timeout or timed out Service call improperly used (vfsnd_dtq or vifsnd_dtq is issued for a Short data queue whose dtqcnt = 0) Released from a wait state by clearing of the Short data queue area [[ Functional description ]] This service call sends the signed 2-byte data indicated by data to the Short data queue indicated by vdtqid.
[[ Example program statement ]] <> #include #include #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”); } : if( vfsnd_dtq( ID_dtq, data[3]) != E_OK ){ error(“error\n”); } : } <> .include mr100.
vrcv_dtq vprcv_dtq viprcv_dtq vtrcv_dtq Receive from Short data queue Receive from Short data queue (polling) Receive from Short data queue (polling,handler only) Receive from Short data queue (with timeout) [[ C Language API ]] ER ER ER ER ercd ercd ercd ercd = = = = vrcv_dtq( ID dtqid, H *p_data ); vprcv_dtq( ID dtqid, H *p_data ); viprcv_dtq( ID dtqid, H *p_data ); vtrcv_dtq( ID dtqid, H *p_data, TMO tmout ); z Parameters ID vdtqid ID number of the Short data queue from which to receive TMO tmo
[[ Functional description ]] 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.
[[ Example program statement ]] <> #include #include #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”); : } <> .include mr100.inc .GLB task task: : PUSH.W R2 PUSHM R6R4 vtrcv_dtq #ID_DTQ1,#TMO_POL : PUSH.
vref_dtq viref_dtq Reference Short data queue status Reference Short data queue status (handler only) [[ C Language API ]] ER ercd = vref_dtq( ID vdtqid, T_RDTQ *pk_rdtq ); ER ercd = viref_dtq( ID vdtqid, T_RDTQ *pk_rdtq ); z Parameters ID vdtqid ID number of the target Short data queue T_RDTQ *pk_rdtq Pointer to the packet to which Short data queue status is returned z Return Parameters ER T_RDTQ ercd *pk_rdtq Terminated normally (E_OK) or error code Pointer to the packet to which Short data que
[[ Functional description ]] 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 dequeued). 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 dequeued). If no tasks are kept waiting, TSK_NONE is returned.
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. Table 5.28 List of Reset Function Service Call No.
vrst_dtq Clear data queue area [[ C Language API ]] ER ercd = vrst_dtq( ID dtqid ); z Parameters ID dtqid Data queue ID to be cleared z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task1(void) { : vrst_dtq( ID_dtq1 ); : } <> .include mr100.inc .GLB task task: : PUSH.
vrst_vdtq Clear Short data queue area [[ C Language API ]] ER ercd = vrst_vdtq( ID vdtqid ); z Parameters ID vdtqid Short data queue ID to be cleared z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task1(void) { : vrst_vdtq( ID_vdtq1 ); : } <> .include mr100.inc .GLB task task: : PUSH.
vrst_mbx Clear mailbox area [[ C Language API ]] ER ercd = vrst_mbx( ID mbxid ); z Parameters ID mbxid z Return Parameters ER ercd Mailbox ID to be cleared Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
[[ Example program statement ]] <> #include #include #include “kernel_id.h” void task1(void) { : vrst_mbx( ID_mbx1 ); : } <> .include mr100.inc .GLB task task: : PUSH.
vrst_mpf Clear fixed-size memory pool area [[ C Language API ]] ER ercd = vrst_mpf( ID mpfid ); z Parameters ID mpfid Fixed-size memory pool ID to be cleared z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
vrst_mpl Clear variable-size memory pool area [[ C Language API ]] ER ercd = vrst_mpl( ID mplid ); z Parameters ID mplid Variable-size memory pool ID to be cleared z Return Parameters ER ercd Terminated normally (E_OK) [[ Assembly language API ]] .include mr100.
6. 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 37, 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. If necessary, correct the sample startup program (crt0mr.a30) and section definition file (c_sec.inc or asm_sec.inc). 3.
HEW Configuration file C standard header file MR100 include file kernel.h Configurator cfg100 Include file kernel_id.h Include file mr100.inc Application include file Application C source Application Assembler source System data definition file sys_ram.inc, sys_rom.inc Startup program start.a30, crt0mr.a30 C compiler Jamp table file mrtable.a30 nc100 Relocatable Assembler as100 Create Jamp table utility mr100tbl Systemcall file ( .
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. This program consists of the following three tasks and one interrupt handler.
#include #include #include "kernel_id.
// System Definition system{ stack_size = 1024; priority = 5; system_IPL = 4; tick_nume = 10; }; //System Clock Definition clock{ mpu_clock = 20MHz; timer = A0; IPL = 4; }; //Task Definition task[1]{ name = ID_main; entry_address = main(); stack_size = 512; priority = 1; initial_start = ON; }; task[2]{ name = ID_image; entry_address = image(); stack_size = 512; priority = 2; }; task[3]{ name = ID_printer; entry_address = printer(); stack_size = 512; priority = 4; }; task[4]{ name = ID_idle; entry_address =
A> make -f makefile as100 -F -Dtest=1 crt0mr.a30 nc100 -c task.c ln100 @ln100.sub A> Figure 6.5 System Generation 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.
7. 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 = ID_task; entry_address = task(); stack_size = 100; priority = 3; }; 2. At the beginning of file, be sure to include "itron.h",”kernel.
#include #include #include "kernel_id.h" void task(void) { for(;;){ /* process */ } } 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 configuration file. 41 wup_tsk(ID_main); 8. To specify an event flag, semaphore, or mailbox, use the respective strings defined in the configuration file.
1. Describe the kernel interrupt handler as a function 43 2. Be sure to use the void type to declare the interrupt handler start function return value and argument. 3. At the beginning of file, be sure to include "itron.h",”kernel.h” which is in the system directory as well as "kernel_id.h" which is in the current directory. 4. Do not use the ret_int service call in the interrupt handler. 44 5. The static declared functions can not be registered as an interrupt handler. #include #include
1. Describe the cyclic or alarm handler as a function. 46 2. Be sure to declare the return value and argument of the interrupt handler start function as a void type. 3. At the beginning of file, be sure to include "itron.h",”kernel.h” which is in the system directory as well as "kernel_id.h" which is in the current directory. 4. The static declared functions cannot be registered as a cyclic handler or alarm handler. 5.
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. For the symbol indicating the task start address, make the external declaration. 47 3. Be sure that an infinite loop is formed for the task or the task is terminated by the ext_tsk service call. .INCLUDE mr100.
8. Set a task that is activated at MR100 system startup in the configuration file 48 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. For the symbol indicating the interrupt handler start address, make the external declaration(Global declaration). 49 3.
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. 51 3. Always use the RTS instruction (subroutine return instruction) to return from cyclic handlers and alarm handlers. For examples: .INCLUDE .GLB mr100.inc cychand ----- (1) ----- (2) cychand: : ; handler process : rts ----- (3) Figure 7.10 Example Handler Written in Assembly Language 51 Use the .GLB pseudo-directive.
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" by adding an initialization routine in C language. The startup programs perform the following: • Initialize the processor after a reset.
7.3.1 C Language Startup Program (crt0mr.a30) Figure 7.11 shows the C language startup program(crt0mr.a30).
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 ;-------------------------------------------------------; bss zero clear ;-------------------------------------------------------;-------------------------------------------------------; ; zero clear BSS ; ;---------
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 JSR.W .ENDIF __init_sem .IF .GLB JSR.W .ENDIF __NUM_DTQ __init_dtq __init_dtq .IF .GLB JSR.W .ENDIF __NUM_VDTQ __init_vdtq __init_vdtq .IF .GLB JSR.W .
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 ; +---------------------------------------------+ ; | System clock interrupt handler | ; +---------------------------------------------+ .GLB __SYS_STMR_INH .ALIGN __SYS_STMR_INH: ; process issue system call ; For PD100 __ISSUE_SYSCALL ; System timer interrupt handler _STMR_hdr ret_int .ENDIF .
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. Incorporate a system RAM area definition file [17 in Figure 7.11] 8. This is the initialization program __SYS_INITIAL that is activated immediately after a reset. [55 - 207 in Figure 7.
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. • c_sec.inc This file is used when you developed your applications with the C language. c_sec.inc is derived from "asm_sec.inc" by adding sections generated by C compiler NC100.
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. • MR_RAM section This section is where the RAM data, MR100's system management data, is stored that is referenced in absolute addressing. • stack section This section is provided for each task's user stack and system stack.
8. 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 applications 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.
It is also possible to enter operators in numerical values. Table 8.2 Operators lists the operators available. Table 8.2 Operators Operator () - (Unary_minus) ∗/% + - (Binary_minus) Priority High Low Direction of computation From left to right From right to left From left to right From loft to right 13. Numerical value examples are presented below.
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.
<< Content >> 1. System stack size [( Definition format )] Numeric value [( Definition range )] 6 or more [( Default value )] 400H Define the total stack size used in service call and interrupt processing. 2. Maximum value of priority (value of lowest priority) [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] 32 Define the maximum value of priority used in MR100's application programs. This must be the value of the highest priority used. 3.
[( System Clock Definition Procedure )] << Format >> // System Clock Definition clock{ timer_clock = MPU clock ; timer = Timers used for system clock ; IPL = System clock interrupt priority level ; }; << Content >> 1. MPU clock [( Definition format)] Frequency(in MHz) [( Definition range )] None [( Default value )] 15MHz Define the MPU operating clock frequency of the microcomputer in MHz units. 2.
[( Definition respective maximum numbers of items )] Here, define respective maximum numbers of items to be used in two or more applications.
5. The maximum number of semaphores defined [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] None Define the maximum number of semaphores defined. 6. The maximum number of fixed-size memory pools defined [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] None 7. The maximum number of variable length memory blocks defined.
[( Task definition )] << Format >> // Tasks Definition task[ ID No. ]{ name = entry_address = stack_size = priority = context = stack_section = initial_start = exinf = }; : : ID name ; Start task of address ; User stack size of task ; Initial priority of task ; Registers used ; Section name in which the stack is located ; TA_ACT attribute (initial startup state) ; Extended information ; The ID number must be in the range of 1 to 255. The ID number can be omitted.
3. User stack size of task [( Definition format )] Numeric value [( Definition range )] 12 or more [( Default value )] 256 Define the user stack size for each task. The user stack means a stack area used by each individual task. MR100 requires that a user stack area be allocated for each task, which amount to at least 12 bytes. 4.
8. Extended information [( Definition format )] Numeric value [( Definition range )] 0 to 0xFFFFFFFF [( Default value )] 0 Define the extended information of a task. This information is passed to the task as argument when it is restarted by a queued startup request, for example. [( Eventflag definition )] This definition is necessary to use Eventflag function. << Format >> // Eventflag Definition flag[ ID No.
4. Multi-wait attribute [( Definition format )] Symbol [( Definition range )] TA_WMUL or TA_WSGL [( Default value )] TA_WSGL Specify whether multiple tasks can be enqueued in the eventflag waiting queue. 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. 5.
2. Selecting a semaphore waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TPRI [( Default value )] TA_TFIFO Select a method in which tasks wait for the semaphore. If TA_TFIFO is selected, tasks are enqueued in order of FIFO. If TA_TPRI is selected, tasks are enqueued in order of priority beginning with the one that has the highest priority. 3.
2. Number of data [( Definition format )] Numeric Value [( Definition range )] 0 to 0x1FFF [( Default value )] 0 Specify the number of data that can be transmitted. What should be specified here is the number of data, and not a data size. 3. Selecting a data queue waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TRPI [( Default value )] TA_TFIFO Select a method in which tasks wait for data queue transmission.
3. Selecting a data queue waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TRPI [( Default value )] TA_TFIFO Select a method in which tasks wait for short data queue transmission. If TA_TFIFO is selected, tasks are enqueued in order of FIFO. If TA_TPRI is selected, tasks are enqueued in order of priority beginning with the one that has the highest priority. [( Mailbox definition )] This definition must always be set when the mailbox function is to be used.
4. Maximum message priority [( Definition format )] Numeric Value [( Definition range )] 1 to "maximum value of message priority" that was specified in "definition of maximum number of items" [( Default value )] 1 Specify the maximum priority of message in the mailbox. [( Fixed-size memory pool definition )] This definition must always be set when the fixed-size memory pool function is to be used. << Format >> // Fixed Memory pool Definition memorypool[ ID No.
4. Size (in bytes) [( Definition format )] Numeric value [( Definition range )] 4 to 65,535 [( Default value )] 256 Define the size of the memory pool per block. The RAM size to be used as a memory pool is determined by this definition: (number of blocks) x (size) in bytes. 5.
8. Section name [( Definition format )] Symbol [( Definition range )] None [( Default value )] MR_HEAP Define the name of the section in which the memory pool is located. The section defined here must always have an area allocated for it in the section file (asm_sec.inc or c_sec.inc). If no section names are defined, the memory pool is located in the MR_HEAP section. 9.
[( Cyclic handler definition )] This definition is necessary to use Cyclic handler function. << Format >> // Cyclic Handlar Definition cyclic_hand[ ID No. ]{ name = interval_counter = start = phsatr = phs_counter = entry_address = exitf = }; : : ID name ; Activation cycle ; TA_STA attribute ; TA_PHS attribute ; Activation phase ; Start address ; Extended information ; The ID number must be in the range of 1 to 255. The ID number can be omitted.
5. Activation phase [( Definition format )] Numeric value [( Definition range )] 0 to 0x7FFFFFFF [( Default value )] None 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 )] Symbol or Function Name [( Definition range )] None [( Default value )] None Define the start address of the cyclic handler.
2. Start address [( Definition format )] Symbol or Function Name [( Definition range )] None 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 )] Numeric value [( Definition range )] 0 to 0xFFFFFFFF [( Default value )] 0 Define the extended information of the alarm handler.
6. Switch passed to PRAGMA extended function [( Definition format )] Symbol [( Definition range )] E, F, B or R [( Default value )] None 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" instruction is output at return from the interrupt handler.
Table 8.
[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. (Always be sure to clear the B flag before issuing ret_int service call.
8.1.3 Configuration File Example The following is the configuration file example. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 //////////////////////////////////////////////////////////////////////////////// // // kernel.cfg : building file for MR100 Ver.1.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 wait_queue = TA_TFIFO; clear_attribute = NO; wait_multi = TA_WMUL; }; flag[2]{ name = ID_flg3; initial_pattern = 0x0000ffff; wait_queue = TA_TPRI; clear_attribute = YES; wait_multi = TA_WMUL; }; flag[]{ name = ID_flg
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 name = ID_mpf1; wait_queue = TA_TFIFO; section = MR_RAM; siz_block = 16; num_block = 5; }; memorypool[2]{ name = ID_mpf2; wait_queue = TA_TPRI; section = MR_RAM; siz_block = 32; num_block = 4
235 236 237 238 239 240 241 242 243 entry_address = alm2; name = ID_alm2; exinf = 0x12345678; }; // // End of Configuration // 253
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: • Configuration file (XXXX.
Configuration File System Data Difinition File xxx.cfg sys_ram.inc, sys_rom.inc Default Configuration File default.cfg Include File cfg100 mr100.inc Template File ID Number Definition File sys_ram.inc, mr100.inc kernel_id.h MR100 Version File Service call Definition File version kernel_sysint.h Service call Definition File kernel_sysint.h Figure 8.1 The operation of the Configurator 8.2.
8.2.3 Configurator Start Procedure Start the configurator as indicated below. C:\> cfg100 [-vV] [-Eipl] [-Wipl] Configuration file name 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. -Eipl Option Enable the check function of an IPL value.
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 configuration 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. cfg100 Error : Not enough memory Memory is insufficient. cfg100 Error : Illegal option --> The configurator's command option is erroneous.
cfg100 Error : System timer's vector conflict near line xxx A different vector is defined for the system clock timer interrupt vector. Confirm the vector No.x for interrupt vector definition. 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. cfg100 Error : is already defined near line xxx (xxxx.cfg) XXXX is already defined.
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. cfg100 Warning : Already definition XXXX near line xxx (xxxx.
9. 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. Table 9.1 Functions in the Sample Program Function Name main() Type Task task1() ID No. Priority Description 1 1 Starts task1 and task2. Task 2 2 Outputs "task1 running." task2() Task 3 3 Outputs "task2 running." cyh1() Handler 1 Wakes up task1().
9.2 Program Source Listing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 /************************************************************************* * MR100 smaple program * * COPYRIGHT(C) 2003(2005) RENESAS TECHNOLOGY CORPORATION * AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED * * * $Id: demo.c,v 1.
9.3 Configuration File 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 //************************************************************************* // // COPYRIGHT(C) 2003,2005 RENESAS TECHNOLOGY CORPORATION // AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED // // MR100 System Configuration File. // "$Id: smp.cfg,v 1.
263
10. 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 between the stacks. z 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. z System stack This stack is used inside the MR100 or during the execution of the handler.
SFR System Stack User satck of TaskID No.1 User satck of TaskID No.2 Stack Section User satck of TaskID No.n Figure 10.
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. z When an application is written in the C language Using the stack size calculation utility of NC100, calculate the stack size of each task.
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 Figure 2.
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 occurrence of multiple interrupts. 55 The necessary size (the maximum size) of the system stack can be obtained from the following relation: Necessary size of the system stack = αΣ βi( γ) zα The maximum system stack size among the service calls to be used. 56. When sta_tsk, ext_tsk, and dly_tsk are used for example, according to the Table 10.
α:The maximum system stack size among the service calls to be used. α βι:The system stack size to be used by the interrupt handler. β1 β2 Interrupt Interrupt βn The necessary system stack Figure 10.
[( 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. Refer to the manual of for the stack size calculation utility detailed use of it.
[( 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 C language Using the stack size calculation utility of NC100, calculate the stack size of each Alarm or Cyclic handler.
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.
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.
11. 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. Table 11.1 Interrupt Number Assignment Interrupt No.
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.
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.
12. Appendix 12.
12.
----Formats related to Variable-size Memory pool---typedef struct t_rmpl { ID wtskid; /* ID number of task at the top of memory acquisition waiting queue */ SIZE fmplsz; /* Total size of free areas */ UINT fblksz; /* Maximum memory block size that can be acquired immediately */ } T_RMPL; ----Formats related to cyclic handler---typedef struct t_rcyc { STAT cycstat; /* Operating status of cyclic handler */ RELTIM lefttim; /* Remaining time before cyclic handler starts */ } T_RCYC; ----Formats related to alarm
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 execution of a service call routine by a software interrupt. If you issue service calls directly without using a service call invocation macro, your program may not be guaranteed of compatibility with future versions of MR100.
Task Dependent Synchronization Function Parameter ServiceCall INTNo.
Synchronization & Communication Function Parameter ServiceCall rcv_dtq INTNo.
Interrupt Management Functions ServiceCall ret_int INTNo. Parameter ReturnParameter FuncCode A0 R0 251 -- -- System State Management Functions ServiceCall INTNo.
Memorypool Management Functions ServiceCall ReturnParameter Parameter INTNo.
System Configuration Management Functions Parameter ServiceCall INTNo. FuncCode A0 ReturnParameter A1 R0 ref_ver 250 160 pk_rver ercd iref_ver 250 160 pk_rver ercd Extenden Function(Reset Function) Parameter ServiceCall INTNo.
- 288 -
Real-time OS for R32C/100 Series M3T-MR100/4 User's Manual Publication Date: September. 16, 2007 Rev.1.00 Published by: Sales Strategic Planning Div. Renesas Technology Corp. Edited by: Application Engineering Department 1 Renesas Solutions Corp. © 2007. Renesas Technology Corp. and Renesas Solutions Corp.
M3T-MR100/4 User's Manual