background image

   

- 47 - 

 

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. 

 

Da
ta

 

Da
ta

 

Da
ta

 

Data 

Data 

Task B 

Task A 

 

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. The accumulated data is retrieved in order of FIFO

22

. However, the 

number of data that can be accumulated in the data queue is limited. If data is transmitted to the data queue that is full of 
data, the service call issuing task goes to a data transmission wait state. 

There are following data queue service calls that are provided by the MR100 kernel. 

 

Send to Data Queue(snd_dtq, tsnd_dtq) 

The data is transmitted to the data queue. If the data queue is full of data, the task goes to a data transmission wait 
state. 

 

Send to Data Queue (psnd_dtq, ipsnd_dtq) 

The data is transmitted to the data queue. If the data queue is full of data, the task returns error code without going 
to a data transmission wait state. 

 

Forced Send to Data Queue (fsnd_dtq, ifsnd_dtq) 

The data is transmitted to the data queue. If the data queue is full of data, the data at the top of the data queue or 
the oldest data is removed, and the transmitted data is stored at the tail of the data queue. 

 

Receive from Data Queue (rcv_dtq, trcv_dtq) 

The data is retrieved from the data queue. If the data queue has no data in it, the task is kept waiting until data is 
transmitted to the data queue. 

 

Receive from Data Queue (prcv_dtq,iprcv_dtq) 

The data is received from the data queue. If the data queue has no data in it, the task returns error code without 
going to a data reception wait state. 

 

Reference Data Queue Status (ref_dtq,iref_dtq) 

Checks to see if there are any tasks waiting for data to be entered in the target data queue and refers to the number 
of the data in the data queue. 

                                                      

22

  First In First Out 

Содержание Emulator System M3T-MR100

Страница 1: ...ok over all the business of both companies Therefore although the old company name remains in this document it is a valid Renesas Electronics document We appreciate your understanding Renesas Electron...

Страница 2: ...t for an application categorized as Specific or for which the product is not intended where you have failed to obtain the prior written consent of Renesas Electronics The quality grade of each Renesas...

Страница 3: ...M3T MR100 4 V 1 00 User s Manual User s Manual Rev 1 00 2007 09 Real time OS for R32C 100 Series...

Страница 4: ...recommended that customers contact Renesas Technology Corporation Renesas Solutions Corporation or an authorized Renesas Technology product distributor for the latest product information before purch...

Страница 5: ...nts a software overview and describes the corrections to the Users Manual and Reference Manual Users Manual PDF file Describes the procedures and precautions to observe when using the MR100 for progra...

Страница 6: ......

Страница 7: ...t during Handler Execution 19 3 3 Object 20 3 3 1 The specification method of the object in a service call 20 3 4 Task 21 3 4 1 Task Status 21 3 4 2 Task Priority and Ready Queue 25 3 4 3 Task Priorit...

Страница 8: ...ce task status simplified version 82 iref_tst Reference task status simplified version handler only 82 5 2 Task Dependent Synchronization Function 84 slp_tsk Put task to sleep 85 tslp_tsk Put task to...

Страница 9: ...uire fixed size memory block 136 pget_mpf Aquire fixed size memory block polling 136 ipget_mpf Aquire fixed size memory block polling handler only 136 tget_mpf Aquire fixed size memory block with time...

Страница 10: ...Short data queue with timeout 188 vfsnd_dtq Forced send to Short data queue 188 vifsnd_dtq Forced send to Short data queue handler only 188 vrcv_dtq Receive from Short data queue 191 vprcv_dtq Receiv...

Страница 11: ...pt vector definition 247 8 1 3 Configuration File Example 250 8 2 Configurator Execution Procedures 254 8 2 1 Configurator Overview 254 Executing the configurator requires the following input files 25...

Страница 12: ...er IPLs 31 Figure 3 23 Interrupt control in a Service Call that can be Issued from only a Task 32 Figure 3 24 Interrupt control in a Service Call that can be Issued from a Task independent 33 Figure 3...

Страница 13: ...el Interrupt Handler 213 Figure 7 5 Example Cyclic Handler Written in C Language 214 Figure 7 6 Example Infinite Loop Task Described in Assembly Language 215 Figure 7 7 Example Task Terminating with e...

Страница 14: ......

Страница 15: ...Table 5 16 List of Variable size memory pool Function Service Call 143 Table 5 17 Specifications of the Time Management Function 150 Table 5 18 List of Time Management Function Service Call 150 Table...

Страница 16: ...xii...

Страница 17: ...ications program development procedure for the MR100 7 Detailed Applications Presents useful information and precautions concerning applications program development with MR100 8 Using Configurator Des...

Страница 18: ......

Страница 19: ...enhance software production efficiency so as to increase the volume of possible software development per engineer One way to achieve this target would be to educate engineers to raise their level of...

Страница 20: ...numerous timers are provided for the microcomputer 5 Software maintainability is enhanced When the real time OS is put to use the developed software consists of small program modules called tasks The...

Страница 21: ...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 Of these s...

Страница 22: ...imum size MR100 is supplied in the object library format of the R32C 100 series Therefore the Linkage Editor functions are activated so that only necessary modules are automatically selected from nume...

Страница 23: ...an a schematic diagram However it indicates that the development period increases expo nentially with an increase in program size For example the development of four 8K byte programs is easier than th...

Страница 24: ...various functions so that program devel opment can easily be conducted by a number of engineers On the other hand there are the following disadvantages 1 The number of parts used increases thereby rai...

Страница 25: ...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 I...

Страница 26: ...a number of tasks appear to be executed simultaneously Time Key input Task Monitor Task Mechanical control Task Volume control Task LED illumination Task Remote control Task Figure 3 4 Time division T...

Страница 27: ...to save the currently executed task register contents into the associated task management memory area and recover the register contents for the task to switch to To establish the kernel therefore it...

Страница 28: ...12 R0 PC SP Register Key input Task Remote control Task Memory map Stack section SFR R0 PC SP R0 PC SP SP LED illumination Task Real time OS Figure 3 7 Task Register Area...

Страница 29: ...each task is stored in a stack area as shown in Figure 3 8 This figure shows the state prevailing after register storage Key input Task SP FLG R7R5 R6R4 A0 A1 PC SB FB R3R1 R2R0 SFR Key input task sta...

Страница 30: ...r processing operations can be initiated by such a service call See Figure 3 9 Key input Task Kernel Remote control task Service call Task switching Figure 3 9 Service call This service call is realiz...

Страница 31: ...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 The flowchart in Figure 3 10 shows the proces...

Страница 32: ...ce 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 A service call from a handler that caused...

Страница 33: ...t iset_flg TaskA Interrupt handler Save Registers Service call processing OS Restore Registers SP User Restore Registers Task selection TaskB Figure 3 11 Processing Procedure for a Service Call a Hand...

Страница 34: ...e interrupted service call processing See Figure 3 12 wup_tsk ret_int iset_flg Interrupt TaskA Interrupt handler Save Service call processing OS Restore Registers SP User Restore Registers Task select...

Страница 35: ...dler A execution issued a service call task switching does not take place during the exe cution of the service call ret_int service call returned from handler B but is effected by the ret_int service...

Страница 36: ...wed by another person he she does not understand at a glance what the No 2 task is To avoid such inconvenience the MR100 provides means of specifying the task by name function or symbol name The progr...

Страница 37: ...on RUNNING state While the system waits for key input task execution is not needed In that situation the key input task in the WAITING state Key input Task RUNNIG state WAITING state RUNNING state Wai...

Страница 38: ...ccurrence the interrupt handler has placed a different task having a higher priority in the READY state The priority assigned to the task has been changed by chg_pri or ichg_pri service call so that t...

Страница 39: ...task is placed into WAITING state for a wait request by one of these service calls In this case the task goes from WAITING state to READY state when the request is met or the specified time has elaps...

Страница 40: ...or tslp_tsk service call wakes up after the specified time elapse The request of the task placed in the WAITING state by the wai_flg wai_sem rcv_mbx snd_dtq rcv_dtq vsnd_dtq vrcv_dtq get_mpf tslp_tsk...

Страница 41: ...ormed immediately should be given higher priorities The MR100 permits giving the same priority to several tasks To provide proper control over the READY task execution order the kernel generates a tas...

Страница 42: ...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 n Priority 1 Pri...

Страница 43: ...counter Task wake up request storage area Flag wait mode This is a wait mode during eventflag wait Flag wait pattern This area stores the flag wait pattern when using the eventflag wait service call w...

Страница 44: ...interrupts OS independent interrupts and kernel interrupts OS dependent interrupts For details about each type of interrupt refer to Section 3 6 The system clock interrupt handler isig_tim is one of...

Страница 45: ...29 Subroutine call Timer interrupt RTS Cyclic handler Alarm handler System clock interrupt handler Task Figure 3 21 Cyclic Handler Alarm Handler Activation...

Страница 46: ...alls that can be issued from a CPU locked state are limited to those that are listed in Table 3 2 17 Table 3 2 Invocable Service Calls in a CPU Locked State loc_cpu iloc_cpu unl_cpu iunl_cpu ext_tsk e...

Страница 47: ...interrupt handler whose interrupt priority level is higher than a kernel interrupt mask level is called non kernel interrupt handler That is interruption priority level is from system_IPL 1 to 7 A ser...

Страница 48: ...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 Task Service call issued Service call processing I fla...

Страница 49: ...ice Call that can be Issued from a Task independent As shown in Figure 3 23 and Figure 3 24 the interrupt enable flag and IPL change in a service call For this reason if you want to disable interrupts...

Страница 50: ...ice call is issued from a task the MR100 switches the stack from the user stack to the system stack See Figure 3 25 The system stack use the interrupt stack ISP Task MR100 service call processing User...

Страница 51: ...ler module part of the task management module and part of the time manage ment module are linked at all times because they are essential feature functions The applications program is a program created...

Страница 52: ...mation Synchronization and Communication Module This is the function for synchronization and communication among the tasks The following four functional mod ules are offered Eventflag Checks whether t...

Страница 53: ...erefore not executed until it is restarted If startup requests are accumulated task startup processing is performed again In that case the is suing task behaves as if it were reset If written in C lan...

Страница 54: ...riority 4 When the priority of Task B is changed into 4 ID Number taskA taskB taskC taskB Figure 4 4 Task rearrangement in a waiting queue Reference task priority get_pri iget_pri Gets the priority of...

Страница 55: ...ccumulated Therefore if a wakeup request is issued to a task RUNNING state for example this wakeup request is temporar ily stored in memory Then when the task in RUNNING state is going to be placed in...

Страница 56: ...if issued to a task in WAIT ING state the task is placed into WAITING SUSPENDED state Since MR100 allows only one forcible wait re quest to be nested if sus_tsk is issued to a task in a forcible wait...

Страница 57: ...f a task and forcible resume Release task from waiting rel_wai irel_wai Forcibly frees a task from WAITING state A task is freed from WAITING state by this service call when it is in one of the follow...

Страница 58: ...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 uni...

Страница 59: ...emaphore is acquired or released to prevent competition for use of the same resource See Figure 4 11 Task Acquired Returned after use Figure 4 11 Semaphore Counter The MR100 kernel offers the followin...

Страница 60: ...lue and existence of the wait task for the target se maphore Figure 4 12 shows example task execution control provided by the wai_sem and sig_sem service calls Task Task Task Task Semaphore Counter wa...

Страница 61: ...entflag attribute There are following eventflag service calls that are provided by the MR100 kernel Set Eventflag set_flg iset_flg Sets the eventflag so that a task waiting the eventflag is released f...

Страница 62: ...ally from the top of the queue In this diagram the tasks that meet the wait conditions are task A task C and task E Out of these tasks task A task C and task E are removed from the queue If this event...

Страница 63: ...l of data the task goes to a data transmission wait state Send to Data Queue psnd_dtq ipsnd_dtq The data is transmitted to the data queue If the data queue is full of data the task returns error code...

Страница 64: ...s defined as shown below T_MSG Mailbox message header T_MSG_PRI Mailbox message header with priority included Messages in any size can be enqueued in the message queue because the header area is reser...

Страница 65: ...ssage is retrieved from the mailbox At this time if the mailbox has no mes sages in it the task is kept waiting until a message is sent to the mailbox Receive from Mailbox polling prcv_mbx iprcv_mbx R...

Страница 66: ...ervice calls is that if there are no blank memory blocks in the memory pool the task re turns error code without going to WAITING state Fixed Length Memorypool Memory Block 1 Memory Block 2 Memory Blo...

Страница 67: ...ntrol 8 byte Example of a configuration file variable_memorypool max_memsize 400 Maximum size heap_size 5000 If a variable size memory pool is defined as shown above the four kinds of fixed length blo...

Страница 68: ...ding it to the optimum block size among the four kinds of block sizes and then acquiring a memory block of the rounded size from the memory pool For example if the user requests 200 bytes of memory th...

Страница 69: ...address Memorypool 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 ar...

Страница 70: ...s returned The timeout time should be specified in ms units 50 tslp_tsk 50 READY state tslp_tsk 50 iwup_tsk E_OK E_TMOUT WAITING state WAITING state RUNNING state Timeout value Figure 4 20 Timeout Pro...

Страница 71: ...ck For example if the time tick interval is 10 ms and the specified timeout value is 35 ms then the timer times out at the fifth oc currence of the time tick Set System Time set_tim Reference System T...

Страница 72: ...clic handler created Activation phase Activation cycle Activation cycle Activation cycle Activation cycle Handler does not start Handler does not start Start operating Stop operating Handler does not...

Страница 73: ...Stop operating Handler does not start Handler starts Start operating Activation time Figure 4 23 Typical operation of the alarm handler Start Alarm Handler Operation sta_alm ista_alm Causes the alarm...

Страница 74: ...he RUNNING state If issued from the handler TSK_NONE 0 is ob tained instead of the ID number Lock the CPU loc_cpu iloc_cpu Places the system into a CPU locked state Unlock the CPU unl_cpu iunl_cpu Fre...

Страница 75: ...rrupt handler When using the C language 31 this function is automatically called at completion of the handler function In this case therefore there is no need to invoke this service call Figure 4 25 s...

Страница 76: ...The data is transmitted to the short data queue If the short data queue is full of data the task returns error code without going to a data transmission wait state Forced Send to Short Data Queue vfsn...

Страница 77: ...is returned Clear Mailbox Area vrst_mbx Initializes the mailbox Clear Fixed size Memory Pool Area vrst_mpf Initializes the fixed size memory pool If there are any tasks in WAITING state they are free...

Страница 78: ......

Страница 79: ...el language TA_ASM Tasks written in assem bly language 4 Task attribute TA_ACT Startup attribute 5 Task stack Section specifiable Table 5 2 List of Task Management Function Service Call System State N...

Страница 80: ...within System State is a following meaning T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled s...

Страница 81: ...ercd Terminated normally E_OK or error code A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc act_tsk TSKID iact_tsk TSKID z z P Pa ar ra am me et te er rs s TSKID ID numbe...

Страница 82: ...call cannot be guaranteed If the target task is not in DORMANT state a task activation request by this service call is enqueued In other words the activation request count is incremented by 1 The max...

Страница 83: ...ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after service call is issued R2R0 Canceled startup request count or error code E Er rr ro or r c co od de e None F Fu un nc ct ti...

Страница 84: ...te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task1 ER_UINT actcnt actcnt can_act ID_task2 void task2 ext_tsk Example statement in assembly...

Страница 85: ...normally E_OK or error code A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc sta_tsk TSKID STACD ista_tsk TSKID STACD z z P Pa ar ra am me et te er rs s TSKID ID number of...

Страница 86: ...is passed as parameter to the activated task If a task is restarted that was once terminated by ter_tsk or ext_tsk the task performs the following as it starts up 1 Initializes the current priority of...

Страница 87: ...on n This service call terminates the invoking task In other words it places the issuing task from RUNNING state into DOR MANT state However if the activation request count for the issuing task is 1...

Страница 88: ...ro og gr ra am m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task void ext_tsk Example statement in assembly language INCLUDE...

Страница 89: ...he issuing task itself F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call terminates the task indicated by tskid If the activation request count of the target task is e...

Страница 90: ...am m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task ter_tsk ID_main Example statement in assembly language INCLUDE mr100 in...

Страница 91: ...r code A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc chg_pri TSKID TSKPRI ichg_pri TSKID TSKPRI z z P Pa ar ra am me et te er rs s TSKID ID number of the target task TS...

Страница 92: ...llowing statement is written in a configuration file system stack_size 0x100 priority 13 then the specifiable range of priority is 1 to 13 If TSK_SELF is specified the priority base priority of the is...

Страница 93: ...t ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after service call is issued R0 Error code R2 Acquired task priority E Er rr ro or r c co od d...

Страница 94: ...at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task PRI p_tskpri ER ercd ercd get_pri ID_task2 p_tskpri Example statement in assembly la...

Страница 95: ...2 Waiting object ID TMO lefttmo 10 4 Left time before timeout UINT actcnt 14 4 Number of queued activation request counts UINT wupcnt 18 4 Number of queued wakeup request counts UINT suscnt 22 4 Numbe...

Страница 96: ...iting by slp_tsk or tslp_tsk TTW_DLY 0x0002 Kept waiting by dly_tsk TTW_SEM 0x0004 Kept waiting by wai_sem or twai_sem TTW_FLG 0x0008 Kept waiting by wai_flg or twai_flg TTW_SDTQ 0x0010 Kept waiting b...

Страница 97: ...Example statement in C language include itron h include kernel h include kernel_id h void task T_RTSK rtsk ER ercd ercd ref_tsk ID_main rtsk Example statement in assembly language _refdata blkb 26 in...

Страница 98: ...of pk_rtsk typedef struct t_rtst STAT tskstat 0 2 Task status STAT tskwait 2 2 Cause of wait T_RTST A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc ref_tst TSKID PK_RTST...

Страница 99: ...han a wait state TTS_WAI or TTS_WAS tskwait is indeterminate TTW_SLP 0x0001 Kept waiting by slp_tsk or tslp_tsk TTW_DLY 0x0002 Kept waiting by dly_tsk TTW_SEM 0x0004 Kept waiting by wai_sem or twai_se...

Страница 100: ...O 3 wup_tsk S B O O O O 4 iwup_tsk S B O O O O 5 can_wup B O O O O 6 ican_wup O O O O 7 rel_wai S B O O O O 8 irel_wai S B Releases task from waiting O O O O 9 sus_tsk S B O O O O 10 isus_tsk Suspends...

Страница 101: ...ode A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc slp_tsk tslp_tsk TMO z z P Pa ar ra am me et te er rs s TMO Timeout value z z R Re eg gi is st te er r c co on nt te e...

Страница 102: ...it goes to WAITING SUSPENDED state In this case even when the task is released from WAITING state by a task wakeup service call it still remains in SUSPENDED state and its execution cannot be resumed...

Страница 103: ...ent in C language include itron h include kernel h include kernel_id h void task if slp_tsk E_OK error Forced wakeup n if tslp_tsk 10 E_TMOUT error time out n Example statement in assembly language in...

Страница 104: ...ITING state to place it into READY or RUNNING state Or if the task specified by tskid is in WAIT ING SUSPENDED state this service call awakes the task from only the sleeping state so that the task goe...

Страница 105: ...e em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task if wup_tsk ID_main E_OK printf Can t wakeup main n Example statement in assembly language...

Страница 106: ...ve state F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call clears the wakeup request count of the target task indicated by tskid to 0 This means that because the tar g...

Страница 107: ...en nt t Example statement in C language include itron h include kernel h include kernel_id h void task ER_UINT wupcnt wupcnt can_wup ID_main if wup_cnt 0 printf wupcnt d n wupcnt Example statement in...

Страница 108: ...indicated by tskid is not an wait state F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call forcibly release the task indicated by tskid from waiting except SUSPENDED s...

Страница 109: ...e em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task if rel_wai ID_main E_OK error Can t rel_wai main n Example statement in assembly language...

Страница 110: ...the target task E Er rr ro or r c co od de e E_OBJ Object status invalid task indicated by tskid is an inactive state E_QOVR Queuing overflow F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti i...

Страница 111: ...m me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task if sus_tsk ID_main E_OK printf Can t suspend task main n Example statement in assembly langu...

Страница 112: ...ue ed d Register name Content after service call is issued R0 Error code R2 ID number of the target task E Er rr ro or r c co od de e E_OBJ Object status invalid task indicated by tskid is not a forci...

Страница 113: ...ge include itron h include kernel h include kernel_id h void task1 if rsm_tsk ID_main E_OK printf Can t resume main n if frsm_tsk ID_task2 E_OK printf Can t forced resume task2 n Example statement in...

Страница 114: ...has elapsed Therefore if specified dlytim 0 the task is placed into WAITING state briefly and then released from the WAITING state at the first time tick The task placed into WAITING state by invocati...

Страница 115: ...t ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task if dly_tsk E_OK error Forced wakeup n Example statement in assembly language inc...

Страница 116: ...S B O O O O 2 isig_sem S B Releases semaphore resource O O O O 3 wai_sem S B Acquires semaphore resource O O O 4 pol_sem S B O O O O 5 ipol_sem Acquires semaphore resource polling O O O O 6 twai_sem S...

Страница 117: ...ice call is issued R0 Error code R2 Semaphore ID number to which returned E Er rr ro or r c co od de e E_QOVR Queuing overflow F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This ser...

Страница 118: ...a at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task if sig_sem ID_sem E_QOVR error Overflow n Example statement in assembly language in...

Страница 119: ...error code A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc wai_sem SEMID pol_sem SEMID ipol_sem SEMID twai_sem SEMID TMO z z P Pa ar ra am me et te er rs s SEMID Semapho...

Страница 120: ...ified operation of the service call cannot be guar anteed If TMO_POL 0 is specified for tmout it means specifying 0 as a timeout value in which case the service call op erates the same way as pol_sem...

Страница 121: ...include kernel_id h void task if wai_sem ID_sem E_OK printf Forced wakeup n if pol_sem ID_sem E_OK printf Timeout n if twai_sem ID_sem 10 E_OK printf Forced wakeup or Timeout n Example statement in as...

Страница 122: ...EM iref_sem SEMID PK_RSEM z z P Pa ar ra am me et te er rs s SEMID ID number of the target semaphore PK_RSEM Pointer to the packet to which semaphore status is returned z z R Re eg gi is st te er r c...

Страница 123: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RSEM rsem ER ercd ercd ref_sem ID_sem1 rsem Example statement in assembly language _ refsem blkb 6 i...

Страница 124: ...Service Call System State No Service Call Function T N E D U L 1 set_flg S B O O O O 2 iset_flg S B Sets eventflag O O O O 3 clr_flg S B O O O O 4 iclr_flg Clears eventflag O O O O 5 wai_flg S B Wait...

Страница 125: ...e 32 bit eventflag indicated by flgid this service call sets the bits indicated by setptn In other words the value of the eventflag indicated by flgid is OR d with setptn If the alteration of the even...

Страница 126: ...m me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task void set_flg ID_flg FLGPTN 0xff000000 Example statement in assembly language include mr100 i...

Страница 127: ...R0 Error code R2 ID number of the eventflag to be cleared A1 Bit pattern to be cleared E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n Of the 32 bit...

Страница 128: ...m me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task void clr_flg ID_flg FLGPTN 0xf0f0f0f0 Example statement in assembly language include mr100 i...

Страница 129: ...d normally E_OK or error code FLGPTN p_flgptn Pointer to the area to which bit pattern is returned when released from wait A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc...

Страница 130: ...flg service call specify a wait time for tmout in ms units The values specified for tmout must be with in 0x7FFFFFFF time tick value If any value exceeding this limit is specified the service call may...

Страница 131: ...K error Wait Released n if pol_flg ID_flg2 FLGPTN 0x00000ff0 TWF_ORW flgptn E_OK printf Not set EventFlag n if twai_flg ID_flg2 FLGPTN 0x00000ff0 TWF_ANDW flgptn 5 E_OK error Wait Released n Example s...

Страница 132: ...FLGID PK_RFLG z z P Pa ar ra am me et te er rs s FLGID ID number of the target eventflag PK_RFLG Pointer to the packet to which eventflag status is returned z z R Re eg gi is st te er r c co on nt te...

Страница 133: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RFLG rflg ER ercd ercd ref_flg ID_FLG1 rflg Example statement in assembly language _ refflg blkb 6 i...

Страница 134: ...3 ipsnd_dtq S Sends to data queue polling O O O O 4 tsnd_dtq S Sends to data queue with timeout O O O 5 fsnd_dtq S O O O O 6 ifsnd_dtq S Forced sends to data queue O O O O 7 rcv_dtq S Receives from da...

Страница 135: ...ER ercd Terminated normally E_OK or error code A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc snd_dtq DTQID DTQDATA isnd_dtq DTQID DTQDATA psnd_dtq DTQID DTQDATA ipsnd_...

Страница 136: ...g 0 as a timeout value in which case the service call operates the same way as psnd_dtq Furthermore if specified as tmout TMO_FEVR 1 it means specifying an infinite wait in which case the service call...

Страница 137: ...LWAI 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 Example statement in a...

Страница 138: ...code VP_INT p_data Pointer to the start of the area in which received data is stored A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc rcv_dtq DTQID prcv_dtq DTQID iprcv_d...

Страница 139: ...nds to the call with the error code E_TMOUT For the trcv_dtq service call specify a wait time for tmout in ms units The values specified for tmout must be within 0x7FFFFFFF time tick value If any valu...

Страница 140: ...nel_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 Example statement...

Страница 141: ...a queue PK_RDTQ Pointer to the packet to which data queue status is returned z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su...

Страница 142: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RDTQ rdtq ER ercd ercd ref_dtq ID_DTQ1 rdtq Example statement in assembly language _ refdtq blkb 8 i...

Страница 143: ...l System State No Service Call Function T N E D U L 1 snd_mbx S B O O O O 2 isnd_mbx Send to mailbox O O O O 3 rcv_mbx S B Receive from mailbox O O O 4 prcv_mbx S B O O O O 5 iprcv_mbx Receive from ma...

Страница 144: ...header with priority included typedef struct t_msg T_MSG msgque 0 4 Message header PRI msgpri 2 2 Message priority T_MSG E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr...

Страница 145: ...ta USER_MSG E Ex xa am mp pl le e p pr ro og gr ra am m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h typedef struct pri_message T_MS...

Страница 146: ...g Pointer to the start of the area in which received message is stored A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc rcv_mbx MBXID prcv_mbx MBXID iprcv_mbx MBXID trcv_m...

Страница 147: ...hin 0x7FFFFFFF If any value exceeding this limit is specified the service call may not operate correctly If TMO_POL 0 is specified for tmout it means specifying 0 as a timeout value in which case the...

Страница 148: ...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...

Страница 149: ...the target mailbox PK_RMBX Pointer to the packet to which mailbox status is returned z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i i...

Страница 150: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RMBX rmbx ER ercd ercd ref_mbx ID_MBX1 rmbx Example statement in assembly language include mr100 inc...

Страница 151: ...cifiable by a section Table 5 14 List of Fixed size memory pool Function Service Call System State No Service Call Function T N E D U L 1 get_mpf S B Aquires fixed size memory block O O O 2 pget_mpf S...

Страница 152: ...e er rs s ID mpfid ID number of the target fixed size memory pool to be acquired VP p_blk Pointer to the start address of the acquired memory block TMO tmout Timeout value tget_mpf z z R Re et tu ur r...

Страница 153: ...der of priority If the issued service call was pget_mpf or ipget_mpf the task returns immediately and responds to the call with the error code E_TMOUT For the tget_mpf service call specify a wait time...

Страница 154: ...d 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 Example...

Страница 155: ...name Content after service call is issued R0 Error code R3R1 Start address of the memory block to be returned R2 ID number of the fixed size memory pool to be released E Er rr ro or r c co od de e No...

Страница 156: ...nclude itron h include kernel h 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 Example statement in assembly language include mr10...

Страница 157: ...MPFID PK_RMPF z z P Pa ar ra am me et te er rs s MPFID Task ID waiting for memory block to be acquired PK_RMPF Pointer to the packet to which fixed size memory pool status is returned z z R Re eg gi...

Страница 158: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RMPF rmpf ER ercd ercd ref_mpf ID_MPF1 rmpf Example statement in assembly language include mr100 inc...

Страница 159: ...not sup ported 5 Specification of memory pool area Area to be acquired specifiable by a section Table 5 16 List of Variable size memory pool Function Service Call System State No Service Call Function...

Страница 160: ...VP p_blk Pointer to the start address of the acquired variable memory A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc pget_mpl MPLID BLKSZ z z P Pa ar ra am me et te er...

Страница 161: ...l 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 It cannot be issued from non task...

Страница 162: ...the memory block to be returned z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after service...

Страница 163: ...de itron h include kernel h 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 Example statement in assembly language include mr100...

Страница 164: ...s ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc ref_mpl MPLID PK_RMPL iref_mpl MPLID PK_RMPL z z P Pa ar ra am me et te er rs s MPLID ID number of the target variable size m...

Страница 165: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RMPL rmpl ER ercd ercd ref_mpl ID_MPL1 rmpl Example statement in assembly language include mr100 inc...

Страница 166: ...000H Table 5 18 List of Time Management Function Service Call System State No Service Call Function T N E D U L 1 get_tim S 2 iget_tim Reference system time 3 set_tim S 4 iset_tim Set system time 5 is...

Страница 167: ...that indicates the system time to be set z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after...

Страница 168: ...include kernel h 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 Example st...

Страница 169: ...s SYSTIM A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc get_tim PK_TIM iget_tim PK_TIM z z P Pa ar ra am me et te er rs s PK_TIM Pointer to the packet to which current s...

Страница 170: ...e statement in C language include itron h include kernel h include kernel_id h void task SYSTIME time Time data storing variable get_tim time Refers to the system time Example statement in assembly la...

Страница 171: ...s if the system clock is defined by the configuration file The application cannot call this function because it is not implementing as service call When a time tick is supplied the kernel is processed...

Страница 172: ...bly language TA_STA Starts operation of cyclic handler 5 Cyclic handler attribute TA_PHS Saves activation phase Table 5 20 List of Cyclic Handler Function Service Call System State No Service Call Fun...

Страница 173: ...Content after service call is issued R0 Error code R2 ID number of the cyclic handler to be operated E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n...

Страница 174: ...a am m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task sta_cyc ID_cyc1 Example statement in assembly language include mr100 i...

Страница 175: ...n nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after service call is issued R0 Error code R2 ID number of the cyclic handler to b...

Страница 176: ...r of the target cyclic handler PK_RCYC Pointer to the packet to which cyclic handler status is returned z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca...

Страница 177: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RCYC rcyc ER ercd ercd ref_cyc ID_CYC1 rcyc Example statement in assembly language include mr100 inc...

Страница 178: ...level language 4 Alarm handler attribute TA_ASM Handlers written in assembly language Table 5 22 List of Alarm Handler Function Service Call System State No Service Call Function T N E D U L 1 sta_alm...

Страница 179: ...t after service call is issued R0 Error code R2 ID number of the alarm handler to be operated R6R4 Alarm handler startup time relative time E Er rr ro or r c co od de e None F Fu un nc ct ti io on na...

Страница 180: ...t ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task sta_alm ID_alm1 100 Example statement in assembly language include mr100 inc GLB...

Страница 181: ...nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after service call is issued R0 Error code R2 ID number of the alarm handler to be s...

Страница 182: ...rs s ALMID ID number of the target alarm handler PK_RALM Pointer to the packet to which alarm handler status is returned z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er r...

Страница 183: ...t Example statement in C language include itron h include kernel h include kernel_id h void task T_RALM ralm ER ercd ercd ref_alm ID_ALM1 ralm Example statement in assembly language include mr100 inc...

Страница 184: ..._dsp S B Disables dispatching O O O O 10 ena_dsp S B Enables dispatching O O O O 11 sns_ctx S References context O O O O O 12 sns_loc S References CPU state O O O O O 13 sns_dsp S References dispatchi...

Страница 185: ...et te er rs s ER ercd Terminated normally E_OK A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc rot_rdq TSKPRI irot_rdq TSKPRI z z P Pa ar ra am me et te er rs s TSKPRI T...

Страница 186: ...when using the rot_rdq service call the ready queue whose priority is that of the issuing task is rotated TPRI_SELF cannot be specified in the irot_rdq service call TPRI_SELF cannot be specified by ir...

Страница 187: ...issued R0 Error code R2 Acquired task ID E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call returns the task ID currently in RUNNING s...

Страница 188: ...the kernel interrupt mask level defined in the configurator 3 Only the following service calls can be invoked from a CPU locked state If any other service calls are invoked operation of the service c...

Страница 189: ...pr ro og gr ra am m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task loc_cpu Example statement in assembly language include mr...

Страница 190: ...the loc_cpu or iloc_cpu service call If the unl_cpu service call is issued from a dispatching enabled state task scheduling is performed If the system was put into a CPU locked state by invoking iloc_...

Страница 191: ...tures of a dispatching disabled state are outlined below 1 Since task scheduling is not performed anymore no tasks other than the issuing task itself will be placed into RUNNING state 2 Interrupts are...

Страница 192: ...pr ro og gr ra am m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task dis_dsp Example statement in assembly language include mr...

Страница 193: ...d de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call frees the system from a dispatching disabled state that was set by the dis_dsp service call As a result t...

Страница 194: ...s s i is ss su ue ed d Register name Content after service call is issued R0 TRUE Non Task context FALSE Task context E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri...

Страница 195: ...is ss su ue ed d Register name Content after service call is issued R0 TRUE CPU locked state FALSE CPUCPU unlocked state E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr...

Страница 196: ...ss su ue ed d Register name Content after service call is issued R0 TRUE Dispatching disabled state FALSE Dispatching enabled state E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d d...

Страница 197: ...i io on na al l d de es sc cr ri ip pt ti io on n This service call returns TRUE when the system is in a dispatching pending state or returns FALSE when the system is not in a dispatching pending stat...

Страница 198: ...rupt handler O O O O Notes S Standard profile service calls B Basic profile service calls Each sign within System State is a following meaning T Can be called from task context N Can be called from no...

Страница 199: ...d from an interrupt handler that was invoked from an interrupt that occurred within another interrupt the scheduler is not activated The scheduler is activated for interrupts from a task only When wri...

Страница 200: ...r References version information O O O O Notes S Standard profile service calls B Basic profile service calls Each sign within System State is a following meaning T Can be called from task context N C...

Страница 201: ...er 6 2 Kernel version number UH prno 4 8 2 Kernel product management information T_RVER z z R Re et tu ur rn n P Pa ar ra am me et te er rs s ER ercd Terminated normally E_OK A As ss se em mb bl ly y...

Страница 202: ...t with ITRON Specification Ver 4 03 00 is returned prver The code H 0100 denoting the version of the M3T MR100 4 is returned prno prno 0 Reserved for future extension prno 1 Reserved for future extens...

Страница 203: ...psnd_dtq O O O O 3 vipsnd_dtq Sends to short data queue polling O O O O 4 vtsnd_dtq Sends to short data queue with timeout O O O 5 vfsnd_dtq O O O O 6 vifsnd_dtq Forced sends to short data queue O O O...

Страница 204: ...ercd Terminated normally E_OK or error code A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc vsnd_dtq VDTQID DTQDATA visnd_dtq VDTQID DTQDATA vpsnd_dtq VDTQID DTQDATA vips...

Страница 205: ...ying 0 as a timeout value in which case the service call operates the same way as vpsnd_dtq Furthermore if specified as tmout TMO_FEVR 1 it means specifying an infinite wait in which case the service...

Страница 206: ...AI 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 Example statement in...

Страница 207: ...nter to the start of the area in which received data is stored A As ss se em mb bl ly y l la an ng gu ua ag ge e A AP PI I include mr100 inc vrcv_dtq VDTQID vprcv_dtq VDTQID viprcv_dtq VDTQID vtrcv_dt...

Страница 208: ...rns immediately and responds to the call with the error code E_TMOUT For the vtrcv_dtq service call specify a wait time for tmout in ms units The values specified for tmout must be within 0x7FFFFFFF I...

Страница 209: ...nel_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 Example statement i...

Страница 210: ...typedef struct t_rdtq ID stskid 0 2 Transmission waiting task ID ID wtskid 2 2 Reception waiting task ID UINT sdtqcnt 4 4 Data bytes contained in Short data queue T_RDTQ A As ss se em mb bl ly y l la...

Страница 211: ...the next task to be de queued If no tasks are kept waiting TSK_NONE is returned sdtqcnt Returned to sdtqcnt is the number of data bytes stored in the Short data queue area If this service call is to b...

Страница 212: ...eue area O O O O 3 vrst_mbx Clear mailbox area O O O O 4 vrst_mpf Clear fixed size memory pool area O O O O 5 vrst_mpl Clear variable size memory pool area O O O O Notes S Standard profile service cal...

Страница 213: ...all is issued R0 Error code R2 Data queue ID to be cleared E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call clears the data stored i...

Страница 214: ...m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task1 void vrst_dtq ID_dtq1 Example statement in assembly language include mr10...

Страница 215: ...all is issued R0 Error code R2 Short data queue ID to be cleared E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call clears the data st...

Страница 216: ...s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task1 void vrst_vdtq ID_vdtq1 Example statement in assembly language include mr10...

Страница 217: ...ar ra am me et te er rs s MBXID Mailbox ID to be cleared z z R Re eg gi is st te er r c co on nt te en nt ts s a af ft te er r s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register nam...

Страница 218: ...m s st ta at te em me en nt t Example statement in C language include itron h include kernel h include kernel_id h void task1 void vrst_mbx ID_mbx1 Example statement in assembly language include mr10...

Страница 219: ...R2 Fixed size memory pool ID to be cleared E Er rr ro or r c co od de e None F Fu un nc ct ti io on na al l d de es sc cr ri ip pt ti io on n This service call initializes the fixed size memory pool...

Страница 220: ...s se er rv vi ic ce e c ca al ll l i is s i is ss su ue ed d Register name Content after service call is issued R0 Error code R2 Variable size memory pool ID to be cleared E Er rr ro or r c co od de...

Страница 221: ...has defined in it the task entry address stack size etc by using an editor The GUI configurator available for MR100 may be used to create a configuration file 4 Executing the configurator From the co...

Страница 222: ...ion include file C compiler nc100 Relocatable Assembler as100 Linkage Editor ln100 Load module converter lmc100 Create Jamp table utility mr100tbl Include file kernel_id h Absolute module Startup prog...

Страница 223: ...the ker nel_id h file which is generated by the configurator is included it is possible to specify the task by name char acter string 39 wai_flg Waits until the eventflag is set up In the example this...

Страница 224: ...void printer printer engine task while 1 slp_tsk printf printer engine operation n void sent_in Centronics interface handler Process input from Centronics interface if 1 page input completed iset_flg...

Страница 225: ...ress sent_in Figure 6 3 Configuration File Example 6 2 3 Configurator Execution When using HEW select Build all which enables the user to execute the procedures described in 6 2 3 Executing the Config...

Страница 226: ...c100 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...

Страница 227: ...e itron h include kernel h include kernel_id h 3 No return value is provided for the task start function Therefore declare the task start function as a void function 4 A function that is declared to b...

Страница 228: ...static variables are initialized only by the startup program crt0mr a30 which actuates before MR100 startup 11 The task executed when the MR100 system starts up is setup 12 The variable storage classi...

Страница 229: ...ernel interrupt handler NOTE If this restriction is not observed the software may malfunction 3 A function that is declared to be static cannot be registered as an interrupt handler 4 If you want mult...

Страница 230: ...l 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 The cyclic handler and alarm handler are invoked by a sub...

Страница 231: ...7 7 Example Task Terminating with ext_tsk Described in Assembly Language 4 The initial register values at task startup are indeterminate except the PC SB R0 and FLG registers 5 To specify a task use...

Страница 232: ...egisters used in a handler are saved at the entry and are restored after use 3 Be sure to end the handler by REIT instruction 4 No service calls can be issued from a non kernel interrupt handler NOTE...

Страница 233: ...ler start address make the external declaration 51 3 Always use the RTS instruction subroutine return instruction to return from cyclic han dlers and alarm handlers For examples INCLUDE mr100 inc 1 GL...

Страница 234: ...nguage variables crt0mr a30 only Set the system timer Initialize MR100 s data area Copy these startup programs from the directory indicated by environment variable LIB100 to the current directory If n...

Страница 235: ...set EQU 0 25 26 27 SBDATA area definition 28 29 GLB __SB__ 30 SB __SB__ 31 32 33 Initialize Macro declaration 34 35 BZERO macro TOP_ SECT_ 36 XOR B R0L R0L 37 mov l TOP_ A1 38 mov l sizeof SECT_ R7R5...

Страница 236: ...ata_MON4_INIT_top data_MON4_top data_MON4 106 107 108 109 Set System IPL and Set Interrupt Vector 110 111 __INI_IPL G0 112 LDC __INT_VECTOR INTB 113 114 115 System timer interrupt setting 116 117 IF U...

Страница 237: ...Pool 185 GLB __init_mpf 186 JSR W __init_mpf 187 ENDIF 188 189 IF __NUM_MPL A1 190 Variable Memory Pool 191 GLB __init_mpl 192 JSR W __init_mpl 193 ENDIF 194 195 196 For PD100 197 __LAST_INITIAL 198...

Страница 238: ...sue system call 242 For PD100 243 __ISSUE_SYSCALL 244 245 System timer interrupt handler 246 _STMR_hdr 247 248 ret_int 249 ENDIF 250 251 END 252 253 254 COPYRIGHT C 2003 2007 RENESAS TECHNOLOGY CORPOR...

Страница 239: ...11 Setting the System Stack pointer 56 in Figure 7 11 Setting the SB FB register 61 65 in Figure 7 11 Initial set the C language 72 105 in Figure 7 11 Setting kernel interrupt mask level 111 in Figure...

Страница 240: ...e 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 Modify the section allocat...

Страница 241: ...r stack and system stack MR_HEAP section This section stores the variable size memorypool MR_KERNEL section This section is where the MR100 kernel program is stored MR_CIF section This section stores...

Страница 242: ......

Страница 243: ...at Hexadecimal Number Add 0x or 0X to the beginning of a numerical value or h or H to the end If the value begins with an al phabetical letter between A and F with h or H attached to the end be sure t...

Страница 244: ...lower case alpha betical letters dollar and _ underscore begins with a non numeric character and ends with The following shows an example of a function name written in the C language main func When wr...

Страница 245: ...ox definition Data queue definition Short data queue definition Fixed size Memory Pool definition Variable size Memory Pool definition Cyclic handler definition Alarm handler definition Interrupt vect...

Страница 246: ...e 7 Set the IPL value in service calls that is the OS interrupt disable level 4 Time tick denominator Definition format Numeric value Definition range Fixed to 1 Default value 1 Set the denominator of...

Страница 247: ...or f8 is chosen as count sauce and a value is set as a timer Ai register and a timer Bi register There fore overflow may occur depending on the value of timer_clock and the value of tick_nume of a sy...

Страница 248: ...er of cyclic handlers defined max_alh the maximum number of alarm handlers defined max_vdtq the maximum number of short data queues defined Contents 1 The maximum number of tasks defined Definition fo...

Страница 249: ...Default value None Define the maximum number of variable length memory blocks defined 8 The maximum number of cyclic activation handlers defined Definition format Numeric value Definition range 1 to 2...

Страница 250: ...the smallest Content Define the following for each task ID number 1 Task ID name Definition format Symbol Definition range None Default value None Define the ID name of a task Note that the function...

Страница 251: ...However the registers used can only be selected when the task is written in the assembly language Select all registers when the task is written in the C language When selecting a register here be sure...

Страница 252: ...omitted If omitted numbers are automatically assigned sequentially beginning with the smallest Content Define the following for each eventflag ID number 1 ID Name Definition format Symbol Definition r...

Страница 253: ...bute If YES is selected the TA_CLR attribute is added If NO is selected the TA_CLR attribute is not added Semaphore definition This definition is necessary to use Semaphore function Format Semaphore D...

Страница 254: ...nter 4 Maximum value of the semaphore counter Definition format Numeric value Definition range 1 to 65535 Default value 1 Define the maximum value of the semaphore counter Data queue definition This d...

Страница 255: ...nition must always be set when the short data queue function is to be used Format Vdataqueue Definition vdataqueue ID No name ID name buffer_size Number of data queues wait_queue Select data queue wai...

Страница 256: ...order of numbers beginning with the smallest Content For each mailbox ID number define the items described below 1 ID name Definition format Symbol Definition range None Default value None Define the...

Страница 257: ...mber can be omitted If omitted ID numbers are automatically assigned in order of numbers beginning with the smallest Content For each memory pool ID number define the items described below 1 ID name D...

Страница 258: ...ze memory pool definition This definition is necessary to use Variable size memory pool function Format Message buffer Definition message_buffer ID No name ID Name mbf_section Section name mbf_size Me...

Страница 259: ...emory having the rounded off size from the memory pool The following equations define the block sizes a max_memsize X 1 X 8 1 8 b a 2 c a 4 d a 8 max_memsize the value specified in the configuration f...

Страница 260: ...format Numeric value Definition range 1 to 0x7FFFFFFF Default value None Define the activation cycle at which time the cyclic handler is activated periodically The activation cycle here must be defin...

Страница 261: ...t Numeric value Definition range 0 to 0xFFFFFFFF Default value 0 Define the extended information of the cyclic handler This information is passed as argument to the cyclic han dler when it starts Alar...

Страница 262: ...ined vector number is valid de pends on the microcomputer used Configurator can t create an Initialize routine interrupt control register interrupt causes etc for this defined interrupt You need to cr...

Страница 263: ...the nearest value Multiple switches can be specified at the same time However if a kernel managed interrupt handler is con cerned only the E or R switch can be specified For non kernel managed interru...

Страница 264: ...Definition format Symbol or function name Definition range None Default value __SYS_DMY_INH Define the entry address to the interrupt handler When written in C language add at the end of the function...

Страница 265: ...e interrupt handler as shown below Always be sure to clear the B flag before issuing ret_int service call Example interrupt fset B fclr B ret_int Internally in the MR100 kernel register banks are not...

Страница 266: ...max_mpl 3 29 max_cyh 4 30 max_alh 2 31 32 33 system clock definition 34 clock 35 timer_clock 20 000000MHz 36 timer A0 37 IPL 3 38 39 40 task 41 entry_address task1 42 name ID_task1 43 stack_size 256 4...

Страница 267: ...ame ID_sem3 108 wait_queue TA_TPRI 109 initial_count 255 110 max_count 255 111 112 113 dataqueue 114 name ID_dtq1 115 wait_queue TA_TFIFO 116 buffer_size 10 117 118 dataqueue 2 119 name ID_dtq2 120 wa...

Страница 268: ...max_memsize 256 189 heap_size 1024 190 191 192 cyclic_hand 193 entry_address cyh1 194 name ID_cyh1 195 exinf 0x0 196 start ON 197 phsatr OFF 198 interval_counter 0x1 199 phs_counter 0x0 200 201 cyclic...

Страница 269: ...253 235 entry_address alm2 236 name ID_alm2 237 exinf 0x12345678 238 239 240 241 242 End of Configuration 243...

Страница 270: ...ves as the template file of include file mr100 inc and sys_ram inc It resides in the directory in dicated by environment variable LIB100 MR100 version file version This file contains description of MR...

Страница 271: ...ting the configurator check to see if the environment variable LIB100 is set correctly The configurator cannot be executed normally unless the following files are present in the directory indicated by...

Страница 272: ...Eipl Option Enable the check function of an IPL value When System_IPL 7 in the con figuration file the error message system_IPL should be 7 is displayed and the execution of cfg100 is stpped Wipl Opti...

Страница 273: ...t open default configuration file The default configuration file cannot be accessed default cfg is needed in the current directory or directory LIB100 specifying cfg100 Error Can t open configuration...

Страница 274: ...de operation occurred in some arithmetic expression cfg100 Error task X stack_size must set XX or more near line xxx xxxx cfg You must set more than XX bytes in task x stack_size cfg100 Error R2R0 mus...

Страница 275: ...ing interrupt_vector x s default is not defined near line xxx xxxx cfg The interrupt vector of vector number x in the configuration file is not defined in the default configuration file cfg100 Warning...

Страница 276: ...arts task1 and task2 task1 Task 2 2 Outputs task1 running task2 Task 3 3 Outputs task2 running cyh1 Handler 1 Wakes up task1 The content of processing is described below The main task starts task1 tas...

Страница 277: ...ude kernel h 13 include kernel_id h 14 include stdio h 15 16 17 void main VP_INT stacd 18 19 sta_tsk ID_task1 0 20 sta_tsk ID_task2 0 21 sta_cyc ID_cyh1 22 23 void task1 VP_INT stacd 24 25 while 1 26...

Страница 278: ...nition 21 clock 22 mpu_clock 20MHz 23 timer A0 24 IPL 4 25 26 Task Definition 27 28 task 29 entry_address main 30 name ID_main 31 stack_size 100 32 priority 1 33 initial_start ON 34 35 task 36 entry_a...

Страница 279: ...263...

Страница 280: ...hen a task issues a service call the MR100 switches the user stack to the system stack See Figure 10 1 System Stack and User Stack The system stack uses interrupt stack ISP Register save Stack switchi...

Страница 281: ...265 SFR System Stack User satck of TaskID No 1 User satck of TaskID No 2 User satck of TaskID No n Stack Section Figure 10 2 Layout of Stacks...

Страница 282: ...ctions used in MR100 refer to a stack size that is used for the service calls issued MR100 requires that if you issue only the service calls that can be issued from tasks 8bytes of area be allocated f...

Страница 283: ...byt es PC FLG size of re gisters used stack size used by sta_tsk 36bytes PC FLG size of registe rs used stack size used by prcv_mbx sta_t sk prcv_mbx 40bytes When use register R2R0 R3R1 A0 12bytes Fig...

Страница 284: ...wing Service Call name System Stack Size sta_tsk 4 bytes ext_tsk 4 bytes slp_tsk 4 bytes dly_tsk 8 bytes Therefore the maximum system stack size among the service calls to be used is the 8 bytes of dl...

Страница 285: ...e maximum system stack size among the service calls to be used The system stack size to be used by the interrupt handler The necessary system stack Interrupt Interrupt Figure 10 4 System Stack Calcula...

Страница 286: ...handler Refer to the manual of for the stack size calculation utility detailed use of it Assembly language The stack size to be used by kernel interrupt handler register to be used user size stack siz...

Страница 287: ...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 Refer to the manual of the stack size calculation utilit...

Страница 288: ..._tsk 0 4 16 ref_mpl 0 20 0 can_wup 0 12 0 set_tim 0 8 0 rel_wai 0 4 16 get_tim 0 8 0 sus_tsk 0 4 4 sta_cyc 0 12 0 rsm_tsk 0 4 4 stp_cyc 0 8 0 frsm_tsk 0 4 4 ref_cyc 0 16 0 dly_tsk 0 4 8 sta_alm 0 12 0...

Страница 289: ...m 12 20 iget_tid 16 20 iref_sem 12 20 iloc_cpu 12 iset_flg 32 68 iunl_cpu 12 20 iclr_flg 12 20 ret_int 16 ipol_flg 16 24 iref_ver 12 24 iref_flg 12 20 vipsnd_dtq 32 64 ipsnd_dtq 28 60 vifsnd_dtq 32 64...

Страница 290: ......

Страница 291: ...that can be issued from only non task context Service calls that can be issued from both task context and non task context 251 ret_int service call 252 dis_dsp service call 253 loc_cpu iloc_cpu servic...

Страница 292: ...ving had its delay dispatching cleared For this reason in isus_tsk that has been issued to the task under execution the task is removed from the ready queue and placed in a SUSPEND state Error code E_...

Страница 293: ...ing 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...

Страница 294: ......

Страница 295: ...o unknown data type typedef void FP Pointer to a function typedef W INT Signed 32 bit integer typedef UW UINT Unsigned 32 bit integer typedef H ID Object ID number typedef H PRI Priority typedef W TMO...

Страница 296: ...waiting queue INT semcnt Current semaphore count value T_RSEM Formats related to eventflag wfmod TWF_ANDW H 0000 AND wait TWF_ORW H 0002 OR wait typedef struct t_rflg ID wtskid ID number of task at t...

Страница 297: ...pedef struct t_rcyc STAT cycstat Operating status of cyclic handler RELTIM lefttim Remaining time before cyclic handler starts T_RCYC Formats related to alarm handler typedef struct t_ralm STAT almsta...

Страница 298: ...ameters The values set forth in ITRON specifica tions are not used for the function code Task Management Function Parameter ReturnParameter ServiceCall INTNo FuncCode A0 R1 R2 R3 A1 R0 R2 ista_tsk 250...

Страница 299: ...wai_sem 249 50 semid ercd pol_sem 250 52 semid ercd ipol_sem 250 52 semid ercd sig_sem 249 46 semid ercd isig_sem 250 48 semid ercd twai_sem 249 54 semid tmout ercd ref_sem 250 56 semid pk_rsem ercd i...

Страница 300: ...dtqid ercd data trcv_dtq 249 90 dtqid tmout ercd data ref_dtq 250 92 dtqid pk_rdtq ercd iref_dtq 250 92 dtqid pk_rdtq ercd snd_mbx 249 94 mbxid pk_msg ercd isnd_mbx 250 96 mbxid pk_msg ercd rcv_mbx 2...

Страница 301: ...r ServiceCall INTNo FuncCode A0 R3 R0 R2 rot_rdq 249 140 tskpri ercd irot_rdq 250 142 tskpri ercd get_tid 250 144 ercd tskid iget_tid 250 144 ercd tskid loc_cpu 253 198 ercd iloc_cpu 253 200 ercd dis_...

Страница 302: ...ercd ref_mpl 250 122 mplid pk_rmpl ercd iref_mpl 250 122 mplid pk_rmpl ercd Time Management Functions Parameter ReturnParameter ServiceCall INTNo FuncCode A0 R2 R6R4 A1 R0 set_tim 250 124 p_systim erc...

Страница 303: ...plid ercd vrst_mbf 249 218 mbfid ercd Extenden Function Short Data Queue Function Parameter ReturnParameter ServiceCall INTNo FuncCode A0 R1 R2 R6R4 A1 R0 R1 vsnd_dtq 249 162 data vdtqid ercd vpsnd_dt...

Страница 304: ...288...

Страница 305: ...er 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 Ren...

Страница 306: ...1753 Shimonumabe Nakahara ku Kawasaki shi Kanagawa 211 8668 Japan M3T MR100 4 V 1 00 REJ10J1523 0100 User s Manual...

Отзывы: