M3T-MR100/4 V.1.00User’s ManualREJ10J1523-0100 Real-time OS for R32C/100 Series Rev.1.00 September 16, 2007
viii List of Figures Figure 3.1 Relationship between Program Size and Development Period...- 7 - Figure 3.2 Microcom
- 86 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call places the issuing task itself from RUNNING state into sleeping
- 87 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 88 - wup_tsk Wakeup task iwup_tsk Wakeup task (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = wup_tsk( ID tskid ); ER ercd = i
- 89 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 90 - can_wup Cancel wakeup request ican_wup Cancel wakeup request (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER_UINT wupcnt = can_
- 91 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #i
- 92 - rel_wai Release task from waiting irel_wai Release task from waiting (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = rel
- 93 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 94 - sus_tsk Suspend task isus_tsk Suspend task (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = sus_tsk( ID tskid ); ER ercd =
- 95 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
ix Figure 6.3 Configuration File Example ...- 209 - Figure 6.4 Co
- 96 - rsm_tsk Resume suspended task irsm_tsk Resume suspended task(handler only) frsm_tsk Forcibly resume suspended task ifrsm_tsk Forcibly resum
- 97 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 98 - dly_tsk Delay task [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = dly_tsk(RELTIM dlytim); zz PPaarraammeetteerrss RELTIM dlytim Delay
- 99 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 100 - 5.3 Synchronization & Communication Function (Semaphore) Specifications of the semaphore function of MR100 are listed in Table 5.5. T
- 101 - sig_sem Release semaphore resource isig_sem Release semaphore resource (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = s
- 102 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 103 - wai_sem Acquire semaphore resource pol_sem Acquire semaphore resource (polling) ipol_sem Acquire semaphore resource (polling, handler only)
- 104 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call acquires one semaphore resource from the semaphore indicated by
- 105 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 106 - ref_sem Reference semaphore status iref_sem Reference semaphore status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd =
- 107 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 108 - 5.4 Synchronization & Communication Function (Eventflag) Specifications of the eventflag function of MR100 are listed in Table 5.7. T
- 109 - set_flg Set eventflag iset_flg Set eventflag (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = set_flg( ID flgid, FLGPTN s
- 110 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 111 - clr_flg Clear eventflag iclr_flg Clear eventflag (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = clr_flg( ID flgid, FLGP
- 112 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 113 - wai_flg Wait for eventflag pol_flg Wait for eventflag(polling) ipol_flg Wait for eventflag(polling, handler only) twai_flg Wait for even
- 114 - [[[[ EErrrroorr ccooddee ]]]] E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out E_ILUSE Service c
- 115 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
xi List of Tables Table 3.1 Task Context and Non-task Context ...- 28 - Tab
- 116 - ref_flg Reference eventflag status iref_flg Reference eventflag status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd =
- 117 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 118 - 5.5 Synchronization & Communication Function (Data Queue) Specifications of the data queue function of MR100 are listed in Table 5.9.
- 119 - snd_dtq Send to data queue psnd_dtq Send to data queue (polling) ipsnd_dtq Send to data queue (polling, handler only) tsnd_dtq Send to d
- 120 - [[[[ EErrrroorr ccooddee ]]]] E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out E_ILUSE Service cal
- 121 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 122 - rcv_dtq Receive from data queue prcv_dtq Receive from data queue (polling) iprcv_dtq Receive from data queue (polling, handler only) trcv
- 123 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call receives data from the data queue indicated by dtqid and store
- 124 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 125 - ref_dtq Reference data queue status iref_dtq Reference data queue status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd
xii
- 126 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 127 - 5.6 Synchronization & Communication Function (Mailbox) Specifications of the mailbox function of MR100 are listed in Table 5.11. Table
- 128 - snd_mbx Send to mailbox isnd_mbx Send to mailbox (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = snd_mbx( ID mbxid, T_M
- 129 - <<Example format of a message>> typedef struct user_msg{ T_MSG t_msg; /* T_MSG structure */ B data[16]; /* User me
- 130 - rcv_mbx Receive from mailbox prcv_mbx Receive from mailbox (polling) iprcv_mbx Receive from mailbox (polling, handler only) trcv_mbx Recei
- 131 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call receives a message from the mailbox indicated by mbxid and sto
- 132 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 133 - ref_mbx Reference mailbox status iref_mbx Reference mailbox status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = ref_
- 134 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 135 - 5.7 Memory Pool Management Function (Fixed-size Memory Pool) Specifications of the fixed-size memory pool function of MR100 are listed in
- 1 - 1. User’s Manual Organization The MR100 User’s Manual consists of nine chapters and thee appendix. • 2 General Information Outlines the object
- 136 - get_mpf Aquire fixed-size memory block pget_mpf Aquire fixed-size memory block (polling) ipget_mpf Aquire fixed-size memory block (polling,
- 137 - zz RReeggiisstteerr ccoonntteennttss aafftteerr sseerrvviiccee ccaallll iiss iissssuueedd get_mpf,pget_mpf,ipget_mpf Register name
- 138 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #i
- 139 - rel_mpf Release fixed-size memory block irel_mpf Release fixed-size memory block (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] E
- 140 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 141 - ref_mpf Reference fixed-size memory pool status iref_mpf Reference fixed-size memory pool status (handler only) [[[[ CC LLaanngguuaaggee
- 142 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 143 - 5.8 Memory Pool Management Function (Variable-size Memory Pool) Specifications of the Variable-size Memory pool function of MR100 are list
- 144 - pget_mpl Aquire variable-size memory block (polling) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = pget_mpl( ID mplid, UINT blksz, VP
- 145 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call acquires a memory block from the variable-size memory pool ind
- 146 - rel_mpl Release variable-size memory block [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = rel_mpl( ID mplid, VP blk ); zz PPaarraammee
- 147 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 148 - ref_mpl Reference variable-size memory pool status iref_mpl Reference variable-size memory pool status (handler only) [[[[ CC LLaanngguu
- 149 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 150 - 5.9 Time Management Function Specifications of the time management function of MR100 are listed in Table 5.17. Table 5.17 Specifications o
- 151 - set_tim Set system time iset_tim Set system time (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = set_tim( SYSTIM *p_sys
- 152 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 153 - get_tim Reference system time iget_tim Reference system time (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = get_tim( S
- 154 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 155 - isig_tim Supply a time tick [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call updates the system time. The isig
- 3 - 2. General Information 2.1 Objective of MR100 Development In line with recent rapid technological advances in microcomputers, the functions of
- 156 - 5.10 Time Management Function (Cyclic Handler) Specifications of the cyclic handler function of MR100 are listed in Table 5.19. The cyclic
- 157 - sta_cyc Start cyclic handler operation ista_cyc Start cyclic handler operation (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]]
- 158 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 159 - stp_cyc Stops cyclic handler operation istp_cyc Stops cyclic handler operation (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER
- 160 - ref_cyc Reference cyclic handler status iref_cyc Reference cyclic handler status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]]
- 161 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 162 - 5.11 Time Management Function (Alarm Handler) Specifications of the alarm handler function of MR100 are listed in Table 5.21. The alarm han
- 163 - sta_alm Start alarm handler operation ista_alm Start alarm handler operation (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER e
- 164 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 165 - stp_alm Stop alarm handler operation istp_alm Stop alarm handler operation (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER erc
- 4 - the greater part of program debugging can be initiated simply by observing the small modules. 4. Timer control is made easier. To perform p
- 166 - ref_alm Reference alarm handler status iref_alm Reference alarm handler status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER
- 167 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 168 - 5.12 System Status Management Function Table 5.23 List of System Status Management Function Service Call System State No. Service Call F
- 169 - rot_rdq Rotate task precedence irot_rdq Rotate task precedence (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = rot_rdq(
- 170 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call rotates the ready queue whose priority is indicated by tskpri. I
- 171 - get_tid Reference task ID in the RUNNING state iget_tid Reference task ID in the RUNNING state (handler only) [[[[ CC LLaanngguuaaggee
- 172 - loc_cpu Lock the CPU iloc_cpu Lock the CPU (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = loc_cpu(); ER ercd = iloc_cp
- 173 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 174 - unl_cpu Unlock the CPU iunl_cpu Unlock the CPU (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = unl_cpu(); ER ercd = iun
- 175 - dis_dsp Disable dispatching [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = dis_dsp(); zz PPaarraammeetteerrss None zz RReettuurrnn
- 5 - 2.2 Relationship between TRON Specification and MR100 MR100 is the real-time operating system developed for use with the R32C/10 series of 3
- 176 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 177 - ena_dsp Enables dispatching [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = ena_dsp(); zz PPaarraammeetteerrss None zz RReettuurrnn
- 178 - sns_ctx Reference context [[[[ CC LLaanngguuaaggee AAPPII ]]]] BOOL state = sns_ctx(); zz PPaarraammeetteerrss None zz RReettuurrnn
- 179 - sns_loc Reference CPU state [[[[ CC LLaanngguuaaggee AAPPII ]]]] BOOL state = sns_loc(); zz PPaarraammeetteerrss None zz RReettuur
- 180 - sns_dsp Reference dispatching state [[[[ CC LLaanngguuaaggee AAPPII ]]]] BOOL state = sns_dsp(); zz PPaarraammeetteerrss None zz R
- 181 - sns_dpn Reference dispatching pending state [[[[ CC LLaanngguuaaggee AAPPII ]]]] BOOL state = sns_dpn(); zz PPaarraammeetteerrss Non
- 182 - 5.13 Interrupt Management Function Table 5.24 List of Interrupt Management Function Service Call System State No. Service Call Function
- 183 - ret_int Returns from an interrupt handler (when written in assembly language) [[[[ CC LLaanngguuaaggee AAPPII ]]]] This service
- 184 - 5.14 System Configuration Management Function Table 5.25 List of System Configuration Management Function Service Call System State No. Ser
- 185 - ref_ver Reference version information iref_ver Reference version information (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER e
z Active X, Microsoft, MS-DOS, Visual Basic, Visual C++, Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corporat
- 6 - 2.3 MR100 Features The MR100 offers the following features. 1. Real-time operating system conforming to the μITORN Specification. The MR100
- 186 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call reads out information about the version of the currently executi
- 187 - 5.15 Extended Function (Short Data Queue) Specifications of the Short data queue function of MR100 are listed in Table 5.26. This function
- 188 - vsnd_dtq Send to Short data queue vpsnd_dtq Send to Short data queue (polling) vipsnd_dtq Send to Short data queue (polling, handler only
- 189 - [[[[ EErrrroorr ccooddee ]]]] E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out E_ILUSE Service c
- 190 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 191 - vrcv_dtq Receive from Short data queue vprcv_dtq Receive from Short data queue (polling) viprcv_dtq Receive from Short data queue (pollin
- 192 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call receives data from the Short data queue indicated by vdtqid and
- 193 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 194 - vref_dtq Reference Short data queue status viref_dtq Reference Short data queue status (handler only) [[[[ CC LLaanngguuaaggee AAPPII
- 195 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call returns various statuses of the Short data queue indicated by vd
- 7 - 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 Nece
- 196 - 5.16 Extended Function (Reset Function) This function initializes the content of an object. This function is outside the scope of µITRON 4.
- 197 - vrst_dtq Clear data queue area [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = vrst_dtq( ID dtqid ); zz PPaarraammeetteerrss ID dtqi
- 198 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 199 - vrst_vdtq Clear Short data queue area [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = vrst_vdtq( ID vdtqid ); zz PPaarraammeetteerrss
- 200 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 201 - vrst_mbx Clear mailbox area [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = vrst_mbx( ID mbxid ); zz PPaarraammeetteerrss ID mbxid
- 202 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 203 - vrst_mpf Clear fixed-size memory pool area [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = vrst_mpf( ID mpfid ); zz PPaarraammeetteerr
- 204 - vrst_mpl Clear variable-size memory pool area [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = vrst_mpl( ID mplid ); zz PPaarraammeette
- 205 - 6. Applications Development Procedure Overview 6.1 Overview Application programs for MR100 should generally be developed following the proce
- 8 - Key inputmicrocomputerRemote controlmicrocomputerLED illuminationmicrocomputerArbitermicrocomputerVolume controlmicrocomputerMonitormicrocompu
- 206 - MR100 include file kernel.h Configuratorcfg100 Application object ROM write formatApplication C source Application Assembler source Jamp ta
- 207 - 6.2 Development Procedure Example This chapter outlines the development procedures on the basis of a typical MR100 application example. 6.
- 208 - #include <itron.h> #include <kernel.h> #include "kernel_id.h" void main() /* main task */ { printf("LBP
- 209 - // System Definition system{ stack_size = 1024; priority = 5; system_IPL = 4; tick_nume = 10; }; //System Clock Def
- 210 - A> make -f makefile as100 -F -Dtest=1 crt0mr.a30 nc100 -c task.c ln100 @ln100.sub A> Figure 6.5 System Ge
- 211 - 7. Detailed Applications 7.1 Program Coding Procedure in C Language 7.1.1 Task Description Procedure 1. Describe the task as a function. T
- 212 - #include <itron.h> #include <kernel.h> #include "kernel_id.h" void task(void) {
- 213 - 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
- 214 - 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 star
- 215 - 7.2 Program Coding Procedure in Assembly Language This section describes how to write an application using the assembly language. 7.2.1 W
- 9 - Key inputTaskRemote controlTaskLED illuminationTaskreal-timeOSVolume controlTaskMonitorTaskMechanicalcontrolTask Figure 3.3 Example System Con
- 216 - 8. Set a task that is activated at MR100 system startup in the configuration file 48 7.2.2 Writing Kernel Interrupt Handler When describi
- 217 - 1. At the beginning of file, be sure to include "mr100.inc" which is in the system directory. 2. For the symbol indicating the h
- 218 - 7.3 Modifying MR100 Startup Program MR100 comes with two types of startup programs as described below. • start.a30 This startup program i
- 219 - 7.3.1 C Language Startup Program (crt0mr.a30) Figure 7.11 shows the C language startup program(crt0mr.a30). 1 ; **************************
- 220 - 75 ;-------------------------------------------------------- 76 ; bss zero clear 77 ;-------------------------------------------------------
- 221 - 155 JSR.W __init_sem 156 .ENDIF 157 158 .IF __NUM_DTQ 159 .GLB __init_dtq 160 JSR.W __init_dtq 161 .ENDIF 162 163 .IF
- 222 - 235 ; +---------------------------------------------+ 236 ; | System clock interrupt handler | 237 ; +-------------------------
- 223 - The following explains the content of the C language startup program (crt0mr.a30). 4. Incorporate a section definition file [14 in Figure
- 224 - 7.4 Memory Allocation This section describes how memory is allocated for the application program data. Use the section file provided by MR
- 225 - 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 ass
- 10 - 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-microcompute
227 8. Using Configurator 8.1 Configuration File Creation Procedure When applications program coding and startup program modification are completed,
228 It is also possible to enter operators in numerical values. Table 8.2 Operators lists the operators available. Table 8.2 Operators Operator Pr
229 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
230 << Content >> 1. System stack size [( Definition format )] Numeric value [( Definition range )] 6 or more [( Default value )] 40
231 [( System Clock Definition Procedure )] << Format >> // System Clock Definition clock{ timer_clock = MPU clock ; timer
232 [( Definition respective maximum numbers of items )] Here, define respective maximum numbers of items to be used in two or more applications.
233 5. The maximum number of semaphores defined [( Definition format )] Numeric value [( Definition range )] 1 to 255 [( Default value )] None D
234 [( Task definition )] << Format >> // Tasks Definition task[ ID No. ]{ name = ID name ; entry_address = Start tas
235 3. User stack size of task [( Definition format )] Numeric value [( Definition range )] 12 or more [( Default value )] 256 Define the user
- 11 - During this interval, itappears that the key inputmicrocomputer is haled.Key inputTaskRemote controlTaskProgram executioninterruptProgram exe
236 8. Extended information [( Definition format )] Numeric value [( Definition range )] 0 to 0xFFFFFFFF [( Default value )] 0 Define the extende
237 4. Multi-wait attribute [( Definition format )] Symbol [( Definition range )] TA_WMUL or TA_WSGL [( Default value )] TA_WSGL Specify whether
238 2. Selecting a semaphore waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TPRI [( Default value )] TA_TFIFO
239 2. Number of data [( Definition format )] Numeric Value [( Definition range )] 0 to 0x1FFF [( Default value )] 0 Specify the number of data
240 3. Selecting a data queue waiting queue [( Definition format )] Symbol [( Definition range )] TA_TFIFO or TA_TRPI [( Default value )] TA_TFIF
241 4. Maximum message priority [( Definition format )] Numeric Value [( Definition range )] 1 to "maximum value of message priority"
242 4. Size (in bytes) [( Definition format )] Numeric value [( Definition range )] 4 to 65,535 [( Default value )] 256 Define the size of the m
243 8. Section name [( Definition format )] Symbol [( Definition range )] None [( Default value )] MR_HEAP Define the name of the section in which
244 [( Cyclic handler definition )] This definition is necessary to use Cyclic handler function. << Format >> // Cyclic Handlar Defini
245 5. Activation phase [( Definition format )] Numeric value [( Definition range )] 0 to 0x7FFFFFFF [( Default value )] None Define the activati
- 12 - R0PCSPRegisterKey inputTaskRemote controlTaskMemory mapStacksectionSFRR0PCSPR0PCSPSPLED illuminationTaskReal-timeOS Figure 3.7 Task Register
246 2. Start address [( Definition format )] Symbol or Function Name [( Definition range )] None Define the start address of the alarm handler. The
247 6. Switch passed to PRAGMA extended function [( Definition format )] Symbol [( Definition range )] E, F, B or R [( Default value )] None S
248 Table 8.3 List of vector number and vector address Vector number Vector address Interrupt 0 FFFFFFD0H Kernel reserved area 1 FFFFFFD4H Kernel
249 [Precautions] 1. Regarding the method for specifying a register bank No kernel interrupt handlers that use the registers in register bank 1 can
250 8.1.3 Configuration File Example The following is the configuration file example. 1 /////////////////////////////////////////////////////////
251 75 wait_queue = TA_TFIFO; 76 clear_attribute = NO; 77 wait_multi = TA_WMUL; 78 }; 79 flag[2]{ 80 name = ID_flg3; 81 initial_pattern = 0x0
252 155 name = ID_mpf1; 156 wait_queue = TA_TFIFO; 157 section = MR_RAM; 158 siz_block = 16; 159 num_block = 5; 160 }; 161 memorypool[2]{ 16
253 235 entry_address = alm2; 236 name = ID_alm2; 237 exinf = 0x12345678; 238 }; 239 240 241 // 242 // End of Configuration 243 //
254 8.2 Configurator Execution Procedures 8.2.1 Configurator Overview The configurator is a tool that converts the contents defined in the config
255 Configuration File xxx.cfg DefaultConfiguration File default.cfg Template File sys_ram.inc, mr100.inc MR100 Version File version System Data Di
- 13 - 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 sho
256 8.2.3 Configurator Start Procedure Start the configurator as indicated below. C:\> cfg100 [-vV] [-Eipl] [-Wipl] Configuration file n
257 8.2.5 Configurator Error Indications and Remedies If any of the following messages is displayed, the configurator is not normally functioning.
258 cfg100 Error : System timer's vector <x>conflict near line xxx A different vector is defined for the system clock timer interrupt vec
259 Warning messages The following message are a warning. A warning can be ignored providing that its content is understood. cfg100 Warning : syste
260 9. Sample Program Description 9.1 Overview of Sample Program As an example application of MR100, the following shows a program that outputs a
261 9.2 Program Source Listing 1 /************************************************************************* 2 * MR100 sm
262 9.3 Configuration File 1 //************************************************************************* 2 // 3 // COPYRIGHT(C) 2003,2005 RENESAS
263
264 10. Stack Size Calculation Method 10.1 Stack Size Calculation Method The MR100 provides two kinds of stacks: the system stack and the user stac
265 SFR System Stack User satck of TaskID No.1User satck of TaskID No.2User satck of TaskID No.nStack Section Figure 10.2: Layout of Stacks
- 14 - 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
266 10.1.1 User Stack Calculation Method User stacks must be calculated for each task. The following shows an example for calculating user stacks i
267 Stack growing direction jsr sub1 4bytes 24bytes(PC+FLG+size of re gisters used stack size used by sta_tsk) 36bytes(PC+FLG+size of registers us
268 10.1.2 System Stack Calculation Method The system stack is most often consumed when an interrupt occurs during service call processing followed
269 α β1 β2βn α:The maximum system stack size among the service calls to be used. βι:The system stack size to be used by the interrupt handler. The
270 [( Stack size βi used by interrupt handlers )] The stack size used by an interrupt handler that is invoked during a service call can be calculat
271 [( 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 use
272 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 b
273 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 ca
- 275 - 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
- 15 - 3.2.1 Service Call Processing When a service call is issued, processing takes place in the following sequence.6 1. The current register co
- 276 - 11.3 Regarding Delay Dispatching MR100 has four service calls related to delay dispatching. • dis_dsp • ena_dsp • loc_cpu • unl_cpu Th
- 277 - 11.4 Regarding Initially Activated Task MR100 allows you to specify a task that starts from a READY state at system startup. This specifica
- 279 - 12. Appendix 12.1 Data Type typedef signed char B; /* Signed 8-bit integer */ typedef signed short H; /* Signed 16-bit integer */ typed
- 280 - 12.2 Common Constants and Packet Format of Structure ----Common formats---- TRUE 1 /* True */ FALSE 0 /* False */ -
- 281 - ----Formats related to Variable-size Memory pool---- typedef struct t_rmpl { ID wtskid; /* ID number of task at the top of memory acq
- 282 - 12.3 Assembly Language Interface When issuing a service call in the assembly language, you need to use macros prepared for invoking service
- 283 - Task Dependent Synchronization Function Parameter ReturnParameterServiceCall INTNo. FuncCode A0 R2 R6R4 R0 slp_tsk 249 22 - - ercd wup_t
- 284 - Synchronization & Communication Function Parameter ReturnParameter ServiceCall INTNo. FuncCode A0 R3R1 R2 R6R4 A1 R0 R3
- 285 - Interrupt Management Functions Parameter ReturnParameterServiceCall INTNo. FuncCode A0 R0 ret_int 251 -- -- System State Management Functi
i Preface The M3T-MR100/4(abbreviated as MR100) is a real-time operating system1 for the R32C/100 series
- 16 - 3.2.2 Processing Procedures for Service Calls from Handlers When a service call is issued from a handler, task switching does not occur unl
- 286 - Memorypool Management Functions Parameter ReturnParam-eter Service-Call INT-No. Func-Code A0 R1 R2 R3 R6R4 A1 R0 R3R1 get_mpf 249
- 287 - System Configuration Management Functions Parameter ReturnParameterServiceCall INTNo. FuncCode A0 A1 R0 ref_ver 250 160 pk_rver ercd iref_v
- 288 -
Real-time OS for R32C/100 Series M3T-MR100/4 User's Manual Publication Date: September. 16, 2007
M3T-MR100/4User's Manual
- 17 - Service Calls from a Handler That Caused an Interrupt during Task Execution Scheduling (task switching) is initiated by the ret_int service
- 18 - Service Calls from a Handler That Caused an Interrupt during Service Call Processing Scheduling (task switching) is initiated after the syst
- 19 - Service Calls from a Handler That Caused an Interrupt during Handler Execution Let us think of a situation in which an interrupt occurs duri
- 20 - 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
- 21 - 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 w
- 22 - Forced termination request from other task SUSPENDED state clearrequest from other task SUSPEND requestfrom other task READY stateRUNNING sta
- 23 - ♦ A currently executed task has placed itself in the WAITING state.10 ♦ A currently executed task has changed its own priority by chg_pri o
- 24 - tasks in the RUNNING, READY, or WAITING state.12 If the suspend request is made to a task in the SUS-PENDED state, an error code is returned.
- 25 - 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
- 26 - 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
- 27 - 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,
- 28 - 3.5 System States 3.5.1 Task Context and Non-task Context The system runs in either context state, "task context" or "non-t
- 29 - Subroutine callTimer interruptRTSCyclic handlerAlarm handlerSystem clockinterrupt handlerTask Figure 3.21 Cyclic Handler/Alarm Handler Activa
- 30 - 3.5.2 Dispatch Enabled/Disabled States The system assumes either a dispatch enabled state or a dispatch disabled state. In a dispatch dis
- 31 - 3.6 Regarding Interrupts 3.6.1 Types of Interrupt Handlers MR100's interrupt handlers consist of kernel interrupt handlers and non-ke
- 32 - 3.6.3 Controlling Interrupts Interrupt enable/disable control in a service call is accomplished by IPL manipulation. The IPL value in a ser
- 33 - • 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 i
- 34 - 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 s
- 35 - 4. Kernel 4.1.1 Module Structure The MR100 kernel consists of the modules shown in Figure 4.1. Each of these modules is composed of functions
iii Contents Requirements for MR100 Use ...
- 36 - 4.1.2 Module Overview The MR100 kernel modules are outlined below. • Scheduler Forms a task processing queue based on task priority and co
- 37 - 4.1.3 Task Management Function The task management function is used to perform task operations such as task start/stop and task priority up
- 38 - 1 Task APriority 2 Task CTask FTask ETask D 3 n Task BTask BWhen the priority of task B has been changed from 3 to 1 Figure 4.3 Alteration
- 39 - 4.1.4 Synchronization functions attached to task The task-dependent synchronization functions attached to task is used to accomplish synchr
- 40 - • Suspend task (sus_tsk, isus_tsk) • Resume suspended task (rsm_tsk, irsm_tsk) These service calls forcibly keep a task suspended for exec
- 41 - • Forcibly resume suspended task (frsm_tsk, ifrsm_tsk) Clears the number of suspension requests nested to 0 and forcibly resumes execution
- 42 - • 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 w
- 43 - 4.1.5 Synchronization and Communication Function (Semaphore) The semaphore is a function executed to coordinate the use of devices and othe
- 44 - • Reference Semaphore Status (ref_sem, iref_sem) Refers the status of the target semaphore. Checks the count value and existence of the wait
- 45 - 4.1.6 Synchronization and Communication Function (Eventflag) The eventflag is an internal facility of MR100 that is used to synchronize the
iv 4.1.8 Synchronization and Communication Function (Mailbox)... - 48 - 4.1.9 Memory pool Manageme
- 46 - 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 fea
- 47 - 4.1.7 Synchronization and Communication Function (Data Queue) The data queue is a mechanism to perform data communication between tasks. In
- 48 - 4.1.8 Synchronization and Communication Function (Mailbox) The mailbox is a mechanism to perform data communication between tasks. In Figur
- 49 - T_MSG header T_MSG header T_MSG header Message queue Message A Message B Message C Figure 4.16 Message queue There are following data qu
- 50 - 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
- 51 - 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 s
- 52 - [[Comparison of Two Management Methods]] • Processing speed Generally speaking, the normal block method is faster in memory allocation/deal
- 53 - Memorypool TaskA rel_mpl top of address Memorypool Figure 4.19 rel_mpl processing • Reference Acquire Variable-size Memory Pool Status (re
- 54 - 4.1.11 Time Management Function The time management function provides system time management, time reading26, time setup27, and the functio
- 55 - 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 tim
v wai_flg Wait for eventflag... - 113 -
- 56 - 4.1.12 Cyclic Handler Function The cyclic handler is a time event handler that is started every startup cycle after a specified startup pha
- 57 - 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 han
- 58 - 4.1.14 System Status Management Function • Rotate Task Precedence (rot_rdq, irot_rdq) This service call establishes the TSS (time-sharing
- 59 - 4.1.15 Interrupt Management Function The interrupt management function provides a function to process requested external interrupts in real
- 60 - 4.1.16 System Configuration Management Function This function inspects the version information of MR100. • References Version Information(
- 61 - 4.1.18 Extended Function (Reset Function) The reset function is a function outside the scope of µITRON 4.0 Specification. It initializes
- 63 - 5. Service call reffernce 5.1 Task Management Function Specifications of the task management function of MR100 are listed in Table 5.1 below.
- 64 - Notes: • [S]: Standard profile service calls [B]: Basic profile service calls • Each sign within " System State " is a followi
- 65 - act_tsk Activate task iact_tsk Activate task (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = act_tsk( ID tskid ); ER ercd
vi ref_alm Reference alarm handler status... - 166 - iref_alm
- 66 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call starts the task indicated by tskid. The started task goes from DO
- 67 - can_act Cancel task activation request ican_act Cancel task activation request (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER_
- 68 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #i
- 69 - sta_tsk Activate task with a start code ista_tsk Activate task with a start code (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER
- 70 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call starts the task indicated by tskid. In other words, it places the
- 71 - ext_tsk Terminate invoking task [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = ext_tsk(); zz PPaarraammeetteerrss None zz RReettuur
- 72 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #i
- 73 - ter_tsk Terminate task [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = ter_tsk( ID tskid ); zz PPaarraammeetteerrss ID tskid ID numbe
- 74 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #i
- 75 - chg_pri Change task priority ichg_pri Change task priority(handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = chg_pri( ID ts
vii 7.2.3 Writing Non-kernel Interrupt Handler... - 216 - 7.2.4 Writi
- 76 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] The priority (base priority) of the task specified by tskid is changed to the value
- 77 - get_pri Reference task priority iget_pri Reference task priority(handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = get_pri(
- 78 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h> #
- 79 - ref_tsk Reference task status iref_tsk Reference task status (handler only) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = ref_tsk( ID
- 80 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call inspects the status of the task indicated by tskid and returns
- 81 - [[[[ EExxaammppllee pprrooggrraamm ssttaatteemmeenntt ]]]] <<Example statement in C language>> #include <itron.h>
- 82 - ref_tst Reference task status (simplified version) iref_tst Reference task status (simplified version, handler only) [[[[ CC LLaanngguuaa
- 83 - [[[[ FFuunnccttiioonnaall ddeessccrriippttiioonn ]]]] This service call inspects the status of the task indicated by tskid and returns th
- 84 - 5.2 Task Dependent Synchronization Function Specifications of the task-dependent synchronization function are listed in below. Table 5.3 S
- 85 - slp_tsk Put task to sleep tslp_tsk Put task to sleep (with timeout) [[[[ CC LLaanngguuaaggee AAPPII ]]]] ER ercd = slp_tsk(); ER ercd
Komentáře k této Příručce