Home
M3T-MR30/4 V.4.01 User`s Manual
Contents
1. 1 A ck ck ck ck ck ck kc ck ck ck 0k ck ck kc ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck ck Ck ck ck ck ck ck ck ck ck AAA RARA kk ck kk kv kv Sk A ko ko ko 2 EK MR30 start up program for C language 4 Copyright C 1996 1997 2011 Renesas Electronics Corporation 5 3 and Renesas Solutions Corp All Rights Reserved i kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 8 Id crtOmr a30 519 2006 04 24 13 36 30Z inui 2 10 list OFF 11 include C sec inc 12 include mr30 inc 13 include Sys rom inc 14 include Sys ram inc 15 list ON 16 Ls 18 SBDATA area definition L97 20 glb SB 21 SB SB 22 23 P 24 Initialize Macro declaration 25 3 26 N BZERO macro TOP SECT 27 mov b 00H ROL 28 mov w TOP_ OFFFFH Al 29 mov w sizeof SECT_ R3 30 sstr b 31 endm 32 33N BCOPY macro FROM TO SECT 34 mov w FROM_ amp OFFFFH AO 35 mov b FROM_ gt gt 16 R1H 36 mov w STO A1 37 mov w sizeof SECT_ R3 38 smovf 39 endm 40 41 BZERO macro TOP SECT 42 push w sizeof SECT_ gt gt 16 43 push w sizeof SECT_ amp Offffh 44 pusha TOP_ gt gt 16 45 pusha TOP_ amp Offffh 46 47 glb _bzero 48 jsr a _bzero 49 endm SD 51 52 BCOPY macro FROM TO SECT 53 push w sizeof SECT gt gt 16 54 push w sizeof SECT amp Offffh 55 pusha TO_ gt gt 16 56 pusha TO_ amp Offffh 54 pusha FROM
2. if snd_dtq ID dro data 0 E RLWAI error Forced released n if Gand dtq ID dro data 1 E TMOUT error Timeoutin if tsnd dtq ID dtq data 2 10 E TMOUT error Timeout An if fsnd dtq ID dro data 3 E OK error error Nn lt lt Example statement in assembly language gt gt include mr30 inc GLB task g dtq LWORD 12345678H task PUSHM RO R1 R2 A0 MOV W 100 R0 MOV W 0 R2 tsnd dtq ID DTOl g dtq PUSHM f R1 A0 psnd dtq ID DTQ2 4O0FFFFH PUSHM f R1 A0 fsnd dtq ID DTQ3 4 0ABCDH R20UT0655EJ0100 Rev 1 00 Page 120 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference rcv dtq Receive from data queue prcv dtq Receive from data queue polling iprcv dtq Receive from data queue polling handler only ircv dtq Receive from data queue with timeout C Language API ER ercd rcv dtq ID dtqid VP INT p data ER ercd prcv dtq ID dtqid VP INT p data ER ercd iprcv dtq ID dtqid VP INT p data ER ercd trcv dtq ID dtqid VP INT p data TMO tmout Parameters ID dtqid ID number of the data queue from which to receive TMO tmout Timeout value trcv dro VP INT p data Pointer to the start of the area in which received data is stored e Return Parameters ER ercd Terminated normally E OK or error code VP INT p data Pointer to the start of the area in which received data is stored
3. GLB task task PUSHM A0 R3 MOV W O R1 MOV W O0 R3 vtrcv dtq ID DTQl PUSHM AO l vprev_dtq ID_DTQ2 PUSHM AO vrev dtq ID DTQ2 R20UT0655EJ0100 Rev 1 00 Page 194 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference vref dtq Reference Long data queue status viref dtq Reference Long data queue status handler only C Language API ER ercd vref dtq ID vdtqid T_RDTQ pk_rdtq ER ercd viref dtq ID vdtgid T RDTOQ pk_rdtq e Parameters ID vdtqid ID number of the target Long data queue T RDTQ pk rdtq Pointer to the packet to which Long data queue status is returned e Return Parameters ER ercd Terminated normally E OK T RDTQ pk rdtq Pointer to the packet to which Long data queue status is returned Contents of pk rdtq typedef struct t rdtq ID stskid 0 2 Transmission waiting task ID ID wtskid 2 2 Reception waiting task ID UINT sdtqcnt 4 2 Data bytes contained in Long data queue T RDTQ Assembly language API include mr30 inc vref dtq VDTOID PK_RDTO viref dtqVDTOID PK_RDTO e Parameters VDTQID ID number of the target Long data queue PK RDTQ Pointer to the packet to which Long data queue status is returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target Long data queue Al Pointer to the packet to which Long data queue status is returned
4. include mr30 inc rel mpf MPFID BLK irel mpf MPFID BLK Parameters MPFID ID number of the fixed size memory pool to be released BLK Start address of the memory block to be returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK R1 Start address of the memory block to be returned AO ID number of the fixed size memory pool to be released Error code None Funcional description This service call releases a memory block whose start address is indicated by blk The start address of the memory block to be released that is specified here should always be that of the memory block acquired by get mpf tget mpf pget mpf or ipget mpf If tasks are enqueued in a waiting queue for the target memory pool the task at the top of the waiting queue is dequeued and linked to a ready queue and is assigned a memory block At this time the task changes state from a memory block wait state to RUNNING or READY state This service call does not check the content of blk so that if the address stored in blk is incorrect the service call may not operate correctly If this service call is to be issued from task context use rel mpf if issued from non task context use irel_mpf R20UT0655EJ0100 Rev 1 00 Page 138 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C langu
5. Assembly language API include mr30 vrcv dtq vprcv dtq viprcv dtq vtrcv dtq e Parameters inc VDTOID VDTOID VDTQID VDTOID VDTQID ID number of the Long data queue from which to receive e Register contents after service call is issued vrcv dtq vprcv dtq viprcv dtq Register name RO R1 R3 AO vircv_dtq Register name RO RI R2 R3 AO Error code J E_RLWAI E_TMOUT Content after service call is issued Terminated normally E_OK or error code Received data 16 low order bits Received data 16 high order bits ID number of the Long data queue from which to receive Content after service call is issued Terminated normally E_OK or error code Received data 16 low order bits Timeout value 16 high order bits Received data 16 high order bits ID number of the Long data queue from which to receive Forced release from waiting Polling failure or timeout or timed out at R3 Timeout value16 high order bits R1 Timeout value16 low order bits must be set before calling sevice call R20UT0655bEJ0100 Rev 1 00 Page 192 of 295 Jun 01 2011 ztENESAS M3T MR30 4 5 Service call reference Functional description This service call receives data from the Long data queue indicated by vdtqid and stores the received data in the area pointed to by p_data If data is present in the target Long data queue the data at the top of the queue or the oldest data is received This results in cr
6. R20UTO0655EJ0100 Rev 1 00 Page 181 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task BOOL stat stat sns_dpn lt lt Example statement in assembly language gt gt include mr30 inc GLB task task sns dpn R20UT0655EJ0100 Rev 1 00 Page 182 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 13Interrupt Management Function Table 5 24 List of Interrupt Management Function Service Call No Service Call Function System State NE D 1 ret int Returns from an interrupt O O O handler U O Notes e S Standard profile service calls e Each sign 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state 9999 R20UT0655EJ0100 Rev 1 00 Page 183 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ret_int Returns from an interrupt handler when written in assembly language C Language API This service call cannot be written in C language Assembly language API inclu
7. sess 15 Service Calls from a Handler That Caused an Interrupt during Service Call Processing 16 Service Calls from a Handler That Caused an Interrupt during Handler Execution sss 17 3 OM EE 18 3 3 1 The specification method of the object in a service call seessssseeeeee 18 Bis MASK Qu NEEDS 19 3 4 1 Task Status eie e ete ERE ea ERR ES ee nee MEE RR su Ree REY aaa 19 3 4 2 Task Priority and Ready Queue nennen nnns tnnt trennt nnne enters 23 3 43 Task Priority and Waiting Oueue nennen nnne nnne nnn nnn nnne nnne tnnt 24 344 Task EontrolBlock TEB aaa dial 25 39 System E TN 27 3 51 Task Context and Non task Contest 27 3 5 2 Dispatch Enabled Disabled States AAA 29 3 5 3 CPU Locked Unlocked States AAA 29 3 5 4 Dispatch Disabled and CPU Locked States sese 29 36 e ie ele Dal e EE 20 3 6 1 Types of Interrupt Handlers eessssssessssseeesene nennen tenente nnne nnne tnt nennt nnn enne 30 3 6 2 The Useof Non maskable Interrupt AA 31 3 6 3 Controlling Interr ptS iea a ana aaaea nera 31 3 6 4 Permission and prohibition of Interrupt enne nnn 33 When prohibiting interrupt in the task AAA 33 When permitting interrupt in the interrupt handler When accepting multiple interrupt 33 3 7 About the power control of M 16C and R8C and the operation of the kernel 34 3 88 le A A uS SR ben eed cle aet
8. typedef struct t_rmpf ID wtskid 1D number of task at the top of memory acquisition waiting queue UINT frbcnt Number of memory blocks T RMPF Formats related to Variable size Memory pool typedef struct t rmpl ID wtskid 1D number of task at the top of memory acquisition waiting queue SIZE fmplsz Total size of free areas UINT fblksz Maximum memory block size that can be acquired immediately T_RMPL Formats related to cyclic handler typedef struct t_rcyc STAT cycstat Operating status of cyclic handler RELTIM lefttim Remaining time before cyclic handler starts T_RCYC Formats related to alarm handler typedef struct t_ralm STAT almstat Operating status of alarm handler RELTIM lefttim Remaining time before alarm handler starts T RALM Formats related to system management typedef struct t rver UH maker Maker UH prid Type number UH spver Specification version UH prver Product version UH prno 4 Product management information T_RVER R20UTO655EJ0100 Rev 1 00 Page 286 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix 14 2Assembly Language Interface When issuing a service call in the assembly language you need to use macros prepared for invoking service calls Processing in a service call invocation macro involves setting each parameter to registers and starting exec
9. 12 5Cautions for each microcontrollers 12 5 14 To use the M16C 62 group MCUs e To use the nenory expansion functi on i n nenory space expansi on node 1 1 2M avai abl e nenor y Locate the MR30 kernel MR_KERNEL section between addresses 30000H and FFFFFH e To use the nenory expansion functi on in nenory space expansi on nade 2 4M avai abl e nenor y Locate the MR30 kernel MR KERNEL section between addresses 3C0000H and 3FFFFFH 12 5 2 To use the M16C 6N group MCUs Please append the following program to the point of the MR30 s system timer setting in the startup pro gram The setting point of MR30 s system timer is lines 160 in crtOmr a30 or lines 73 in start a30 These startup files are in MR30 s install directory XL IB30 directory If you select no division by changing the value of the peripheral function clock register need not append the following program d System timer interrupt setting mov b stmr mod val stmr mod reg set timer mode mov b 1H OAH A bset 6 07H mov b stmr_int_IPL stmr_int_reg set timer IPL H belr 6 07H A mov D 0 OAH mov w stmr_cnt_stmr_ctr_reg set interval count mov b stmr_mod_reg ROL and b OCOH ROL jnz MR SYSTIME END mov w stmr_cnt 2 stmr_ctr_reg MR SYSTIME END or b stmr bit 41 stmr start PRIN ee gbase ee a append append append append append R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 RE
10. ER ercd ercd act_tsk ID_task2 void task2 VP_INT stacd d ext_tsk lt lt Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task pushm AO act_tsk ID_TASK3 R20UT0655EJ0100 Rev 1 00 Page 66 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference can_act Cancel task activation request ican_act Cancel task activation request handler only C Language API ER_UINT actcnt can_act ID tskid ER_UINT actcnt ican_act ID tskid e Parameters ID tskid ID number of the task to cancel Return Parameters ER_UINT actcnt gt 0 Canceled activation request count actcnt 0 Assembly language API include mr30 inc can act TSKID ican act TSKID Parameters TSKID ID number of the task to cancel e Register contents after service call is issued Register name Content after service call is issued RO Canceled startup request count AO ID number of the target task Error code None Functional description This service call finds the number of task activation requests enqueued for the task indicated by tskid returns the result as a return parameter and at the same time invalidates all of the task s activation requests Specifying tskid TSK_SELF 0 specifies the issuing task itself If TSK_SELF is specified for tskid in non task context operation of this service call cannot be guaranteed This service call can be invoked
11. For the tget_mpf service call specify a wait time for tmout in ms units The values specified for tmout must be within Ox 7fffffff time tick 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 service call operates the same way as pget_mpf Furthermore if specified as tmoutZTMO FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as get_mpf The task placed into WAITING state by execution of the get_mpf or tget_mpf service call is released from WAITING state in the following cases When the rel_mpf or irel_mpf service call is issued before the tmout time elapses with task awaking conditions thereby satisfied The error code returned in this case is E_OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI When the target memory pool being waited for is removed by the vrst mpf service call issued from another task The error code returned in this case is EV RST The value of the memory block acquired by this service call is indeterminate because it is not initialized
12. forced wakeup Nn if prcv mbx T MSG amp msg ID mbx E TMOUT error Timeout n if trcv mbx T MSG amp msg ID mbx 10 E TMOUT error Timeoutin lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM R3 A0 MOV W 100 R1 MOV W O0 R3 trcv mbx ID MBX1 PUSHM f R3 A0 rcv mbx ID MBX1 PUSHM f R3 A0 prcv_mbx ID_MBX1 R20UT0655EJ0100 Rev 1 00 Page 131 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref mbx Reference mailbox status iref mbx Reference mailbox status handler only C Language API ER ercd ref mbx ID mbxid T RMBX pk rmbx ER ercd iref mbx ID mbxid T RMBX pk rmbx e Parameters ID Mbxid ID number of the target mailbox T RMBX pk rmbx Pointer to the packet to which mailbox status is returned e Return Parameters ER ercd Terminated normally E OK T RMBX pk rmbx Pointer to the packet to which mailbox status is returned Contents of pk rmbx typedef struct t rmbx ID wtskid 0 2 Reception waiting task ID T MSG pk msg 4 4 Next message packet to be received T RMBX Assembly language API include mr30 inc ref mbx MBXID PK RMBX iref mbx MBXID PK RMBX Parameters MBXID ID number of the target mailbox PK RMBX Pointer to the packet to which mailbox status is returned Register contents after service call is issued Register name Content after
13. 6 to OxFFFF Default value 400H Define the total stack size used in service call and interrupt processing 2 Maximum value of priority value of lowest priority Definition format Numeric value Definition range 1 to 255 Default value 63 Define the maximum value of priority used in MR30 s application programs This must be the value of the highest priority used 3 Kernel mask level OS interrupt disable level Definition format Numeric value Definition range 1to7 Default value 7 Set the IPL value in service calls that is the OS interrupt disable level 4 Timeout function Definition format Symbol Definition range YES or NO Default value NO Specify YES when using or NO when not using tslp_tsk twai flg twai sem end dro trcv dtq tget_mpf vtsnd dtq vtrev_dtq and trcv msg 5 Task Pause Definition format Symbol Definition range YES or NO Default value NO Specify YES when using or NO when not using the Task Pause function of OS Debug Function of the debug ger R20UT0655EJ0100 Rev 1 00 Page 231 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 6 Time tick denominator Definition format Numeric value Definition range Fixed to 1 Default value 1 Set the denominator of the time tick 7 Time tick numerator Definition format Numeric value Definition range 1 to 65 535 Default va
14. E OBJ Object status invalid task indicated by tskid is an inactive state Functional description This service call clears the wakeup request count of the target task indicated by tskid to 0 This means that because the target task was in either WAITING state nor WAITING SUSPENDED state when an attempt was made to wake it up by wup_tsk or iwup_tsk before this service call was issued the attempt resulted in only accumulating wakeup requests and this service call clears all of those accumulated wakeup requests Furthermore the wakeup request count before being cleared to 0 by this service call i e the number of wakeup requests that were issued in vain wupcnt is returned to the issuing task If a wakeup request is issued while the target task is in DORMANT state the error code E_OBJ is returned If TSK_SELF is specified for tskid it means specifying the issuing task itself If TSK_SELF is specified for tskid in non task context operation of this service call cannot be guaranteed If this service call is to be issued from task context use can_wup if issued from non task context use ican_wup R20UT0655EJ0100 Rev 1 00 Page 89 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task ER_UINT wupcnt wupcnt can wup ID main if wup cn
15. Error code None R20UT0655EJ0100 Rev 1 00 Page 195 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call returns various statuses of the Long data queue indicated by vdtqid 4 siskid Returned to stskid is the ID number of the task at the top of a transmission waiting queue the next task to be dequeued If no tasks are kept waiting TSK_NONE is returned wtskid Returned to wtskid is the ID number of the task at the top of a reception waiting queue the next task to be de queued If no tasks are kept waiting TSK NONE is returned sdtqcnt Returned to sdtqent is the number of data bytes stored in the Long data queue area If this service call is to be issued from task context use ref dtq if issued from non task context use iref dro Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task T_RDTO rdtq ER ercd ercd vref_dtq ID DTO1 amp rdtq lt lt Example statement in assembly language gt gt refdtq blkb 6 include mr30 inc GLB task task PUSHM A0 A1 vref_dtq ID_DTQ1 _refdtq R20UT0655EJ0100 Rev 1 00 Page 196 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 16 Extended Function Reset Function This function initializes the content of an object This function is outsi
16. Flag wait mode This is a wait mode during eventflag wait Timer queue connection pointer This area is used when using the timeout function This area stores the task connection pointer used when con structing the timer queue Flag wait pattern This area is used when using the timeout function This area stores the flag wait pattern when using the eventflag wait service call with the timeout function twai_flg No flag wait pattern area is allocated when the eventflag is not used Startup request counter This is the area in which task startup requests are accumulated Extended task information Extended task information that was set during task generation is stored in this area The task control block is schematized in Figure 3 20 15 Called the task context R20UT0655EJ0100 Rev 1 00 Page 25 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel TCB TCB TCB Time out counter or Flag wait pattern Timer queue Connection pointer Flag wait pattern Figure 3 20 Task control block This area is allocated only when the timeout function is used R20UT0655EJ0100 Rev 1 00 Page 26 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 5 System States 3 5 1 Task Context and Non task Context The system runs in either context state task context or non task context The differences between the task content and non task context are shown in Table 3 1 Task Context and Non
17. None Functional description This service call places the system into a dispatching disabled state The features of a dispatching disabled state are out lined 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 accepted 3 No service calls can be invoked that will place tasks into WAITING state If one of the following operations is performed during a dispatching disabled state the system status returns to a task execution state a Invocation of the ena dsp service call b Invocation of the ext tsk service call Transitions between dispatching disabled and dispatching enabled states occur only when the dis dsp ena dsp or ext tsk service call is invoked Invoking this service call again while the system is already in a dispatching disabled state does not cause an error in which case task queuing is not performed however This service call can be issued only from task context It cannot be issued from non task context R20UT0655EJ0100 Rev 1 00 Page 175 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task dis_dsp lt lt Example statement in assembly language gt gt include mr30 inc GLB task task di
18. R20UT0655EJ0100 Rev 1 00 Page 241 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator lt lt Content gt gt For each long data queue ID number define the items described below 1 2 3 ID name Definition format Symbol Definition range None Default value None Define the name by which the short data queue is specified in a program Number of data Definition format Numeric Value Definition range 0 to 0x1FFF Default value 0 Specify the number of data that can be transmitted What should be specified here is the number of data and not a data size Selecting a data queue waiting queue Definition format Symbol Definition range TA_TFIFO or TA_TRPI Default value TA_TFIFO Select a method in which tasks wait for short data queue transmission If TA_TFIFO is selected tasks are en queued in order of FIFO If TA_TPRI is selected tasks are enqueued in order of priority beginning with the one that has the highest priority Mailbox definition This definition must always be set when the mailbox function is to be used lt lt Format gt gt Mailbox Definition mailbox ID No 1 name ID name wait_queue Select mailbox waitin eue message_queu Select message queue max_pri Maximum message priority The ID number must be in the range 1 to 255 The ID number can be omitted If omitted
19. TA ASM Handlers written in assembly language TA STA Starts operation of cyclic handler TA PHS Saves activation phase Table 5 20 List of Cyclic Handler Function Service Call No Service Call Function System State T N E D UI L 1 sta_cyc S Starts cyclic handler op O olojo 2 ista_cyc eration OO JOl O 3 stp_cyc S Stops cyclic handler op O O O O 4 istp_cyc eration OO JOl O 5 ref_cyc Reference cyclic handler O olojo 6 iref_cyc status O JO O Oo Notes e S Standard profile service calls e Each sign 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Page 155 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sta_cyc Start cyclic handler operation ista_cyc Start cyclic handler operation handler only C Language API ER ercd sta_cyc ID cycid ER ercd ista_cyc ID cycid e Parameters ID cycid ID number of the cyclic handler to be operated Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc sta cyc CYCNO ista cyc CYCNO e Parameters CYCNO ID number of the cyclic handler t
20. gt sema en es ES ER eism 3 3 see sme es E Lam s em w es ES em gt lemoa es ES ES am s lomo es ES ES am s amp E CO es ES Des wm vaio fra Jelli wf efo wm tmr Iesel ec Il mme 3 Siwe vanoa es feel mme Siwe wem wa fered oan Lem 3 o e o mm E E Hem s of w se es ES ES me 2 z w ee es L waa aje ae les ES Ima ea ew fees E mds ofe a feed ES Fiera s fea ew Jee ES ES eg wr ota wae as Sisi t wea x e feed e ES se Jags fees e L wwa sje p e es e wwa o we trax aos feed asa ES wa sj e meer eas sj 0 1 lee ojee ES ES R20UT0655EJ0100 Rev 1 00 Page 289 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix Synchronization amp Communication Function Parameter ReturnPararreter ServiceCall INTNo FuncCode R3 FuncCode Saa ae RE E E I rd n EL RM E E Frente IE II ria ee mms mv s 3e CC Sea memo men 3 xe ewe fered mme eng 2 lest E E rita E Prete 3 3 jew mme es Td Hem 3 3aw rte oec Tees _ Memorypool Management Functions Parameter ReturnPararreter gt
21. 199 phs counter 0x0 200 201 cyclic_hand 202 entry_address cyh2 203 name ID_cyh2 204 exinf 0x1234 205 start OFF 206 phsatr ON 207 interval_counter 0x20 208 phs_counter 0x10 209 210 cyclic_hand 211 entry address cyh3 212 name ID cyh3 213 exinf OxFFFF 214 start ON 215 phsatr OFF 216 interval_counter 0x20 217 phs_counter 0x0 218 219 cyclic_hand 4 R20UT0655EJ0100 Rev 1 00 Page 254 of 295 Jun 01 2011 RENESAS M3T MR30 4 220 entry_address cyh4 221 name ID_cyh4 222 exinf 0x0 223 start ON 224 phsatr ON 225 interval counter 0x100 226 phs counter 0x80 227 228 229 alarm hand 230 entry address alml 231 name ID_alml 232 exinf OxFFFF 233 234 alarm_hand 2 235 entry address alm2 236 name ID alm2 237 exinf 0x12345678 238 239 240 241 242 End of Configuration 243 R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 2tENESAS 8 Using Configurator Page 255 of 295 M3T MR30 4 8 Using Configurator 8 2 Configurator Execution Procedures 8 2 1 Configurator Overview The configurator is a tool that converts the contents defined in the configuration file into the assembly language include file etc Figure 8 1 outlines the operation of the configurator When used on HEW the configurator is automatically started and an application program is built 1 Executin
22. 5 6 MR30 4 System Configuration File 7 Id smp cfg 693 2011 06 02 07 01 45Z inui 8 9 m PM e 10 11 System Definition 12 system 13 stack size 1024 14 priority 10 15 system IPL 4 16 task_pause NO 17 timeout NO 18 tic_nume 1 19 tic_deno 1 20 message_pri 255 21 22 System Clock Definition 23 clock 24 mpu_clock 20MHz 25 timer AO 26 IPL 4 27 28 Task Definition 29 30 task 31 entry address main 32 name ID main 33 stack size 100 34 priority 1 35 initial start ON 36 exinf 0 37 38 task 39 entry_address task1 40 name ID_taskl 41 stack_size 500 42 priority 2 43 exinf 0 44 gt 45 task I 46 entry_address task2 47 name ID_task2 48 stack_size 500 49 priority 3 50 exinf 0 51 52 53 semaphore 54 name ID_seml 55 max_count 1 56 initial_count 1 57 wait queue TA TPRI 58 59 60 61 62 cyclic hand 1 63 name ID cyhl 64 interval counter 100 65 start OFF 66 phsatr OFF 67 phs_counter 0 68 entry_address cyhl 69 exinf 1 70 71 R20UT0655EJ0100 Rev 1 00 Page 266 of 295 Jun 01 2011 RENESAS 11 Stack Size Calculation Method 11 1Stack Size Calculation Method The MR30 provides two kinds of stacks the system stack and the user stack The stack size calculation method differ be
23. 7 2 2 Writing Kernel OS dependent Interrupt Handler 216 7 2 3 Writing Non kernel OS independent Interrupt Handler A 217 7 244 Writing CydicHandler Alarm Handler sess nennen nennen 218 7 3 Modifying MR30 Startup Program 219 7 3431 C Language Startup Program crtOmr a30 sese nnns 220 7 4 Memory Allocation spi eite e e Ee e ED Rt RE CR and OH FERE re AER Tea eR UR e Eea ERE e e dei qn 225 7 4 1 Sections that kernel uses sssssssssssssseeseeeeeene rn 226 8 Usirig Conflgurator EE 227 8 1 Configuration File Creation Procechure nennen nennen nnne 227 8 1 1 Configuration File Data Entry Forme 227 Operator M M O 228 Direction of comp tati Qni ecc EA cta Pe a E eoi E Ea yer HT E DA ELE e cue HE ELE ee Ue v ne T 228 8 1 2 Configuration File Definition Ireme enne 230 System Definition Procedure ariari mae ee epe ere e eit ge E n REPE aa 230 System Clock Definition Procedure ll 232 Definition respective maximum numbers of items 1 234 Task Sea a E E EA 236 CEventilag definition Mira A ees E E a keane 238 Semaphore definida Lic aa e EE evt K i ne ER e E e e aa a NEE 239 Data queue delia ita 240 I Re vie data QUESO ele E UE 241 CMailbox definition m eret rre hd vene errem ee eb re ve d Sia ern nay P wean Aun Dak RN RR e 242 Fixed size memory pool definition H 243 Variable size memory pool
24. 8 1 3 Configuration File Example The following is the configuration 1 2 3 7 kernel cfg building file for MR30 Ver 4 00 4 5 Generated by M3T MR30 GUI Configurator at 2005 02 28 19 01 20 6 7 8 9 system definition 10 system 11 Stack size 256 12 sys m IPL 4 153 message pri 64 14 timeout NO 15 task pause NO 16 tick_nume 10 17 tick_deno 1 18 gt 19 20 max definition 21 maxdefine 22 max task 3 23 max flag 4 24 max sem 3 25 max dtq 3 26 max mbx 4 27 max mpf 3 28 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 taskl 43 stack size 256 44 priority 1 45 initial start OFF 46 exinf 0x0 47 gt 48 task 49 entry_address task2 50 name ID_task2 51 stack_size 256 52 priority 5 53 initial start ON 54 exinf OxFFFF 55 HM 56 task 3 57 entry_address task3 58 name ID_task3 59 stack_size 256 60 priority 7 61 initial_start OFF 62 exinf 0x0 63 64 65 flag 66 name ID flgl 67 initial pattern 0x00000000 68 wait queue TA TFIFO 69 clear attribute NO R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 file example 132 N SAS 8 Using Configurator LMIUMLMBllllllll ll dd dd d Al dd dd MP P P P M MM LP P gg Mllllll d dd
25. Assembly language API include mr30 inc rcv dtq DTQID prcv dtq DTOID iprcv dtq DTOID trcv dtq DTQID Parameters DTQID ID number of the data queue from which to receive e Register contents after service call is issued rcv dtq prcv dtq iprcv dtq Register name Content after service call is issued RO Terminated normally E OK or error code RI Received data AO Data queue ID number trcv dtq Register name Content after service call is issued RO Terminated normally E OK or error code RI Received data R2 Timeout value 16 high order bits AO ID number of the data queue from which to receive Error code E RLWAI Forced release from waiting E TMOUT Polling failure or timeout or timed out R3 Timeout value16 high order bits R1 Timeout value16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 121 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call receives data from the data queue indicated by dtqid and stores the received data in the area pointed to by p_data If data is present in the target data queue the data at the top of the queue or the oldest data is received This results in creating a free space in the data queue area so that a task enqueued in a transmission waiting queue is released from WAITING state and starts sending data to the data queue area If no data exist in the data queue and the
26. E ken FuncCode eca pbk mu xp o 1 EN me mt n ens LECCE UNITIES E t I AA S ERE hem 2 moja Iesel es Jam Laag LS amp IL Il ee hem s wp mee ee ES E hem a m p me km es heim u me km es Imm z m me fea o im pw me les hem s e p eem es hem Tr a es R20UTO0655EJ0100 Rev 1 00 Page 290 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix Time Management Functions Pararreter RetumParameter RetumParameter ServiceCall INTNo FuncCode mE tA COIN IEEE IEC ERE E dem CARES em s s Tem fea m s us Tem fee Lao s Tae leng moe je EE oc s J le mec Ta es wx s e l Jos mee es wx s i Jon o es aam s re amm amm Jara Jea saam 3 l g Jamm Jara Je am 3 3 o o e es sem 1 a es 4 Eam s 3x oo fae mem es eam 3 1m am mmm es System Management Functions Interrupt Management lt Parameter ReturnPararreter o om oJ a xp e O ug m ERR mu w es s amp ea el es CI em 3 fees em ff je sid SSCS nam e was ea i 35 R20UT0655EJ0100 Rev 1 00 Page 291 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix System configuration manag
27. Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2011 Renesas Electronics Corporation and Renesas Solutions Corp All rights reserved Colophon 1 0 Real time OS for M16C Series and R8C Family M3T MR30 4 V 4 01 User s Manual N ESAS R20UT0655EJ0100 Renesas Electronics Corporation
28. Message queue MessageA Message B Message C Figure 4 16 Message queue There are following data queue service calls that are provided by the MR30 kernel Send to Mailbox snd_mbx isnd_mbx Transmits a message Namely a message is dropped into the mailbox e Receive from Mailbox rcv mbx trcv mbx Receives a message Namely a message is retrieved from the mailbox At this time if the mailbox has no mes sages in it the task is kept waiting until a message is sent to the mailbox e Receive from Mailbox polling prcv mbx iprcv mbx Receives a message The difference from the rcv mbx service call is that if the mailbox has no messages in it the task returns error code without going to a wait state e Reference Mailbox Status ref mbx iref mbx Checks to see if there are any tasks waiting for a message to be put into the target mailbox and refers to the message present at the top of the mailbox R20UT0655EJ0100 Rev 1 00 Page 50 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 7 Memory pool Management Function Fixed size Memory pool A fixed size memory pool is the memory of a certain decided size The memory block size is specified at the time of a configuration Figure 4 17 is a figure about the example of a fixed size memory pool of operation Memory Block 1 TaskA S NS Memory block acquisition Memory Block 2 Used by TaskB AUS Memory Block 3 Memory block acquisition Memory block
29. Multi wait attribute Definition format Symbol Definition range TA_WMUL or TA WSGL Default value TA WSGL Specify whether multiple tasks can be enqueued in the eventflag waiting queue If TA_WMUL is selected the TA WMUDL attribute is added permitting multiple tasks to be enqueued If TA WSGL is selected the TA WSGL attribute is added prohibiting multiple tasks from being enqueued Clear attribute Definition format Symbol Definition range YES or NO Default value NO Specify whether the TA CLR attribute should be added as an eventflag attribute 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 lt lt Format gt gt Semaphore Definition semaphore ID No name ID name wait_queue Selecting a semaphore waiting queue initial count Initial value of semaphore counter max count Maximum value of the semaphore counter Ir The ID number must be in the range of 1 to 255 The ID number can be omitted If omitted numbers are automatically assigned sequentially beginning with the smallest R20UT0655EJ0100 Rev 1 00 Page 239 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator lt lt Content gt gt Define the following for each semaphore ID number 1
30. TA WMUL 0x0000ffff TA TPRI YES TA WMUL 0x00000008 TA TPRI YES TA WSGL TA TFIFO 0 TA TFIFO 5 TA TPRI 255 TA TFIFO 10 TA TPRI 5 TA TFIFO 256 TA TFIFO TA MFIFO TA TPRI TA MPRI TA TFIFO TA MPRI 132 N SAS 8 Using Configurator Page 253 of 295 M3T MR30 4 8 Using Configurator 145 max_pri 5 146 147 mailbox 4 148 name ID_mbx4 149 wait_queue TA_TPRI 150 message_queu TA_MFIFO 151 max_pri 6 152 153 154 memorypool 155 name ID mpfl 156 wait queue TA TFIFO 157 section MR RAM 158 siz block 16 159 num block 5 160 161 memorypool 2 162 name ID_mpf2 163 wait_queue TA_TPRI 164 section MR_RAM 165 siz_block 32 166 num_block 4 167 168 memorypool 3 169 name ID_mpf3 170 wait_queue TA_TFIFO 171 section MPF3 172 siz_block 64 173 num block 256 174 175 176 variable memorypool 177 name ID_mpll 178 max_memsize 8 179 heap_size 16 180 181 variable_memorypool 182 name ID mpl12 183 max memsize 64 184 heap size 256 195 3 186 variable memorypool 3 187 name ID mpl3 188 max memsize 256 189 heap size 1024 190 191 192 cyclic hand l 193 entry address cyhl 194 name ID cyhl 195 exinf 0x0 196 start ON 197 phsatr OFF 198 interval counter 0x1
31. The stack size used by an interrupt handler that is invoked during a service call can be calculated by the equation below The stack size Bi used by an interrupt handler is shown below C language Using the stack size calculation utility calculate the stack size of each interrupt handler Refer to the manual of the stack size calculation utility for detailed use of the stack size calculation utility Assembly language The stack size to be used by OS dependent interrupt handler register to be used user size stack size to be used by service call The stack size to be used by OS independent interrupt handler register to be used user size User size is the stack size of the area written by user SAX Context 20bytes bg Interrupt 2bytes lt gt jsr func 20bytes iset flg ret int L i 42bytes Context 20 bytes when written in C language When written in assembly language Context size of registers used 4 PC F LG bytes Figure 11 5 Stack size to be used by Kernel Interrupt Handler R20UT0655EJ0100 Rev 1 00 Page 273 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method System stack size y used by system dock interrupt handler When you do not use a system timer there is no need to add a system stack used by the system clock interrupt handler The system stack size y used by the system clock interrupt handler is whichever larger of the two cases below 24 maximu
32. iget_pri Gets the priority of a task Reference task status simple version ref_tst iref_tst Refers to the state of the target task Reference task status ref_tsk iref_tsk Refers to the state of the target task and its priority etc R20UT0655bEJ0100 Rev 1 00 Page 39 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 2 Synchronization functions attached to task The task dependent synchronization functions attached to task is used to accomplish synchronization between tasks by placing a task in the WAIT SUSPENDED or WAIT SUSPENDED state or waking up a WAIT state task The MR30 offers the following task incorporated synchronization service calls e Put Task to sleep slp_tsk tslp_tsk Wakeup task wup_tsk iwup_tsk Wakeups a task that has been placed in a WAIT state by the slp_tsk or tslp_tsk service call No task can be waked up unless they have been placed in a WAIT state ba If a wakeup request is issued to a task that has been kept waiting for conditions other than the slp tsk or tslp_tsk service call or a task in other than DORMANT state by the wup_tsk or iwup tsk service call that wakeup re quest only will be accumulated Therefore if a wakeup request is issued to a task RUNNING state for example this wakeup request is tempo rarily stored in memory Then when the task in RUNNING state is going to be placed into WAIT state by the slp_tsk or tslp tsk service call the accumulated wakeup request becom
33. inthand Registers used are saved to a stack 2 interrupt process Registers used are restored 2 REIT 3 Figure 7 9 Example of Non kernel OS independent Interrupt Handler of Specific Level 5 qf you want the non kernel OS independent interrupt handler to be assigned a priority level lower than kernel OS dependent interrupt handlers change the description of the non kernel OS independent interrupt handler to that of the kernel OS dependent interrupt han dler R20UT0655EJ0100 Rev 1 00 Page 217 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 2 4 Writing Cyclic Handler Alarm Handler When describing the cyclic or alarm handler in Assembly Language observe the following precautions 1 At the beginning of file be sure to include mr30 inc which is in the system directory For the symbol indicating the handler start address make the external declaration Always use the RTS instruction subroutine return instruction to return from cyclic han dlers and alarm handlers For examples INCLUDE mr30 inc 1 GLB cychand 2 cychand handler process TES ES 3 Figure 7 10 Example Handler Written in Assembly Language Use the GLB pseudo directive R20UT0655EJ0100 Rev 1 00 Page 218 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 3 Modifying MR30 Startup Program MR30 comes with two types of
34. ref dtq Reference data queue status iref dtq Reference data queue status handler only C Language API ER ercd ref dtq ID dtqid T RDTQ pk rdtq ER ercd iref dtq ID dtqid T RDIQ pk rdtq e Parameters ID dtqid ID number of the target data queue T RDTQ pk rdtq Pointer to the packet to which data queue status is returned e Return Parameters ER ercd Terminated normally E OK T RDTQ pk rdtq Pointer to the packet to which data queue status is returned Contents of pk rdtq typedef struct t rdtq ID stskid 0 2 Transmission waiting task ID ID wtskid 2 2 Reception waiting task ID UINT sdtqcnt 4 2 Data bytes contained in data queue T RDTQ Assembly language API include mr30 inc ref dtq DTOID PK RDTQ iref dro DTOID PK_RDTO e Parameters DTQID ID number of the target data queue PK RDTQ Pointer to the packet to which data queue status is returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target data queue Al Pointer to the packet to which data queue status is returned Error code None Functional description This service call returns various statuses of the data queue indicated by dtqid 9 stskid Returned to stskid is the ID number of the task at the top of a transmission waiting queue the next task to be dequeued If no tasks are kept waiting TSK_NONE is re
35. task PUSHM AO sig_sem FID_SEM2 R20UT0655EJ0100 Rev 1 00 Page 101 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference wai sem Acquire semaphore resource pol sem Acquire semaphore resource polling ipol sem Acquire semaphore resource polling handler only Wal sem Acquire semaphore resource with timeout C Language API ER ercd wai sem ID semid ER ercd pol sem ID semid ER ercd ipol sem ID semid ER ercd twai sem ID semid TMO tmout Parameters ID semid Semaphore ID number to be acquired TMO tmout Timeout value for twai sem e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc wai sem SEMID pol sem SEMID ipol sem SEMID twai sem SEMID Parameters SEMID Semaphore ID number to be acquired TMO Timeout value twai sem e Register contents after service call is issued wai sem pol sem ipol sem Register name Content after service call is issued RO Terminated normally E OK or error code AO Semaphore ID number to be acquired twai_sem Register name Content after service call is issued RO Terminated normally E_OK or error code RI Timeout value 16 low order bits R3 Timeout value 16 high order bits AO Semaphore ID number to be acquired Error code E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout s R3 Timeout value16 high order bits R1 Timeout value16 low ord
36. 0 ercd sta_tsk ID_task2 stacd void task2 VP INT msg if msg 0 lt lt Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task PUSHM AO R1 sta_tsk ID_TASK4 01234H R20UT0655EJ0100 Rev 1 00 Page 70 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ext_tsk Terminate invoking task C Language API ER ercd ext_tsk e Parameters None e Return Parameters Not return from this service call Assembly language API include mr30 inc ext tsk e Parameters None e Register contents after service call is issued Not return from this service call Error code Not return from this service call Funcional description 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 or more the activation request count is decremented by 1 and processing similar to that of act tsk or iact_tsk is performed In that case the task is placed from DORMANT state into READY state The task has its extended information passed to it as parameter when the task starts up This service call is designed to be issued automatically at return from a task In the invocation of this service call the resources the issuing task had acquired previously e g semaphore are not re leased This service cal
37. 1 The operation of the Configurator ssssssssssseeeeeeneeeneene enne enne 257 Figure 11 1 System Stack and User Stack AAA 267 Figure TE 2 Layout of Stacks uec eere tede eee ee e geen PR Pec re edid eg 268 Figure 11 3 Example of Use Stack GizeCaloilattom cnn nr rnrnnnnn 270 Figure 11 4 System Stack Calculation Method sse 272 Figure 11 5 Stack size to be used by Kernel Interrupt Handler 273 Figure 13 1 ROM Separate e a a aa ennn nn 282 Figure 13 2 M us Nr E EE 284 List of Tables Table 3 1 Task Context and Non task Context sess nennen nnns 27 Table 3 2 Invocable Service Calls in a CPU Locked State sess 29 Table 3 3 CPU Locked and Dispatch Disabled State Transitions Relating to dis dsp and loc cpu29 Table 5 1 Specifications of the Task Management Funchon nano nnnccnnn crac 63 Table 5 2 List of Task Management Function Service Call eene 63 Table 5 3 Specifications of the Task Dependent Synchronization Function sess 84 Table 5 4 List of Task Dependent Synchronization Service Call eese 84 Table 5 5 Specifications of the Semaphore Function sssssseeeeeeeeeennenn nnns 99 Table 5 6 List of Semaphore Function Service Call eese nnns 99 Table 5 7 Specifications of the Eventflag Function ssssssssseeseseeeeeeeenneenn nnne 107 Table5 8 List of Eventflag Function GervicerCall rn rnr nn 1
38. 10 slp_tsk pget mpl 5 tslp tsk rel mpl 0 wup tsk ref mpl 12 can wup set tim 10 rel wai get tim 10 sus tsk sta cyc 10 rsm tsk stp cyc 10 frsm tsk ref cyc 10 dly tsk sta alm 10 sig sem AIAINININIAIOIAIAINIOI OJO stp_alm 10 wai_sem N o ref_alm 10 pol_sem o rot_rdq 0 twai_sem N N get_tid 10 5 ref_sem o loc_cpu 4 set_flg elajolajojojojojojojo 3jojojo oo unl cpu 0 clr fe n o ref_ver 12 wai_flg N o vsnd_dtq 0 pol_flg o vpsnd_dtq 0 twai_flg vtsnd_dtq ref_flg vfsnd_dtq 0 snd_dtq vrcv dtq psnd dtq vprcv dtq tsnd_dtq vtrev_dtq fsnd_dtq vref_dtq rcv_dtq vrst_dtq prev_dtq vrst_vdtq trev_dtq vrst_mbx ref_dtq vrst_mpf snd_mbx vrst_mpl dis_dsp ena_dsp Stack sizes used by service call in C programs R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 ztENESAS ololglo x imjoj slaja S a Blojolojojojolojojojojojojo o Page 275 of 295 M3T MR30 4 11 Stack Size Calculation Method Tabl e 11 2 Stack Sizes Used by Servi ce Calls Issued fromHandlers in bytes lists the stack sizes system stack used by service calls that can be issued from handlers Table 11 2 Stack Sizes Used by Servic
39. 16 58 pusha FROM amp Offffh 59 60 glb _bcopy 61 331 2 _bcopy 62 endm 63 64 65 Interrupt section start 66 67 glb SYS INITIAL 68 Section MR KERNEL CODE ALIGN R20UT0655EJ0100 Rev 1 00 Page 220 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 69 __SYS_INITIAL 70 71 after reset this program will start 72 3 73 lde Sys Sp amp OFFFFH ISP set initial ISP 74 75 mov b 2H OAH 76 mov b 00 PMOD Set Processor Mode Regsiter 77 mov b OH OAH 78 79 ldc 00H FLG 80 ldc Sys Sp amp OFFFFH fb 81 lde BB 80 82 83 84 ISSUE SYSTEM CALL DATA INITIALIZE 85 86 For PD30 87 INIT ISSUE SYSCALL 88 89 90 MR RAM DATA O zero clear 91 4 92 N BZERO MR RAM top MR RAM 93 94 95 96 NEAR area initialize 97 98 bss zero clear 99 100 N BZERO TOPOF bss SE bss SE 101 N BZERO TOPOF bss SO bss SO 102 103 N BZERO TOPOF bss NE bss NE 104 N BZERO TOPOF bss NO bss NO 105 106 107 initialize data section 108 109 N_BCOPY TOPOF data SEI data SE top data SE 110 N BCOPY TOPOF data SOI data SO top data SO 111 N BCOPY TOPOF data NEI data NE top data NE 112 N BCOPY TOPOF data NOI data NO top data NO 113 114 s 115 FAR area initial
40. 20 Series AO A7 BOO B5 XO X2 OTHER NOTIMER M16C 10 Series OTHER NOTIMER R8C Family RA RB OTHER NOTIMER Default value NOTIMER Define the hardware timers used for the system clock If you do not use a system clock define NOTIMER It is necessary to note that the timer that the microcomputer doesn t have is not specified because the setting range of the timer of each the above mentioned series is not checked in the configurator Please set the timer used by the start up specifying OTHER when the M16C 10 series is used 3 System clock interrupt priority level Definition format Numeric value Definition range 1 to Kernel mask OS interrupt disable level in system definition Default value 4 Define the priority level of the system clock timer interrupt The value set here must be smaller than the kernel mask OS interrupt disable level Interrupts whose priority levels are below the interrupt level defined here are not accepted during system clock interrupt handler processing 4 System clock address correction Definition format Symbol Definition range YES or NO Default value NO When the SFR address of the timer specified for the system clock is the same as M16C 64 it is specified as YES Concretely when M16C 63 64 64A 64C 65 65C 6B 6C group or the M16C 50 series is used it is specified as YES eurrent reg map must be NO when RA an
41. 2011 RENESAS M3T MR30 4 5 Service call reference 5 12System Status Management Function Table 5 23 List of System Status Management Function Service Call No Service Call Function System State T N E D ULL 1 rot_rdq S Rotates task precedence O olojo 2 irot_rdq S oloiliojjo 3 get_tid S References task ID in the RUN O olojo 4 iget_tid S NING state olololo 5 loc_cpu S Locks the CPU O O O JO O 6 iloc_cpu S o O 0 0 0 7 unl cpu S Unlocks the CPU O O O JO O 8 iunl cpu S o O0 0 0 0 9 dis_dsp S Disables dispatching O O JO O 10 ena_dsp S Enables dispatching O olojo 11 sns_ctx S References context o o 0 0 01 0 12 sns_loc S References CPU state o o 0O0 0 01 0 13 sns_dsp S References dispatching state OJO JO O O O 14 sns dpn S References dispatching pending O O O O O O state Notes S Standard profile service calls e Each sign 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UTO655EJ0100 Rev 1 00 Page 167 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference rot rdq Rotate task precedence irot
42. Dataqueue Function Service Call esee 188 Table 5 28 List of Reset Function Service Call 197 Table 7 1 C Language Variable Treatment esses enne enne nn 210 Table 8 1 Numerical Value Entry Examples sse 228 Table 8 2 Operatore cccococcconcccnoncncnonnnonnnnono conan nnnnnn rn nnnR nn non RR RR RR RRE RR RRE RRE R RR RRR RR RnnNR rr rn nr aran rn anne nnnnrrnannrnrns 228 Table 8 3 Interrupt Causes and Vector Numbers enne nnne nnne nnn 251 Table 10 1 Functions in the Sample Pro am 264 Table 11 1 Stack Sizes Used by Service Calls Issued from Tasks in bytes 275 Table 11 2 Stack Sizes Used by Service Calls Issued from Handlers in bytes 276 Table 11 3 Stack Sizes Used by Service Calls Issued from Tasks and Handlers in bytes 276 Table 12 1 Interrupt Number Assignment sse eene ener nnne enne nnne nnn 277 1 User s Manual Organization The MR30 User s Manual consists of nine chapters and thee appendix 2 General Information Outlines the objective of MR30 development and the function and position of the MR30 3 Introduction to Kernel Explains about the ideas involved in MR30 operations and defines some relevant terms 4 Kernel Outlines the applications program development procedure for the MR30 5 Service call reference Details MR30 service call API 6 Applications Developme
43. ID numbers are automatically assigned in order of numbers beginning with the smallest lt lt Content gt gt For each mailbox ID number define the items described below R20UT0655EJ0100 Rev 1 00 Page 242 of 295 Jun 01 2011 ztENESAS M3T MR30 4 8 Using Configurator 1 2 3 4 ID name Definition format Symbol Definition range None Default value None Define the name by which the mailbox is specified in a program Select mailbox waiting queue Definition format Symbol Definition range TA_TFIFO or TA_TPRI Default value TA_TFIFO Select a method in which tasks wait for the mailbox If TA_TFIFO is selected tasks are enqueued in order of FIFO If TA_TPRI is selected tasks are enqueued in order of priority beginning with the one that has the highest priority Select message queue Definition format Symbol Definition range TA_MFIFO or TA_MRPI Default value TA_MFIFO Select a method by which a message queue of the mailbox is selected If TA_MFIFO is selected messages are enqueued in order of FIFO If TA_MPRI is selected messages are enqueued in order of priority beginning with the one that has the highest priority Maximum message priority Definition format Numeric Value Definition range 1 to maximum value of message priority that was specified in definition of maximum number of items Default value 1 Specify the maximum priori
44. INTERRUPT_VECTOR INT3 external interrupt 28 INTERRUPT_VECTOR INT2 external interrupt 29 INTERRUPT_VECTOR INT1 external interrupt 30 INTERRUPT_VECTOR INTO external interrupt 31 INTERRUPT_VECTOR Timer B5 32 INTERRUPT_VECTOR UART2 transmit NACK 33 INTERRUPT_VECTOR UART2 receive ACK 34 INTERRUPT_VECTOR UARTS3 transmit NACK 35 INTERRUPT VECTOR UARTS3 receive ACK 36 INTERRUPT VECTOR UARTA transmit NACK 37 INTERRUPT VECTOR UARTA receive ACK 38 INTERRUPT VECTOR BUS conflict UART2 39 INTERRUPT VECTOR BUS conflict UART3 40 INTERRUPT VECTOR BUS conflict UART4 41 INTERRUPT VECTOR A D 42 INTERRUPT VECTOR Key input interrupt 43 INTERRUPT VECTOR User Software interrupt 44 INTERRUPT VECTOR A INTERRUPT_VECTOR INTERRUPT VECTOR User Software interrupt 54 INTERRUPT VECTOR Software interrupt for MR30 55 INTERRUPT VECTOR User Software interrupt 56 INTERRUPT VECTOR User Software interrupt 57 INTERRUPT_VECTOR Software interrupt for MR30 58 INTERRUPT_VECTOR INTERRUPT VECTOR Software interrupt for MR30 62 INTERRUPT VECTOR Software interrupt for MR30 63 INTERRUPT VECTOR Undefined instruction 247 FIX INTERRUPT VECTOR Over flow 248 FIX INTERRUPT VECTOR BRK instruction 249 FIX INTERRUPT VECTOR Address match 250 FIX INTERRUPT VECTOR FIX INTERRUPT VECTOR Watch dog timer 252 FIX INTERRUPT VECTOR FIX INTERRUPT VECTOR NMI 254 FIX INTERRUPT VECTOR Reset 255 FIX INTERRUPT VECTOR R20UTO655EJ0100 Rev 1 00 Page 251 of 295 Jun 01 2011 RENESAS M3T MR30 4
45. If this service call is to be issued from task context use get mpf pget mpf tget mpf if issued from non task context use ipget mpf R20UT0655EJ0100 Rev 1 00 Page 136 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h VP p_blk void task d if get mpf ID mpf amp p blk E OK error Not enough memory Nn if pget mpf ID mpf amp p blk E OK error Not enough memory Nn E if tget_mpf ID_mpf amp p blk 10 E OK error Not enough memory Nn lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO get_mpf ID_MPF1 PUSHM AO pget mpf ID_MPF1 PUSHM AO MOV W R1 200 MOV W R3 0 tget_mpf ID_MPF1 R20UT0655EJ0100 Rev 1 00 Page 137 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference rel mpf Release fixed size memory block irel mpf Release fixed size memory block handler only C Language API ER ercd rel mpf ID mpfid VP blk ER ercd irel mpf ID mpfid VP blk e Parameters ID mpfid ID number of the fixed size memory pool to be released VP blk Start address of the memory block to be returned e Return Parameters ER ercd Terminated normally E_OK Assembly language API
46. Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference pget_mpl Aquire variable size memory block polling C Language API ER ercd pget mpl ID mplid UINT blksz VP p_blk Parameters ID mplid ID number of the target Variable size Memory pool to be acquired UINT blksz Memory size to be acquired in bytes VP p_blk Pointer to the start address of the acquired variable memory Return Parameters ER ercd Terminated normally E_OK or error code VP p blk Pointer to the start address of the acquired variable memory Assembly language API include mr30 inc pget mpl MPLID BLKSZ e Parameters MPLID ID number of the target Variable size Memory pool to be acquired BLKSZ Memory size to be acquired in bytes e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code R1 Memory size to be acquired AO ID number of the target Variable size Memory pool to be acquired Error code E TMOUT No memory block R20UT0655EJ0100 Rev 1 00 Page 143 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call acquires a memory block from the variable size memory pool indicated by mplid and stores the start address of the acquired memory block in the variable p_blk The content of the acquired memory block is indeterminate If the specified variable size memory pool
47. MBXID PK MBX Parameters MBXID ID number of the mailbox to which transmitted PK MBX Message to be transmitted address e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the mailbox to which transmitted Al Message to be transmitted address Structure of the message packet lt lt Mailbox message header gt gt typedef struct t_msg VP msghead 0 2 Kernel managed area T_MSG lt lt Mailbox message header with priority included gt gt typedef struct t_msg T MSG msgque 0 2 Message header PRI msgpri 2 2 Message priority T MSG PRE Error code None Functional description This service call sends the message indicated by pk msg to the mailbox indicated by mbxid T MSG should be speci fied with a 16 bit address If there is any task waiting to receive a message in the target mailbox the transmitted message is passed to the task at the top of the waiting queue and the task is released from WAITING state To send a message to a mailbox whose attribute is TA MFIFO add a T MSG structure at the beginning of the message when creating it as shown in the example below To send a message to a mailbox whose attribute is TA MPRI add a T MSG PRI structure at the beginning of the mes sage when creating it as shown in the example below Messages should always be created in a RAM area regardless of whether its
48. Page 18 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 4 Task This section describes how tasks are managed by MR30 3 4 1 Task Status The real time OS monitors the task status to determine whether or not to execute the tasks Figure 3 15 shows the relationship between key input task execution control and task status When there is a key input the key input task must be executed That is the key input task is placed in the execution RUNNING state While the system waits for key input task execution is not needed In that situation the key input task in the WAITING state Key input Task Key input Waiting for Key input processing key input processing RUNNIG state WAITING state RUNNING state Figure 3 15 Task Status The MR30 controls the following six different states including the RUNNING and WAITING states 1 RUNNING state 2 READY state 3 WAITING state 4 SUSPENDED state 5 WAITING SUSPENDED state 6 DORMANT state Every task is in one of the above six different states Figure 3 16 shows task status transition R20UT0655EJ0100 Rev 1 00 Page 19 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel MPU exedusive right acquisition READY state WAITING state MPU execlusive right relinguishment RUNNING state Entering the WAITING state WAITING state SUSPENDED state clear SUSPEND request Forced Terminate E from other task mue s
49. Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc vrst mpl MPLID e Parameters MPLID Variable size memory pool ID to be cleared Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO Variable size memory pool ID to be cleared Error code None Funcional description This service call initializes the variable size memory pool indicated by mplid This service call can be issued only from task context It cannot be issued from non task context Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void taskl void vrst_mpl ID_mpll lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO vrst_mpl FID_MPL1 R20UT0655EJ0100 Rev 1 00 Page 205 of 295 Jun 01 2011 RENESAS 6 Applications Development Procedure Overview 6 1 Overview Application programs for MR30 should generally be developed following the procedure described below 1 Generating a project When using High performance Embedded Workshop create a new project using MR30 on High performance Embedded Workshop 2 Coding the application program Write the application program in code form using C or assembly language If necessary correct the sample startup program crtOmr
50. Tel 1 905 898 5441 Fax 1 905 898 3220 Renesas Hectronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Hectronics Europe GmbH Arcadiastrasse 10 40472 D sseldorf Germany Tel 49 211 65030 Fax 49 211 6503 1327 Renesas Hectronics China Co Lid 7th Hoor Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100083 PRChina Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Hectronics Shanghai Co Lid Unit 204 205 AZIA Center No 1233 Lujiazui Ring Fd Pudong District Shanghai 200120 China Tel 86 21 5877 1818 Fax 86 21 6887 7858 7898 Renesas Hectronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2886 931 8 Fax 852 2886 9022 9044 Renesas Hectronics Taiwan Co Lid 7F No 363 Fu Shing North Road Taipei Taiwan Tel 886 2 8175 9600 Fax 886 2 81 75 9670 Renesas Hectronics Singapore Pte Ltd 1 harbourFront Avenue 106 10 keppel Bay Tower Singapore 098632 Tel 65 6213 0200 Fax 65 6278 8001 Renesas Hectronics Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jn Persiaran Barat 46050 Petaling Jaya Selangor Darul Ensan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Hectronics Korea Co Ltd 11F Samik Lavied or Bldg 720 2 Yeoksam Dong Kangnam Ku Seoul 135 080
51. a30 and section definition file c_sec inc or asm sec inc 3 Creating a configuration file Create a configuration file which has defined in it the task entry address stack size etc by using an editor The GUI configurator available for MR30 may be used to create a configuration file 4 System generation Execute build on High performance Embedded Workshop to generate a system 5 Writing to ROM Using the ROM programming format file created write the finished program file into the ROM Or load it into the debugger to debug Figure 6 1 shows a detailed flow of system generation R20UT0655EJ0100 Rev 1 00 Page 206 of 295 Jun 01 2011 RENESAS M3T MR30 4 6 Applications Development Procedure Overview High performance Embedded Workshop Configuration file MR30 indude file Configurator kernel h cfg30 Y Indude file kernel id h kernel svsint h C standard header file Application include file Indude file System data definition file mr30 inc sys_ram inc sys_rom inc VA Startup program start a30 ctOmr a30 J amp table file mrtable a30 Create J amp table utility mkmrtbl Application C source Application Assembler source Relocatable Assembler as30 Systemcall file mrc C standard Application MR30 object Library Library y y Linkage Editor optink or In30 Absolute module L
52. acquired immediately is returned If this service call is to be issued from task context use ref mpl if issued from non task context use iref mpl R20UT0655EJ0100 Rev 1 00 Page 147 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RMPL rmpl ER ercd ercd ref_mpl ID_MPL1 amp rmpl lt lt Example statement in assembly language gt gt include mr30 inc GLB task refmpl blkb 8 task PUSHM A0 A1 ref_mpl ID_MPL1 _refmpl R20UT0655EJ0100 Rev 1 00 Page 148 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 9 Time Management Function Specifications of the time management function of MR30 are listed in Table 5 17 5 Service call reference Table 5 17 Specifications of the Time Management Function No Item Content 1 System time value Unsigned 48 bits 2 Unit of system time value 1 ms 3 System time updating cycle User specified time tick updating time ms 4 Initial value of system time at initial startup 000000000000H Table 5 18 List of Time Management Function Service Call No Service Call Function System State T N E D U L 1 get_tim S Reference system O OO Qo 2 iget tim time olololo 3 set_tim S Set sys
53. alarm handler to be operated ALMTIM Alarm handler startup time relative time e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK RI Alarm handler startup time 16 low order bits relative time R3 Alarm handler startup time 16 high order bits relative time AO ID number of the alarm handler to be operated Error code None Functional description This service call sets the activation time of the alarm handler indicated by almid as a relative time of day after the lapse of the time specified by almtim from the time at which it is invoked and places the alarm handler into an operational state If an already operating alarm handler is specified the previously set activation time is cleared and updated to a new acti vation time If almtim 0 is specified the alarm handler starts at the next time tick The values specified for almtim must be within Ox 7fffffff time tick If any value exceeding this limit is specified the service call may not operate correctly If 0 is specified for almtim the alarm handler is started at the next time tick If this service call is to be issued from task context use sta alm if issued from non task context use ista alm e R3 Invoked time value16 high order bits R1 Invoked time value16 low order bits must be set before calling sevice call ae R3 Invoked time value16 high order bits R1 In
54. awaking conditions thereby satisfied The error code returned in this case is E OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI If this service call is to be issued from task context use rcv_dtq trcv_dtq prev_dtq if issued from non task context use iprcv dro R20UTO0655EJ0100 Rev 1 00 Page 122 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task VP_INT data if rcv dtq ID dtq amp data E RLWAI error forced wakeup Nn if prcv dtq ID dtq amp data E TMOUT error Timeout n E if trcv dtq ID_dtq amp data 10 error Timeout Wn TMOUT E lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO R1 R3 MOV W D RI MOV W 0 R3 trcv_dtg ID_DTQ1 PUSHM AO prcv dtq ID DTO2 PUSHM AO rcv dtq ID DTQ2 R20UTO0655EJ0100 Rev 1 00 Page 123 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference
55. begins with an alphabetical letter between A and F with h or H attached to the end be sure to add 0 to the beginning Note that the system does not distinguish between the upper and lower case alphabetical characters A F used as numerical values 2 Decimal Number Use an integer only as in 23 However it must not begin with 0 3 Octal Numbers Add 0 to the beginning of a numerical value of O or o to end 4 Binary Numbers Add B or b to the end of a numerical value It must not begin with 0 DI The System distinguishes between the upper and lower case letters except for the numbers A F and a f R20UT0655EJ0100 Rev 1 00 Page 227 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Table 8 1 Numerical Value Entry Examples Oxf12 Oxf12 0a12h Hexadecimal 0a12H 12h 12H Decimal 32 017 Octal 170 170 Binary 101110b 101010B It is also possible to enter operators in numerical values Table 8 2 Operators lists the operators available Table 8 2 Operators Operator Priority Direction of computation Unary_minus From right to left 9o From left to right Binary minus Low From loft to right Numerical value examples are presented below e 123 e 1234 0x23 e 23 443 2 e 100B 0aH Symbol The symbols are indicated by a character string that consists of numerals upper and lower
56. below and the time management function of the MR30 are unused a timer does not need to be occupied for use by MR30 e Place a task in a finite time wait state by specifying a timeout value A timeout can be specified in a service call that places the issuing task into WAITING state This service call includes tslp_tsk twai_flg twai_sem tsnd_dtq trcv dtq trev_mbx tget_mpf vtsnd_dtq and vtrev_dtq If the wait cancel condition is not met before the specified timeout time elapses the error code E TMOUT is returned and the task is freed from the wait state If the wait cancel condition is met the error code E OK is returned The timeout time should be specified in ms units tslp tsk 50 E TMOUT READY state WAITING state 50 A Timeout value tslp tsk 50 E OK RUN state WAITING state A iwup_tsk Figure 4 20 Timeout Processing MR30 guarantees that as stipulated in uITRON specification timeout processing is not performed until a time equal to or greater than the specified timeout value elapses More specifically timeout processing is performed with the following timing 1 If the timeout value is O for only dly_tsk The task times out at the first time tick after the service call is issued 2 If the timeout value is a multiple of time tick interval The timer times out at the timeout value time tick interval first time tick For example if the time tick interval is 10 m
57. call updates the current value of the system time to the value indicated by p_systim The time specified by packet is expressed in ms units and not by the number of time ticks The values specified by packet must be within OX7FFF FFFFFFFF If any value exceeding this limit is specified the ser vice call may not operate correctly If this service call is to be issued from task context use set_tim if issued from non task context use iset_tim R20UT0655EJ0100 Rev 1 00 Page 150 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt 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 amp time Sets the system time lt lt Example statement in assembly language gt gt include mr30 inc GLB task _g_systim WORD 1111H LWORD 22223333H task PUSHM AO set tim g systim R20UT0655EJ0100 Rev 1 00 Jun 01 2011 RENESAS Page 151 of 295 M3T MR30 4 5 Service call reference get_tim Reference system time iget_tim Reference system time handler only C Language API ER ercd get_tim SYSTIM p_systim ER ercd iget_tim SYSTIM p_systim e Parameters SY STIM p_systim Pointer to the packet to which curren
58. case alphabetical letters underscore and and begins with a non numeric character Example symbols are presented below e _TASK1 e IDLE3 Function Name The function names are indicated by a character string that consists of numerals upper and 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 R20UT0655EJ0100 Rev 1 00 Page 228 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator e main e func When written in the assembly language the start label of a module is assumed to be a function name Frequency The frequency is indicated by a character string that consist of numerals and period and ends with MHz The numerical values are significant up to six decimal places Also note that the frequency can be entered us ing decimal numbers only Frequency entry examples are presented below e 16MHz e 8 1234MHz Itis also well to remember that the frequency must not begin with period Time The time is indicated by a character string that consists of numerals and period and ends with ms The time values are effective up to three decimal places when the character string is terminated with ms Also note that the time can be entered using decimal numbers only e 10ms e 10 5ms Itis also well to remember that t
59. dd dd dd dd d dd dd d dd dd AAA AAA dd dd dd dd dd dd dd LITT ATLA TTT TTT TTT TTT TTT TITAS TTA TTT TTT Page 252 of 295 M3T MR30 4 70 wait_multi 71 72 flag 1 13 name ID flg2 74 initial pattern T5 wait_queue 76 clear_attribute 77 wait_multi 78 Y 79 flag 2 80 name ID_flg3 81 initial_pattern 82 wait_queue 83 clear_attribute 84 wait_multi 85 86 flag 87 name ID flg4 88 initial pattern 89 wait queue 90 clear attribute 91 wait multi 92 93 94 semaphore 95 name ID sem1 96 wait queue 97 initial count 98 max_count 10 99 100 semaphore 2 101 name ID_sem2 102 wait_queue 103 initial_count 104 max_count 10 105 106 semaphore 107 name ID_sem3 108 wait_queue 109 initial_count 0 max_count 255 1 2 3 dataqueue 114 name ID_dtql T5 wait_queue 6 buffer_size 7 8 dataqueue 2 119 name ID_dtq2 120 wait_queue 121 buffer size 122 123 dataqueue 3 124 name ID_dtq3 125 wait_queue 126 buffer_siz 127 128 129 mailbox 130 name ID mbx1 131 wait queue 132 message_queu 133 max pri 4 134 135 mailbox 136 name ID mbx2 137 wait queue 138 message_queu 139 max_pri 64 140 141 mailbox 142 name ID_mbx3 143 wait_queue 144 message_queu R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 TA_WSGL 0x00000001 TA TFIFO NO
60. ethod sessi nnne nne 267 11 1 1 User Stack Calculation Meho AAA 269 111 2 System Stack Calculation Methol AAA 271 11 2 Necessary Stack Silicon E ere cR niger anee cuR DER Rea one Rn 275 TEM Toi M 277 St LheUseof INT INstructiO nitet er ten ada ER a RARO 277 12 2 TheUseof registers of bank esssssssssesseeseese enne enne nennen trennen tnnt nnne tnter nne sn rennen 277 12 3 Regarding Delay Dispatching 278 12 4 Regarding Initially Activated Taek nnne nnne nennen tnter 279 12 5 Cautions for each microcontrollers AA 279 12 5 1 TousetbeMi eCiGioroupMCUe nnne nnne nennen eniin innen 279 12 5 2 Tousethe M 16C 6N oropMCUs nnne nnne nnne entren enne enn 279 13 Separate ROM Sis seca tied A eee ree ERE ER Raid 280 13 1 How to Form Separate ROMS ANE 280 E ie ne TEE 285 14 1 Common Constants and Packet Format of Structure 285 14 2 Assembly L anouagelntertace eeccecceeeceeseeceee eee eeee eee eeeee eae enne nnn nennen trennen nnn trn tnnt nnne tnn 287 VII List of Figures Figure 3 1 Relationship between Program Size and Development Period ssssss 5 Figure 3 2 Microcomputer based System E xample Audio E qui pment esses 6 Figure 3 3 Example System Configuration with Real time OS Audio Equipment 7 Figure 3 4 Time division Task Operation 8 Figure 3 5 Task Execution Interruption and Re
61. for a Long data queue that is full of data the task that issued the service call goes from RUNNING state to a data transmission wait state and is enqueued in a transmission waiting queue kept waiting for the Long data queue to become available In that case if the attribute of the specified Long data queue is TA TFIFO the task is enqueued in order of FIFO if TA TPRI the task is enqueued in order of priority For vpsnd dro and vipsnd dtq the task returns immediately and responds to the call with the error code E TMOUT For the vtsnd dtq service call specify a wait time for tmout in ms units The values specified for tmout must be within Ox 7fffffff time tick If any value exceeding this limit is specified the service call may not operate correctly If TMO POL O is specified for tmout it means specifying 0 as a timeout value in which case the service call operates the same way as vpsnd_dtq Furthermore if specified as tmoutZTMO FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as vsnd dtq If there are no tasks waiting for reception nor is the Long data queue area filled the transmitted data is stored in the Long data queue The task placed into a wait state by execution of the vsnd dro or vtsnd_dtq service call is released from WAITING state in the following cases When the vrcv dtq vtrcv dtq vprcv dtq or viprcv dtq service call is issued before the tmout time elapses with tas
62. from C language is included with the software package 5 An upstream process tool named Configurator is provided to simplify development proce dures A configurator is furnished so that various items including a ROM write form file can be created by giving sim ple definitions Therefore there is no particular need to care what libraries must be linked In addition a GUI version of the configurator is available beginning with M3T MR30 4 V 4 00 It helps the user to create a configuration file without the need to learn how to write it R20UT0655EJ0100 Rev 1 00 Page 4 of 295 Jun 01 2011 RENESAS 3 Introduction to Kernel 3 1 Concept of Real time OS This section explains the basic concept of real time OS 3 1 1 Why Real time OS is Necessary In line with the recent advances in semiconductor technologies the single chip microcomputer ROM capacity has in creased ROM capacity of 32K bytes As such large ROM capacity microcomputers are introduced their program development is not easily carried out by con ventional methods Figure 3 1 shows the relationship between the program size and required development time program development difficulty This figure is nothing more than 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 the development of one 32K byte program Developm
63. handler only C Language API ER ercd ref cyc ID cycid T RCYC pk rcyoc ER ercd iref cyc ID cycid T RCYC pk rcyoc e Parameters ID cycid ID number of the target cyclic handler T RCYC pk rcyc Pointer to the packet to which cyclic handler status is returned e Return Parameters ER ercd Terminated normally E OK T RCYC pk rcyc Pointer to the packet to which cyclic handler status is returned Contents of pk rcyc typedef struct t_reyc STAT cycstat 0 2 Operating status of cyclic handler RELTIM lefttim 2 4 Left time before cyclic handler starts up T_RCYC Assembly language API include mr30 inc ref cyc ID PK RCYC iref cyc ID PK RCYC Parameters CYCNO ID number of the target cyclic handler PK RCYC Pointer to the packet to which cyclic handler status is returned Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target cyclic handler Al Pointer to the packet to which cyclic handler status is returned Error code None Functional description This service call returns various statuses of the cyclic handler indicated by cycid cycstat The status of the target cyclic handler is returned TCYC_STA Cyclic handler is an operational state TCYC_STP Cyclic handler is a non operational state lefttim The remaining time before the target cyclic handler will start next is re
64. id h which is in the current directory 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 subroutine call from a system clock interrupt handler include lt itron h gt include lt kernel h gt include kernel_id h void cychand void process Figure 7 5 Example Cyclic Handler Written in C Language HI The handler to function name correlation is determined by the configuration file R20UT0655EJ0100 Rev 1 00 Page 213 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 2 Program Coding Procedure in Assembly Language This section describes how to write an application using the assembly language 7 2 1 Writing Task This section describes how to write an application using the assembly language 1 Be sure to include mr30 inc at the beginning of file For the symbol indicating the task start address make the external declaration 3 Be sure that an infinite loop is formed for the task or the task is terminated by the ext_tsk service call INCLUDE mr30 inc 1 GLB task 2 task process jmp task 3 Figure 7 6 Example Infinite Loop Task Described in Assembly Language INCLUDE mr30 inc GLB task task process ext_tsk Figure 7 7 Example Task Terminating with ext_tsk Described in Assembly Language 4 The initial register values at task startup are indeterminate except
65. independent interrupt handler NOTE If this restriction is not observed the software may malfunction 3 Afunction that is declared to be static cannot be registered as an interrupt handler If you want multiple interrupts to be enabled in a non kernel an OS independent interrupt handler always make sure that the non kernel OS independent interrupt handler is as signed a priority level higher than other kernel OS dependent interrupt handlers 9 include itron h include kernel h include kernel id h void inthand void process Figure 7 4 Example of Non kernel OS independent Interrupt Handler 80 f you want the non kernel OS independent interrupt handler to be assigned a priority level lower than kernel OS dependent interrupt handlers change the description of the non kernel OS independent interrupt handler to that of the kernel OS dependent interrupt han dler R20UT0655EJ0100 Rev 1 00 Page 212 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 1 4 Writing Cyclic Handler Alarm Handler When describing the cyclic or alarm handler in C language observe the following precautions 1 Describe the cyclic or alarm handler as a function 2 Be sure to declare the return value and argument of the interrupt handler start function as a VP INT type 3 At the beginning of file be sure to include itron h kernel h which is in the system di rectory as well as kernel
66. lt User Restore Registers H TaskB Figure 3 12 Processing Procedure for a Service Call from a Handler that caused an interrupt during Service Call Processing R20UT0655EJ0100 Rev 1 00 Page 16 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Service Calls from a Handler That Caused an Interrupt during Handler Execution Let us think of a situation in which an interrupt occurs during handler execution this handler is hereinafter referred to as handler A for explanation purposes When task switching is called for as a handler hereinafter referred to as handler B that caused an interrupt during handler A execution issued a service call task switching does not take place during the execution of the service call ret_int service call returned from handler B but is effected by the ret_int service call from handler A See Figure 3 13 TaskA Interrupt handler A Interrupt handler A Interrupt Save Registers SP lt System NN Interrupt OS Save Registers Service call processing iset flg Restore Register Restore Register Task selection ret int SP lt User Restore Registers TaskB Figure 3 13 Processing Procedure for a service call from a Multiplex interrupt Handler R20UT0655EJ0100 Rev 1 00 Page 17 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 3 Object The object operated by the service call of a se
67. memory pool status is returned Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO Task ID waiting for memory block to be acquired Al Pointer to the packet to which fixed size memory pool status is returned Error code None Funcional description This service call returns various statuses of the message buffer indicated by mpfid wtskid Returned to wtskid is the ID number of the task at the top of a memory block waiting queue the first queued task If no tasks are kept waiting TSK_NONE is returned fblkcnt The number of free memory blocks in the specified memory pool is returned If this service call is to be issued from task context use rel mpf if issued from non task context use irel_mpf R20UT0655EJ0100 Rev 1 00 Page 140 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RMPF rmpf ER ercd ercd ref mpf ID MPF1 amp rmpf lt lt Example statement in assembly language gt gt include mr30 inc GLB task _ refmpf blkb 4 task PUSHM A0 A1 ref mpf ID_MPF1 _refmpf R20UT0655bEJ0100 Rev 1 00 Page 141 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 8 Memory Pool Ma
68. number of the target task e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO ID number of the target task Error code E_OBJ Object status invalid task indicated by tskid is an inactive state E_QOVR Queuing overflow Functional description This service call aborts execution of the task indicated by tskid and places it into SUSPENDED state Tasks are resumed from this SUSPENDED state by the rsm_tsk irsm_tsk frsm_tsk or ifrsm_tsk service call If the task indicated by tskid is in DORMANT state it returns the error code E_OBJ as a return value for the service call The maximum number of suspension requests by this service call that can be nested is 1 If this service call is issued to a task which is already in SUSPENDED state the error code E QOVR is returned This service call forbids specifying the issuing task itself for tskid If this service call is to be issued from task context use sus tsk if issued from non task context use isus_tsk R20UT0655EJ0100 Rev 1 00 Page 93 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task if sus_tsk ID_main E_OK printf Can t suspend task main n lt lt Example statem
69. over character number of including path name The path name of include file is longer than 255 characters R20UT0655EJ0100 Rev 1 00 Page 262 of 295 Jun 01 2011 RENESAS 9 Table Generation Utility 9 1 Summary The utility mkritbl is a command line tool that after collecting service call information used in the application generates service call tables and interrupt vector tables In kernel_sysint h that is included by kernel h it is so defined that when service call functions are used the service call information will be output to the mrc file by the assert control instruction Using these service call information files as its input mkritbl generates a service call table in such a way that only the service calls used in the system will be linked Furthermore mkritbl generates an interrupt vector table based on the vector table template files output by cfg30 and the mrc file 9 2 Environment Setup Following environment variables need to be set e LIB30 lt Installation directory gt lib30 9 3 Table Generation Utility Start Procedure The table generation utility is started in the form shown below C 1 gt mkmrtbl directory name or file name gt For the parameter normally specify the directory that contains the mrc file that is generated when compiled Multiple directories or files can be specified Note that the mrc file present in the current directory is unconditionally selected for input Also it is nec
70. priority O olojo 10 ichg_pri O JO O O 11 get pri S Refers to task priority O olojo 12 iget_pri O JO O O 13 ref_tsk Refers to task state O olojo 14 iref_tsk 0 0O O O 15 ref tst Refers to task state simple version O oloo 16 iref tst olojojo R20UT0655EJ0100 Rev 1 00 Page 63 of 295 Jun 01 2011 RENESAS M3T MR30 4 Notes e S Standard profile service calls e Each sign within System State is a following meaning 9999 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 132 N SAS 5 Service call reference Page 64 of 295 M3T MR30 4 5 Service call reference act_tsk Activate task lact tsk Activate task handler only C Language API ER ercd act tsk ID tskid ER ercd iact tsk ID tskid e Parameters ID bkid ID number of the task to be started e Return parameters ER ercd Terminated normally E_OK or error code Assembly language API include mr30 inc act tsk TSKID iact tsk TSKID e Parameters TSKID ID number of the task to be started e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO Task ID Error Code
71. rdq Rotate task precedence handler only C Language API ER ercd rot rdq PRI tskpri ER ercd irot rdq PRI tskpri e Parameters PRI tskpri Task priority to be rotated e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc rot rdq TSKPRI irot rdq TSKPRI e Parameters TSKPRI Task priority to be rotated e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK R3 Task priority to be rotated Error code None R20UT0655EJ0100 Rev 1 00 Page 168 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call rotates the ready queue whose priority is indicated by tskpri In other words it relocates the task en queued at the top of the ready queue of the specified priority by linking it to behind the tail of the ready queue thereby switching over the executed tasks that have the same priority Figure5 1 depicts the manner of how this is performed Proprity 1 gt tcp Priority 2 TCB TCB PER TCB TCB TCB pe Moved to behind the tail of the queue Figure5 1 Manipulation of the ready queue by the rot rdq service call By issuing this service call at given intervals it is possible to perform round robin scheduling If tskpriZTPRI SELF is specified when using the rot rdq service call the ready queue whose priority is that of the is
72. release from waiting E TMOUT Polling failure or timeout or timed out i R3 Timeout value16 high order bits R1 Timeout value16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 129 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call receives a message from the mailbox indicated by mbxid and stores the start address of the received message in the area pointed to by ppk_msg T_MSG should be specified with a 16 bit address If data is present in the target mailbox the data at the top of the mailbox is received On the other hand if rev_mbx or trev_mbx is issued for a mailbox that has no messages in it the task that issued the ser vice call goes from RUNNING state to a message reception wait state and is enqueued in a message reception waiting queue In that case if the attribute of the specified mailbox is TA_TFIFO the task is enqueued in order of FIFO if TA_TPRI the task is enqueued in order of priority For prev_mbx and iprcv_mbx the task returns immediately and re sponds to the call with the error code E_TMOUT For the trev_mbx service call specify a wait time for tmout in ms units The values specified for tmout must be within Ox 7fffffff time tick 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 O as a timeout value in which
73. returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target alarm handler Al Pointer to the packet to which alarm handler status is returned Error code None Functional description This service call returns various statuses of the alarm handler indicated by almid almstat The status of the target alarm handler is returned TALM STA Alarm handler is an operational state TALM SIb Alarm handler is a non operational state 4 lefttim The remaining time before the target alarm handler will start next is returned This time is expressed in ms units If the target alarm handler is a non operational state the returned value is indeterminate If this service call is to be issued from task context use ref alm if issued from non task context use iref alm R20UT0655EJ0100 Rev 1 00 Page 165 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RAIM ralm ER ercd ercd ref_alm ID_ALM1 amp ralm lt lt Example statement in assembly language gt gt include mr30 inc GLB task _ refalm blkb 6 task PUSHM A0 A1 ref alm ID_ALM1 _refalm R20UT0655bEJ0100 Rev 1 00 Page 166 of 295 Jun 01
74. sem or twai sem service call is released from the WAIT ING state in the following cases When the sig sem or isig sem service call is issued before the tmout time elapses with task awaking conditions thereby satisfied The error code returned in this case is E OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI If this service call is to be issued from task context use wai sem twai sem or pol sem if issued from non task context use ipol sem R20UT0655EJ0100 Rev 1 00 Page 103 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt 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 lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO pol_sem ID SEMI PUSHM AO wai_sem ID_SEM2 PUSHM AO R1 R3 MOV W 300 R1 MOV W O0 R3
75. sent to the task at the top of the reception waiting queue with which the task is released from the reception wait state On the other hand if snd_dtq or tsnd_dtq is issued for a data queue that is full of data the task that issued the service call goes from RUNNING state to a data transmission wait state and is enqueued in transmission waiting queue kept waiting for the data queue to become available In that case if the attribute of the specified data queue is TA_TFIFO the task is enqueued in order of FIFO if TA_TPRI the task is enqueued in order of priority For psnd_dtq and ipsnd_dtq the task returns immediately and responds to the call with the error code E TMOUT For the tsnd_dtq service call specify a wait time for tmout in ms units The values specified for tmout must be within Ox 7fffffff time tick 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 O as a timeout value in which case the service call operates the same way as psnd dtq Furthermore if specified as tmoutZTMO FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as snd dtq If there are no tasks waiting for reception nor is the data queue area filled the transmitted data is stored in the data queue The task placed into WAITING state by execution of the snd dtq or tsnd dro service call is released from WAITING state in th
76. service call is issued RO Terminated normally E OK or error code AO ID number of the target task Error code E_OBJ Object status invalid task indicated by tskid is an inactive state E_QOVR Queuing overflow Functional description If the task specified by tskid has been placed into WAITING state by slp_tsk or tslp_tsk this service call wakes up the task from WAITING 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 goes to SUS PENDED state If a wakeup request is issued while the target task remains in DORMANT state the error code E OBJ is returned to the service call issuing task If TSK_SELF is specified for tskid it means specifying the issuing task itself If TSK_SELF is specified for tskid in non task context operation of the service call cannot be guaranteed If this service call is issued to a task that has not been placed in WAITING state or in WAITING SUSPENDED state by execution of slp_tsk or tslp_tsk the wakeup request is accumulated More specifically the wakeup request count for the target task to be awakened is incremented by 1 in which way wakeup requests are accumulated The maximum value of the wakeup request count is 15 If while the wakeup request count 15 a new wakeup request is generated exceeding this limit the error code E QOVR is returned to the task that iss
77. state WAITING WAITING state SUSPENDED WAITING state state Number of suspension 0 1 1 0 request Figure 4 7 Forcible wait of a task and resume R20UT0655EJ0100 Rev 1 00 Jun 01 2011 Page 41 of 295 32 NE SAS M3T MR30 4 4 Kernel e Forcibly resume suspended task frsm_tsk ifrsm tsk Clears the number of suspension requests nested to 0 and forcibly resumes execution of a task Since MR30 al lows only one suspension request to be nested this service call behaves the same way as rsm_tsk and irsm_tsk See Figure 4 8 sus tsk frsm_tsk Task h5y READY state SUSPENDED READY state state WAITING WAITING WAITING state SUSPENDED state state Number of suspension 0 1 0 requests Figure 4 8 Forcible wait of 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 following wait states Timeout wait state Wait state entered by slp_tsk service call timeout included Event flag timeout included wait state Semaphore timeout included wait state Message timeout included wait state Data transmission timeout included wait state Data reception timeout included wait state Fixed size memory block timeout included acquisition wait state Short data transmission timeout included wait state Short data reception timeou
78. the C language When selecting a register here be sure to select all regis ters that store service call parameters used in each task MR30 kernel does not change the registers of bank If this definition is omitted it is assumed that all registers are selected 6 Section name in which the stack is located Definition format Symbol Definition range None Default value stack Define the section name in which the stack is located The section defined here must always have an area allo cated for it in the section file asm sec inc or c sec inc If no section names are defined the stack is located in the stack section R20UT0655EJ0100 Rev 1 00 Page 237 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 7 TA_ACT attribute initial startup state Definition format Symbol Definition range ON or OFF Default value OFF Define the initial startup state of a task If this attribute is specified ON the task goes to a READY state at the initial system startup time The task startup code of the initial startup task is 0 One or more tasks must have TA_ACT attribute 8 Extended information Definition format Numeric value Definition range 0 to OxFFFF Default value 0 Define the extended information of a task This information is passed to the task as argument when it is re started by a queued startup request for example Eventflag definition This defi
79. the RUNNING state requests to be placed in the WAITING state it exits the RUNNING state and enters the WAITING state The WAITING state is usually used as the condition in which the completion of I O device I O operation or the processing of some other task is awaited The task goes into the WAITING state in one of the following ways The task enters the WAITING state simply when the slp tsk service call is issued In this case the task does not go into the READY state until its WAITING state is cleared explicitly by some other task The task enters and remains in the WAITING state for a specified time period when the dly tsk service call is issued In this case the task goes into the READY state when the specified time has elapsed or its WAITING state is cleared explicitly by some other task The task is placed into WAITING state for a wait request by the wai flg wai sem rcv mbx snd dro rcv dtq vsnd dtq vrcv do or get mpf service call In this case the task goes from WAITING state to READY state when the request is met or WAITING state is explicitly canceled by another task The tslp tsk twai flg twai sem trcv mbx end dtq trev_dtq vtsnd do vtrcv dtq and tget mpf service calls are the timeout specified versions of the slp tsk wai flg wai sem rcv mbx snd dtq rcv dtq vsnd dtq vrcv dtq and get mpf service calls The task is placed into WAITING state for a wait request by one of these service calls In this case the task g
80. the condition in which a READY task or currently executed task is excluded from scheduling to halt processing due to I O or other error occurrence That is when the suspend request is made to a READY task that task is excluded from the execution queue Note that no queue is formed for the suspend request Therefore the suspend request can only be made to the tasks in the RUNNING READY or WAITING state If the suspend request is made to a task in the SUS PENDED state an error code is returned WAITING SUSPENDED If a suspend request is issued to a task currently in a WAITING state the task goes to a WAIT ING SUSPENDED state If a suspend request is issued to a task that has been placed into a WAITING state for a wait request by the slp tsk dly_tsk wai flg wai sem rcv_mbx and dtq rcv_dtq vsnd_dtq vrcv dtq get mpf tslp tsk twai flg twai sem trcv mbx tsnd dtq trcv dtq vtsnd dtq vtrcv dtq or tget mpf service call the task goes to a WAITING SUSPENDED state When the wait condition for a task in the WAITING SUSPENDED state is cleared that task goes into the SUS PENDED state It is conceivable that the wait condition may be cleared when any of the following conditions occurs The task wakes up upon wup tsk or iwup_tsk service call issuance The task placed in the WAITING state by the dly tsk or tslp tsk service call wakes up after the specified time elapse The request of the task placed in the WAITING state by
81. the wai flg wai sem rcv mbx snd dtq rcv dtq vsnd dtq vrcv dtq get mpf tslp tsk twai flg twai sem trcv mbx tsnd dtq trcv dtq vtsnd dtq vtrcv dro or tget mpf service call is fulfilled The WAITING state is forcibly cleared by the rel wai or irel wai service call When the SUSPENDED state clear request by rsm tsk or irsm tsk is made to a task in the WAIT ING SUSPENDED state that task goes into the WAITING state Since a task in the SUSPENDED state cannot request to be placed in the WAITING state status change from SUSPENDED to WAITING SUSPENDED does not possibly occur DORMANT This state refers to the condition in which a task is registered in the MR30 system but not activated This task state prevails when either of the following two conditions occurs The task is waiting to be activated The task is normally terminated by ext tsk service call or forcibly terminated by ter tsk ser vice call If the task under execution is placed into a forcible wait state by the isus tsk service call from the handler the task goes from an exe cuting state directly to a forcible wait state Please note that in only this case exceptionally it is possible that a task will go from an exe cuting state directly to a forcible wait state 12 If a forcible wait request is issued to a task currently in a wait state the task goes to a WAITING SUSPENDED state R20UT0655EJ0100 Rev 1 00 Page 22 of 295 Jun 01 2011 RENESAS M3T MR
82. tid Referencetask ID in the RUNNING state 170 iget tid Referencetask ID in the RUNNING state handler only 170 Oe pur OGG tHe CRU rtp DE 172 iloc cpu Lock the CPU handler only 172 Unb cour nlock the CPU ure then trt ee Dee e reni RO er irr ere ERR ne ra Rn Re YER 174 iunl cpu Unlock the CPU handler only 174 dis dsp Disable dispatching nennen enne enne enini ens 175 ena dsp Enables depatching ennemi entren enn enn enn ens 177 sns CN Referencecontext uec O ee Le deed 178 sns loc Reference CPU state eee eerte kr n tr dd 179 sns dsp Reference dispatching state AAA 180 sns dpn Reference dispatching pending estate 181 5 13 Interrupt Management FUNCION enne enne enn enin nnn nsn nnne trennen tnnt 183 ret int Returns from an interrupt handler when written in assembly language 184 5 14 System Configuration Management Funcon nennen nnne nnns 185 ref ver Reference version information ENEE 186 iref ver Reference version information handler oplvl 186 5 15 Extended Function Long Data Oueuel ener nennen nennen nennen 188 vsnd dro Send to Long data queue eene nennen nennen nnn tnnt nnne rennen nennen 189 vpsnd do Send to Long data oueietpoltingl enne 189 vipsnd dro Send to Long data queue polling handler only 189 vtsnd do Send to Long data queue with timeout sss nennen 189 vfsnd dro Forcibly send to Long data queue enne enne nnn 189 vifsnd dro Forcibly send to Long data queu
83. to the ITRON Specification The MR30 is designed in compliance with the uITRON Specification which incorporates a minimum of the ITRON Specification functions so that such functions can be incorporated into a one chip microcomputer As the uITRON Specification is a subset of the ITRON Specification most of the knowledge obtained from pub lished ITRON textbooks and ITRON seminars can be used as is Further the application programs developed using the real time operating systems conforming to the ITRON Specification can be transferred to the MR30 with comparative ease 2 High speed processing is achieved MR30 enables high speed processing by taking full advantage of the microcomputer architecture 3 Only necessary modules are automatically selected to constantly build up a system of the minimum size MR30 is supplied in the object library format of the M16C 10 M16C 20 M16C 30 M16C 60 M16C Tiny and R8C Tiny series Therefore the Linkage Editor LN30 functions are activated so that only necessary modules are automatically selected from numerous MR30 functional modules to generate a system Thanks to this feature a system of the minimum size is automatically generated at all times 4 With the C compiler NC30WA it is possible to develop application programs in C language Application programs of MR30 can be developed in C language by using the C compiler NC30WA Further more the interface library necessary to call the MR30 functions
84. with timeout C Language API ER ercd wai flg ID flgid FLGPTN waiptn MODE wfmode FLGPIN p flgptn ER ercd pol flg ID flgid FLGPTN waiptn MODE wfmode FLGPIN p flgptn ER ercd ipol flg ID flgid FLGPTN waiptn MODE wfmode FLGPIN p flgptn ER ercd twai flg ID flgid FLGPTN waiptn MODE wfmode FLGPIN p flgptn TMO tmout e Parameters ID flgid ID number of the eventflag waited for FLGPTN waiptn Wait bit pattern MODE wfmode Wait mode FLGPTN p flgptn Pointer to the area to which bit pattern is returned when released from wait TMO tmout Timeout value for twai flg e Return Parameters ER ercd Terminated normally E OK or error code FLGPTN p flgptn Pointer to the area to which bit pattern is returned when released from wait Assembly language API include mr30 inc wai_flg FLGID WAIPTN WFMODE pol fl1g FLGID WAIPTN WFMODE N N ipol flg FLGID WAIPTN WFMODE twai flg FLGID WAIP WEMODE e Parameters FLGID ID number of the eventflag waited for WAIPTN Wait bit pattern WFMODE Wait mode e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code RI Wait mode R2 bit pattern is returned when released from wait R3 Wait bit pattern AO ID number of the eventflag waited for Error code E RLWAI Forced releas
85. 0 Error zero divide error near line xxx xxxx cfg A zero divide operation occurred in some arithmetic expression cfg30 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 cfg30 Error RO must exist in task x context near line xxx xxxx cfg You must select RO register in task x context cfg30 Error can t define address match interrupt definition for Task Pause Functio n near line xxx xxxx cfg Another interrupt is defined in interrupt vector definition needed by Task Pause Function R20UT0655EJ0100 Rev 1 00 Page 260 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator cfg30 Error Set system timer system timeout YES near line xxx xxxx cfg Set clock timer symbol except NOTIMER cfg30 Error Initial Start Task not defined No initial startup task is defined in the configuration file R20UT0655EJ0100 Rev 1 00 Page 261 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Warning messages The following message are a warning A warning can be ignored providing that its content is understood cfg30 Warning system is not defined xxxx cfg cfg30 Warning system XXXX is not defined xxxx cfg System definition or system definition item XXXX is omitted in the configuration file cfg30 Warning system message_size is not defined xxxx cfg The message size definition is omitted in the system definition Please spec
86. 0 Page 248 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Interrupt vector definition This definition is necessary to use Interrupt function lt lt Format gt gt Interrupt Vector Definition interrupt_vector Vector No 14 os_int Kernel managed OS dependent interrupt handler entry_address Start address pragma switch Switch passed to PRAGMA extended function Ir The vector number can be written in the range of 0 to 63 and 247 to 255 However whether or not the defined vector number is valid depends on the microcomputer used The relationship between interrupt causes and interrupt vector numbers for the M16C 80 series is shown in Table 8 3 Interrupt Causes and Vector Numbers Configurator can t create an Initialize routine interrupt control register interrupt causes etc for this defined interrupt You need to create that lt lt Content gt gt 1 Kernel OS dependent interrupt handler Definition format Symbol Definition range YES or NO Define whether the handler is a kernel OS dependent interrupt handler If it is a kernel OS dependent inter rupt handler specify YES if it is a non kernel OS independent interrupt handler specify No If this item is defined as YES the declaration statement shown below is output to the kernel_id h file pragma INTHANDLER V4 function name If this item is defined as NO the declaration st
87. 0 rounds off the size to 244 bytes and acquires 244 byte mem ory If memory acquirement goes well the MR30 returns the first address of the memory acquired along with the error code E_OK If memory acquirement fails the MR30 returns the error code E_TMOUT R20UT0655EJ0100 Rev 1 00 Page 52 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel Rounding 224 bytes Figure 4 18 pget mpl processing e Release Acquire Variable size Memory Block rel mpl Releases a acquired memory block by pget_mpl service call TaskA M emorypool M emorypool rel mpl top of gt address Figure 4 19 rel_mpl processing e Reference Acquire Variable size Memory Pool Status ref mpl iref mpl Checks the total free area of the memory pool and the size of the maximum free area that can immediately be acquired R20UT0655EJ0100 Rev 1 00 Page 53 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 9 Time Management Function The time management function provides system time management time reading time setup and the functions of the alarm handler which actuates at preselected times and the cyclic handler which actuates at preselected time intervals The MR30 kernel requires one timer for use as the system clock There are following time management service calls that are provided by the MR30 kernel Note however that the system clock is not an essential function of MR30 Therefore if the service calls described
88. 07 Table 5 9 Specifications of the Data Queue Function sess 117 Table 5 10 List of Dataqueue Function Service Call 117 Table 5 11 Specifications of the Mailbox Function sese enne nnne 126 Table 5 12 List of Mailbox Function Service Call 126 Table 5 13 Specifications of the Fixed size memory pool EFuncion esses 134 Table 5 14 List of Fixed size memory pool Function Service Call 134 Table 5 15 Specifications of the Variable size memory Pool Funcionm 142 Table 5 16 List of Variable size memory pool Function Servicertall sess 142 Table 5 17 Specifications of the Time Management Funcion nara narn cnn 149 Table 5 18 List of Time Management Function Service Call esee 149 Table5 19 Specifications of the Cyclic Handler Function sse 155 Table 5 20 List of Cyclic Handler Function Service Call sess 155 Table 5 21 Specifications of the Alarm Handler Fundtion esee 161 Table 5 22 List of Alarm Handler Function Service Call sese 161 Table 5 23 List of System Status Management Function Service Call sese 167 Table 5 24 List of Interrupt Management Function Service Call 183 Table 5 25 List of System Configuration Management Function Service Call 185 Table 5 26 Specifications of the Long DataOueuetuncion cnn nn nnnnnnanns 188 Table 5 27 List of Long
89. 1 RENESAS M3T MR30 4 13 Separate ROMs system definition You need to make the following items which are dealt with in the system definition common to two applica tions timeout task pause priority e clock definition The value assigned to this item in one of two applications can be different from its counterpart Avoid defin ing this item in one application and omitting it in the other application Be sure to deal with this item in the same manner either define or omit in two applications O task definition e initial start Switch this item ON only in the task first started up after the System is stared up and switch this item OFF in any other tasks Other definitions though different from each other between two configuration files raise no problem 3 Changing the processor mode register You change the processor mode register for a startup program in compliance with the system 4 Preparing application programs You prepare two application programs 5 Changing of the section name of start up program Change the name of the section name of start up program start a30 crtOmr a30 from MR KERNEL section to other name before section MR KERNEL CODE ALIGN after section MR STARTUP CODE ALIGN 6 Locating respective sections Programs to be located in the kernel ROM and in the application ROM are given below e Programs to be located in the kernel ROM e MR30 s kernel MR K
90. 163 164 IF USE SYSTEM TIME 165 MOV W t D Sys TIME L Sys_time 4 166 MOV W __D_Sys_TIME_M Sys_time 2 167 MOV W __D_Sys_TIME_H Sys_time 168 ENDIF 169 170 ITI s User Initial Routine if there are Liz got 173 5 174 175 176 jmp MR INIT for Separate ROM 177 178 179 3 Initialization of System Data Area 180 181 GLB init sys init tsk END INIT 182 JSR W init sys 183 JSR W init tsk 184 185 IF MR TIMEOUT 186 GLB init tout 187 JSR W init tout 188 ENDIF 189 190 IF NUM FLG 191 GLB init flg 192 JSR W init Elo 193 ENDIF 194 195 IF NUM SEM 196 GLB init sem 197 JSR W init sem 198 ENDIF 199 200 IF NUM DTQ 201 GLB init dtq 202 JSR W init dtq 203 ENDIF 204 205 IF NUM VDTQ 206 GLB init vdtq 207 JSR W init vdtq 208 ENDIF 209 210 IF NUM MBX SEL GLB init mbx 212 JSR W init mbx 213 ENDIF 214 215 SLE ALARM HANDLER 216 GLB inite alh 217 JSR W init alh 218 ENDIF R20UT0655EJ0100 Rev 1 00 Page 222 of 295 Jun 01 2011 RENESAS M3T MR30 4 Se os se kB CYCLIC HANDLER GLB init cyh JSR W init cyh ENDIF IE NUM MPF Fixed Memory Pool GLB init mpf JSR W init mpf ENDIF IF NUM MPL Variable Memory Pool GLB init mpl JSR W init mpl ENDIF For PD30 LAST INITIAL END INIT Start initial active task ST
91. 30 4 3 Introduction to Kernel 3 4 2 Task Priority and Ready Queue In the kernel several tasks may simultaneously request to be executed In such a case it is necessary to determine which task the system should execute first To properly handle this kind of situation the system organizes the tasks into proper execution priority and starts execution with a task having the highest priority To complete task execution quickly tasks related to processing operations that need to be performed immediately should be given higher priorities The MR30 permits giving the same priority to several tasks To provide proper control over the READY task execution order the kernel generates a task execution queue called ready queue The ready queue structure is shown in Figure 3 17 The ready queue is provided and controlled for each priority level The first task in the ready queue having the highest priority is placed in the RUNNING state Priority 3 TCB TCB TCB 5 109 1 34 vs Figure 3 17 Ready Queue Execution Queue 13 The TCB task control block is described in the next chapter 14 The task in the RUNNING state remains in the ready queue R20UT0655EJ0100 Rev 1 00 Page 23 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 4 3 Task Priority and Waiting Queue In The standard profiles in uITRON 4 0 Specification support two waiting methods for each object In one meth
92. 30 inc set flg FLGID SETPTN iset flg FLGID SETPTN Parameters FLGID ID number of the eventflag to be set SETPTN Bit pattern to be set e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK R3 Bit pattern to be set AO Eventflag ID number Error code None Funcional description Of the 16 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 eventflag value results in task awaking condi tions for a task that has been kept waiting for the eventflag by the wai flg or twai flg service call becoming satisfied the task is released from WAITING state and placed into READY or RUNNING state Task awaking conditions are evaluated sequentially beginning with the top of the waiting queue If TA WMUL is speci fied as an eventflag attribute multiple tasks kept waiting for the eventflag can be released from WAITING state at the same time by one set flg or iset flg service call issued Furthermore if TA CLR is specified for the attribute of the target eventflag all bit patterns of the eventflag are cleared with which processing of the service call is terminated If all bits specified in setptn are 0 no operation will be performed for the target eventflag in which case no errors are assumed however If this servic
93. 424 NEC SAS E CD D me o lt Y 5 C v M3T MR30 4 V 4 01 User s Manual Real time OS for M16C Series and R8C Family All information contained in these materials including products and product specifications represents information on the product at the time of publication and is subject to change by Re nesas Electronics Corporation without notice Please review the latest information published by Renesas Electronics Corporation through various means including the Renesas Electronics Corporation website http www renesas com Renesas Electronics 8 10 11 12 Notice All information included in this document is current as of the date this document is issued Such information however is subject to change without any prior notice Before purchasing or using any Renesas Electronics products listed herein please confirm the latest product information with a Renesas Electronics sales office Also please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyr
94. AITING State e Reference Eventflag Status ref To iref_flg Checks the existence of the bit pattern and wait task for the target eventflag R20UT0655EJ0100 Rev 1 00 Page 46 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel Figure 4 13 shows an example of task execution control by the eventflag using the wai_flg and set_flg service calls The eventflag has a feature that it can wake up multiple tasks collectively at a time In Figure 4 13 there are six tasks linked one to another task A to task F When the flag pattern is set to OxF by the set_flg service call the tasks that meet the wait conditions are removed sequentially 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 flag has a TA_CLR attribute when the waiting of Task A is canceled the bit pattern of the event flag will be set to 0 and Task C and Task E will not be removed from queue Flag queue TaskA TaskB TaskC TaskD TaskE TaskF Flag pattern Wait pattern OxOF OxFF OxOF OxFF OxFF 0x10 Wait mode OR AND AND AND OR OR set flg TaskB TaskD TaskF Flag pattern OxOF Figure 4 13 Task Execution Control by the eventflag R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 RENESAS Page 47 of 295 M3T MR30 4 4 Kernel 4 3 5 Synchronization and Communication Function Data Queue The da
95. ART TASK glb rdyq search jmp W rdyqd search Define Dummy glb __SYS_DMY_INH 254 SYS DMY INH reit 257 IF CUSTOM SYS END 2583 299 260 Syscall exit routine to customize GLB Sys end 262 sys end 7 Detailed Applications 263 Customize here 264 REIT 265 ENDIF 266 267 268 exit function 269 7 270 LP _exit Sexit 271 _exit 272 Sexit 273 jmp exit 274 275 if USE TIMER 276 F 2 os System clock interrupt handler 278 279 SECTION MR_KERNEL CODE ALIGN 280 glb SYS STMR INH SYS TIMEOUT 281 glb DBG MODE SYS ISS 282 _ SYS STMR INH 283 process issue system call 284 For PD30 285 __ISSUE_SYSCALL 286 287 288 289 System timer interrupt handler 290 STMR hdr 291 ret int 292 endif 293 R20UT0655EJ0100 Rev 1 00 Page 223 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 294 end Figure 7 11 C Language Startup Program for M16C 63 64 65 crtOmr a30 The following explains the content of the C language startup program crtOmr a30 Incorporate a section definition file 11 in Figure 7 11 Incorporate an include file for MR30 12 in Figure 7 11 Incorporate a system ROM area definition file 13 in Figure 7 11 Incorporate a system RAM area definition file 14 in Figure 7 11 ST ZS O que uh This is the initialization p
96. E QOVR Queuing overflow R20UTO655EJ0100 Rev 1 00 Page 65 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call starts the task indicated by tskid The started task goes from DORMANT state to READY state or RUN NING state The following lists the processing performed on startup 1 Initializes the current priority of the task 2 Clears the number of queued wakeup requests 3 Clears the number of suspension requests Specifying tskid TSK_SELF 0 specifies the issuing task itself The task has passed to it as parameter the extended in formation of it that was specified when the task was created If TSK_SELF is specified for tskid in non task context op eration of this service 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 maximum value of the task activation request is 15 If this limit is ex ceeded the error code E_QOVR is returned If TSK_SELF is specified for tskid the issuing task itself is made the target task If this service call is to be issued from task context use act_tsk if issued from non task context use iact_tsk Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel id h void task1 VP INT stacd
97. ERNEL section Programs common to two applications program section This example assumes that the task identified by 1 is a program common to two applications Locating a com mon program in the application ROM raises no problem With a common program located in the kernel ROM the system calls given below cannot be issued so be careful get mpf get pri get tid iprcv dtq pget mpf pget mpl pol flg prev_dtq prcv mbx rcv dtq rcv mbx tget mpf trcv dtq trev_mbx tsnd dtq twai flg viprcv dtq vprev_dtq vrev_dtq vtrcv_dtq vtsnd_dtq wai flg To issue these system calls from a common program locate it in the application ROM R20UT0655EJ0100 Rev 1 00 Page 281 of 295 Jun 01 2011 RENESAS M3T MR30 4 13 Separate ROMs kernel ROM Internal ROM MR_KERNEL Startup Program MR30 kernel program Task of D 1 Application ROM1 Application ROM 2 MR ROM MR30 s ROM MR30 s ROM E data MR ROM data PS C language I F routine MR CIF Clanguagel F routine application change App prog Task2 app prog Task2 gt Task3 Task3 Task4 Task4 l Task Use F unction ask5 Mailbox i Use Function Eventflag Interrupt vector area Mailbox Interrupt vector area semaphore Eventflag E Number of Task4 Fix Interrupt Fix Interrupt Vector area Number ot Taska Vector area Figure 13 1 ROM separate Programs to be located in the ap
98. I include mr30 inc loc cpu iloc cpu e Parameters None Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK Error code None Functional description This service call places the system into a CPU locked state thereby disabling interrupts and task dispatches The features of a CPU locked state are outlined below 1 No task scheduling is performed during a CPU locked state 2 No external interrupts are accepted unless their priority levels are higher than 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 call cannot be guaranteed ext tsk loc cpu iloc cpu unl cpu iunl cpu sns ctx sns loc sns_dsp sns_dpn The system is freed from a CPU locked state by one of the following operations a Invocation of the unl_cpu or iunl_cpu service call b Invocation of the ext_tsk service call Transitions between CPU locked and CPU unlocked states occur only when the loc_cpu iloc_cpu unl_cpu iunl_cpu or ext_tsk service call is invoked The system must always be in a CPU unlocked state when the interrupt handler or the time event handler is terminated If either handler terminates while the system is in a CPU locked state handler operation cannot be guaranteed Note that the syste
99. ID Name Definition format Symbol Definition range None Default value None Define the name with which a semaphore is specified in a program 2 Selecting a semaphore waiting queue Definition format Symbol Definition range TA TFIFO or TA TPRI Default value TA TFIFO Select a method in which tasks wait for the semaphore If TA TFIFO is selected tasks are enqueued in order of FIFO If TA TPRI is selected tasks are enqueued in order of priority beginning with the one that has the highest priority 3 Initial value of semaphore counter Definition format Numeric value Definition range 0 to 65535 Default value 1 Define the initial value of the semaphore counter 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 definition must always be set when the data queue function is to be used lt lt Format gt gt Dataqueue Definition dataqueue ID No name ID name buffer_size Number of data queues wait_queue Select data queue waiting queue Ir The ID number must be in the range to 255 The ID number can be omitted If omitted ID numbers are automatically R20UT0655EJ0100 Rev 1 00 Page 240 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurato
100. ID number to which returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO Semaphore ID number to which returned Error code E_QOVR Queuing overflow Functional description This service call releases one resource to the semaphore indicated by semid If tasks are enqueued in a waiting queue for the target semaphore the task at the top of the queue is placed into READY state Conversely if no tasks are enqueued in that waiting queue the semaphore resource count is incremented by 1 If an attempt is made to return resources sig_sem or isig_sem service call causing the semaphore resource count value to exceed the maximum value specified in a configuration file maxsem the error code E QOVR is returned to the service call issuing task with the semaphore count value left intact If this service call is to be issued from task context use sig_sem if issued from non task context use isig_sem R20UT0655EJ0100 Rev 1 00 Page 100 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task if sig_sem ID_sem E_QOVR error Overflow n lt lt Example statement in assembly language gt gt include mr30 inc GLB task
101. M3T MR30 4 vrst_mbx Clear mailbox area C Language API ER ercd vrst_mbx ID mbxid Parameters ID mbxid Mailbox ID to be cleared Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc vrst mbx MBXID e Parameters MBXID Mailbox ID to be cleared Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO Mailbox ID to be cleared Error code None Functional description This service call clears the messages stored in the mailbox indicated by mbxid 5 Service call reference This service call can be issued only from task context It cannot be issued from non task context R20UT0655EJ0100 Rev 1 00 Jun 01 2011 RENESAS Page 202 of 295 M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void taskl void vrst mbx ID_mbx1 lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO vrst mbx ID_MBX1 R20UT0655EJ0100 Rev 1 00 Page 203 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference vrst_mpf Clear fixed size memory pool area C Language API ER ercd vrst_mpf ID mpfid Parameters ID mpfid Fixed size memory pool ID to be cle
102. Memory Pool Specifications of the fixed size memory pool function of MR30 are listed in Table 5 13 The memory pool area to be acquired can be specified by a section name for each memory pool during configuration Table 5 13 Specifications of the Fixed size memory pool Function No Item Content 1 Fixed size memory pool ID 1 255 2 Number of fixed size memory block 1 65535 3 Size of fixed size memory block 2 65535 4 Supported attributes TA_TFIFO Waiting tasks enqueued in order of FIFO TA_TPRI Waiting tasks enqueued in order of priority 5 Specification of memory pool area Area to be acquired specifiable by a section Table 5 14 List of Fixed size memory pool Function Service Call No Service Call Function System State D get_mpf S Aquires fixed size memory block pget mpf S Aquires fixed size memory block ipget mpf polling tget mpf S Aquires fixed size memory block with timeout rel mpf S Releases fixed size memory irel mpf block ref mpf References fixed size memory iref mpf pool status O OOo BLO Re O IO OF IO ojojojo OjO O O t ojojojo QOjoO o o c oo 1 ON tA Oo O oo Notes e S Standard profile service calls Each sign within System State is a following meaning T Can be called from task context N Can be called from non task context E Can be called from dispatch en
103. NESAS Page 279 of 295 13 Separate ROMs 13 1 How to Form Separate ROMs This chapter describes how to form the MR30 s kernel and application programs into separate ROMs Figure 13 1 shows an instance in which the sections common to two different applications together with the kernel are allocated in the kernel ROM and the applications are allocated in separate ROMs Here is how to divide a ROM based on this example 1 System configuration Here you set up a system configuration of application programs Here descriptions are given on the supposition that the system configuration of two application programs is as shown below 2 Preparing configuration files Application 1 Application 2 The number of Tasks 4 5 The number of Eventflags 1 3 The number of Semaphores 4 2 The number of Mailboxes 3 5 The number of Fixed size memory pools 3 1 The number of Cyclic handlers 3 3 Prepare configuration files based on the result brought by setting up the system configuration e maxdefine definition You must specify the greater of the two numbers of definitions as to the respective applications for a value to be set in the maxdefine definition division Thus the individual items must be equal in number to each other in these applications e g maxdefine max task 5 max_flag 3 max_sem 4 max_mbx 5 max mpl 3 max_cyh 3 R20UT0655EJ0100 Rev 1 00 Page 280 of 295 Jun 01 201
104. R Bit pattern cleared when waiting task is released Table 5 8 List of Eventflag Function Service Call No Service Call Function System State T N E D U L 1 set_flg S Sets eventflag O O O O 2 iset_flg S O O O O 3 clr_flg S Clears eventflag O O O O 4 iclr_flg O O O O 5 wai_flg S Waits for eventflag O O O 6 pol flg S Waits foreventflag polling O O O O 7 ipol_flg S O O O O 8 twai_flg S Waits for eventflag with O O O timeout 9 ref_flg References eventflag status O O O O 10 iref_flg O O O O Notes e S Standard profile service calls e Each sign within System State is a following meaning T Can be called from task context 9999 N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Jun 01 2011 ztENESAS Page 107 of 295 M3T MR30 4 5 Service call reference set_flg Set eventflag iset_flg Set eventflag handler only C Language API ER ercd set flg ID flgid FLGPITN setptn ER ercd iset flg ID flgid FLGPIN setptn e Parameters ID flgid ID number of the eventflag to be set FLGPTN setptn Bit pattern to be set e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr
105. R20UT0655EJ0100 Rev 1 00 Page 85 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call places the issuing task itself from RUNNING state into sleeping wait state The task placed into WAIT ING state by execution of this service call is released from the wait state in the following cases When a task wakeup service call is issued from another task or an interrupt The error code returned in this case is E_OK 4 When a forcible awaking service call is issued from another task or an interrupt The error code returned in this case is E RLWAI When the first time tick occurred after tmout elapsed for tslp tsk The error code returned in this case is E TMOUT If the task receives sus tsk issued from another task while it has been placed into WAITING state by this service call 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 until rsm tsk is issued The service call tslp tsk may be used to place the issuing task into sleeping state for a given length of time by specifying tmout in a parameter to it The parameter tmout is expressed in ms units For example if this service call is written as tslp tsk 10 then the issuing task is placed from RUNNING state into WAITING state for a period of 10 ms If specified as tmout TMO_FEVR 1
106. R20UT0655bEJ0100 Rev 1 00 Page 153 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference isig_tim Supply a time tick Functional description This service call updates the system time The isig_tim is automatically started every tick_time interval ms if the system clock is defined by the configuration file The application cannot call this function because it is not implementing as service call When a time tick is supplied the kernel is processed as follows Updates the system time Starts an alarm handler Starts a cyclic handler Processes the timeout processing of the task put on WAITING state by service call with timeout such as tslp_tsk Ha wa 1 2 3 4 R20UT0655EJ0100 Rev 1 00 Page 154 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 10 Time Management Function Cyclic Handler Specifications of the cyclic handler function of MR30 are listed in Table 5 19 The cyclic handler description languages in item No 4 are those specified in the GUI configurator They are not output to a configuration file nor are the MR30 kernel concerned with them Table 5 19 Specifications of the Cyclic Handler Function No Item Content 1 Cyclic handler ID 1 255 2 Activation cycle 0 Ox7FFFEFFF time tick ms 3 Activation phase 0 0x 7FFFFFFF time tick ms 4 Extended information 16 bits 5 Cyclic handler attribute TA HLNG Handlers written in high level language
107. Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics Preface The M3T MR30 4 abbreviated as MR30 is a real time operating system for the M16C 10 M16C 20 M16C 30 M16C 60 M16C Tiny and R8C Tiny series microcomputers The MR30 conforms to the uITRON Specification This manual describes the procedures and precautions to observe when you use the MR30 for programming purposes For the detailed information on individual service call procedures refer to the MR30 Reference Manual Requirements for MR30 Use When creating programs based on the MR30 it is necessary to purchase the following product of Renesas C compiler package M3T NC30WA abbreviated as NC30 for the M16C 10 M16C 20 M16C 30 M16C 60 M16C Tiny and R8C Tiny series microcomputers Document List The following sets of documents are supplied with the MR30 e Release Note Presents a software overview and describes the corrections to the Users Manual and Reference Manual e Users Manual PDF file Describes the procedures and precautions to observe when using the MR30 for programming purposes Right of Software Use The right of software use conforms to the software license agreement You can use the MR30 for your product develop ment purposes only and are not all
108. SAS M3T MR30 4 5 Service call reference stp_cyc Stops cyclic handler operation istp_cyc Stops cyclic handler operation handler only C Language API ER ercd stp_cyc ID cycid ER ercd istp cyc ID cycid e Parameters ID cycid ID number of the cyclic handler to be stopped e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc stp_cyc CYCNO istp_cyc CYCNO e Parameters CYCNO ID number of the cyclic handler to be stopped Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the cyclic handler to be stopped Error code None Funcional description This service call places the cyclic handler indicated by cycid into a non operational state If this service call is to be issued from task context use stp cyc if issued from non task context use istp cyc Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task stp_cyc ID_cycl lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO stp cyc ID_CYC1 R20UT0655EJ0100 Rev 1 00 Page 158 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref cyc Reference cyclic handler status iref cyc Reference cyclic handler status
109. USPENDED state If the target task is not in WAITING state the error code E OBJ is returned This service call forbids specifying the issu ing task itself for tskid If this service call is to be issued from task context use rel wai if issued from non task context use irel wai This means that tasks cannot be resumed from SUSPENDED state by this service call Only the rsm tsk irsm tsk frsm tsk and ifrsm tsk service calls can release them from SUSPENDED state R20UT0655EJ0100 Rev 1 00 Page 91 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task if rel_wai ID_main E_OK error Can t rel wai main n lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO rel_wai ID_TASK2 R20UT0655bEJ0100 Rev 1 00 Page 92 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sus_tsk Suspend task isus_tsk Suspend task handler only C Language API ER ercd sus_tsk ID tskid ER ercd isus_tsk ID tskid e Parameters ID tskid ID number of the target task e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc sus tsk TSKID isus tsk TSKID e Parameters TSKID ID
110. XXXX file and whether it actually exists cfg30 Error can t open version file The MR30 version file version cannot be found in the directory indicated by the environment variable LIB30 cfg30 Error can t open default configuration file The default configuration file cannot be accessed default cfg is needed in the current directory or directory LIB30 specifying cfg30 Error can t open configuration file lt xxxx cfg gt The configuration file cannot be accessed Check that the file name has been properly designated cfg30 Error illegal XXXX gt xx near line xxx xxxx cfg The value or ID number in definition item XXXX is incorrect Check the valid range of definition cfg30 Error Unknown XXXX gt xx near line xx xxxx cfg The symbol definition in definition item XXXX is incorrect Check the valid range of definition cfg30 Error too big XXXX s ID number gt xx xxxx cfg A value is set to the ID number in XXXX definition that exceeds the total number of objects defined The ID number must be smaller than the total number of objects cfg30 Error too big task x s priority gt xx near line xxx xxxx cfg The initial priority in task definition of ID number x exceeds the priority in system definition R20UT0655EJ0100 Rev 1 00 Page 259 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator cfg30 Error too big IPL gt lt xx gt near line xxx xxxx cfg The system clock interru
111. _dtq References data queue sta O O O O 12 iref_dtq tus O O O O Notes e S Standard profile service calls e Each sign 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Page 117 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 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 data queue with timeout fsnd_dtq Forcibly send to data queue ifsnd dtq Forcibly send to data queue handler only C Language API ER ercd snd dtq ID dtqid VP INT data ER ercd psnd dtq ID dtqid VP INT data ER ercd ipsnd dtq ID dtqid VP INT data ER ercd tsnd dtq ID dtqid VP INT data TMO tmout ER ercd fsnd dtq ID dtqid VP INT data ER ercd ifsnd dtq ID dtqid VP INT data e Parameters ID dtqid ID number of the data queue to which transmitted TMO tmout Timeout value tsnd dtq VP INT data Data to be transmitted e Return Parameters ER ercd Terminated normally E_OK or error code Assembly language API include mr30 inc snd dtq DTQID DTQDATA isnd dtq DTQID DTQDATA psnd dtq DTQID DTODATA ipsnd dtq DTQID DTQDATA t
112. a is transmitted to the long data queue Receive from Long Data Queue vprcv dtq viprcv do The data is received from the long data queue If the long data queue has no data in it the task returns error code without going to a data reception wait state Reference Long Data Queue Status vref dtq viref dtq Checks to see if there are any tasks waiting for data to be entered in the target long data queue and refers to the number of the data in the long data queue R20UT0655EJ0100 Rev 1 00 Page 61 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 16 Extended Function Reset Function The reset function is a function outside the scope of uITRON 4 0 Specification It initializes the mailbox data queue and memory pool etc Clear Data Queue Area vrst_dtq Initializes the data queue If there are any tasks waiting for transmission they are freed from WAITING state and the error code EV_RST is returned Clear Mailbox Area vrst_mbx Initializes the mailbox Clear Fixed size Memory Pool Area vrst_mpf Initializes the fixed size memory pool If there are any tasks in WAITING state they are freed from the WAIT ING state and the error code EV_RST is returned Clear Variable size Memory Pool Area vrst mpl Initializes the variable length memory pool Clear Short Data Queue Area vrst vdtq Initializes the short data queue If there are any tasks waiting for transmission they are freed from WAITING state and the error co
113. abled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state 9999 R20UT0655EJ0100 Rev 1 00 Page 134 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference get_mpf Aquire fixed size memory block pget_mpf Aquire fixed size memory block polling ipget_mpf Aquire fixed size memory block polling handler only tget_mpf Aquire fixed size memory block with timeout C Language API ER ercd get mpf ID mpfid VP p_blk ER ercd pget mpf ID mpfid VP p blk ER ercd ipget mpf ID mpfid VP p blk ER ercd tget mpf ID mpfid VP p blk TMO tmout e Parameters 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 Return Parameters ER ercd Terminated normally E OK or error code VP p blk Pointer to the start address of the acquired memory block Assembly language API include mr30 inc get mpf MPFID pget mpf MPFID ipget mpf MPFID tget mpf MPFID Parameters MPFID ID number of the target fixed size memory pool to be acquired e Register contents after service call is issued get mpf pget mpf ipget mpf Register name Content after service call is issued RO Terminated normally E OK or error code RI Start address of the acquired memory block AO ID number of the target fixed size memory pool to b
114. acquisition request TaskD No blank memory blocks available i Fixed Length M emorypool Goes toa wait state Figure 4 17 Memory Pool Management Acquire Fixed size Memory Block get_mpf tget_mpf Acquires a memory block from the fixed size memory pool that has the specified ID If there are no blank memory blocks in the specified fixed size memory pool the task that issued this service call goes to WAITING state and is enqueued in a waiting queue Acquire Fixed size Memory Block polling pget_mpf ipget mpf Acquires a memory block from the fixed size memory pool that has the specified ID The difference from the get mpf and tget mpf service 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 e Release Fixed size Memory Block rel mpf irel mpf Frees the acquired memory block If there are any tasks in a wait state for the specified fixed size memory pool the task enqueued at the top of the waiting queue is assigned the freed memory block In this case the task changes its state from WAITING state to READY state If there are no tasks in a wait state the memory block is returned to the memory pool e Reference Fixed size Memory Pool Status ref mpf iref mpf Checks the number and the size of blank blocks available in the target memory pool R20UT0655EJ0100 Rev 1 00 Page 51 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 8 Variable size M
115. ader cannot be rewritten from the application The structure of the message queue is shown in Figure 4 16 The message header has its data types 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 reserved on the application side In no event will tasks be kept waiting for transmission Messages can be assigned priority so that messages will be received in order of priority beginning with the highest In this case TA_MPRI should be added to the mailbox attribute If messages need to be received in order of FIFO add TA MFIFO to the mailbox attribute Furthermore if tasks in a message wait state are to receive a message the tasks can be prioritized in which order they can receive a message beginning with one that has the highest priority In this case add TA_TPRI to the mailbox attribute If tasks are to receive a message in order of FIFO add TA_TFIFO to the mailbox attribute 7 Message Message TaskA TaskB Figure 4 15 Mailbox 2 It is in the mailbox definition message_queue of the configuration file that the TA_MPRI or TA_MFIFO attribute should be added 2 It is in the mailbox definition wait queue of the configuration file that the TA TPRI or TA TFIFO attribute should be added R20UT0655EJ0100 Rev 1 00 Page 49 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel
116. age API ER ercd ref mpl ID mplid T RMPL pk rmpl ER ercd iref mpl ID mplid T RMPL pk rmpl Parameters ID mplid ID number of the target variable size memory pool T RMPL pk rmpl Pointer to the packet to which variable size memory pool status is returned e Return Parameters ER ercd Terminated normally E OK T RMPL pk rmpl Pointer to the packet to which variable size memory pool status is returned Contents of pk rmpl typedef struct t rmpl ID wtskid 0 2 Task ID waiting for memory block to be acquired unused SIZE fmplsz 4 4 Free memory size in bytes UINT fblksz 8 2 Maximum size of memory that can be acquired immediately in bytes T_RMPL Assembly language API include mr30 inc ref_mpl MPLID PK_RMPL iref_mpl MPLID PK_RMPL e Parameters MPLID ID number of the target variable size memory pool PK RMPL Pointer to the packet to which variable size memory pool status is returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E_OK AO ID number of the target variable size memory pool Al Pointer to the packet to which variable size memory pool status is returned Error code None Funcional description This service call returns various statuses of the message buffer indicated by mplid wtskid Unused fmplsz A free memory size is returned fblksz The maximum size of memory that can be
117. age gt gt include lt itron h gt include kernel h include kernel_id h void task VP p_blf if get mpf ID mpfl amp p blf E OK error Not enough memory An rel_mpf 1D_mpf1 p_b1f lt lt Example statement in assembly language gt gt include mr30 inc GLB task _g_blk blkb 4 task PUSHM AO get_mpf ID_MPF1 MOV W R1 g blk PUSHM AO rel_mpf ID_MPF1 _g_blk R20UT0655bEJ0100 Rev 1 00 Page 139 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref mpf Reference fixed size memory pool status iref mpf Reference fixed size memory pool status handler only C Language API ER ercd ref mpf ID mpfid T RMPF pk rmpf ER ercd iref mpf ID mpfid T RMPF pk rmpf e Parameters ID mpfid Task ID waiting for memory block to be acquired T RMPF pk rmpf Pointer to the packet to which fixed size memory pool status is returned e Return Parameters ER ercd Terminated normally E OK T RMPF pk rmpf Pointer to the packet to which fixed size memory pool status is returned Contents of pk rmpf typedef struct t rmpf ID wtskid 0 2 Task ID waiting for memory block to be acquired UINT fblkent 2 2 Number of free memory blocks T_RMPF Assembly language API include mr30 inc ref_mpf MPF ID PK_RMPF iref_mpf MPFID PK_RMPF Parameters MPFID Task ID waiting for memory block to be acquired PK RMPF Pointer to the packet to which fixed size
118. ant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein Renesas Electronics products are classified according to the following three quality grades Standard High Quality and Specific The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application categorized as Specific without the prior written consent of Renesas Electronics Further you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as Specific 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 Electronics product is Standard unless otherwise expressly specified in a Renesas Electronics data sheets or data books etc Standard Computers office equipment communications equipment test and measurement
119. ared Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc vrst mpf MPFID e Parameters MPFID Fixed size memory pool ID to be cleared e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO Fixed size memory pool ID to be cleared Error code None Functional description This service call initializes the fixed size memory pool indicated by mpfid If tasks are enqueued in a memory block waiting queue all of the tasks enqueued in the memory block waiting queue are released from WAITING state Further more the error code EV RST is returned to the tasks that have been released from WAITING state This service call can be issued only from task context It cannot be issued from non task context Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task1 void vrst_mpf ID_mpfl lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO vrst mpf ID_MPF1 R20UT0655EJ0100 Rev 1 00 Page 204 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference vrst_mpl Clear variable size memory pool area C Language API ER ercd vrst_mpl ID mplid Parameters ID mplid Variable size memory pool ID to be cleared
120. ared e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the eventflag to be cleared R3 Bit pattern to be cleared Error code None Funcional description Of the 16 bit eventflag indicated by flgid this service call clears the bits whose corresponding values in clrptn are 0 In other words the eventflag bit pattern indicated by flgid is updated by AND ing it with clrptn If all bits specified in clrptn are 1 no operation will be performed for the target eventflag in which case no errors are assumed however If this service call is to be issued from task context use clr_flg if issued from non task context use iclr flg R20UT0655EJ0100 Rev 1 00 Page 110 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task void clr_flg ID_flg FLGPTN Oxf0f0 lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM A0 R3 clr_flg ID_FLG1 0f0f0H R20UT0655EJ0100 Rev 1 00 Page 111 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference wai flg Wait for eventflag pol fig Wait for eventflag polling ipol flg Wait for eventflag polling handler only twai flg Wait for eventflag
121. as 35 3 81 System Stack and User Stack eene nnne nnne nnne nnne 35 LEE O WEE 36 Al Mod leStrU cture auntie ti a anpra eae Flo rer ok AER 36 4 2 Module Overview eseessessseesseeesee er 37 ES MEN GM A A A E E E 38 4 3 1 Task Management Euncdion enne ennt ennt tnnt nnne tnn 38 4 3 2 Synchronization functions attached to task AAA 40 4 3 3 Synchronization and Communication Function Germmatphorel 44 4 3 48 Synchronization and Communication Function Eventflag ococonccccnncccnoncncnonnnonaranonanononnns 46 4 3 5 Synchronization and Communication Function Data Queue cooccconoccnoncccconnncnonnnonnnnncnnnononnns 48 4 3 6 Synchronization and Communication Function Mailbox 49 4 3 4 Memory pool Management F unction F ixed size Memory pol 51 4 3 8 Variable size Memory Pool Management Funclon 52 4 3 9 Time Management Eunctton enne rr 54 4 3 10 Cyclic Handler Function tentent cm ERR e eR o Dk RE e ERR o YR dore eden 56 4 3 11 AlarmHandler FUNCION AEN 57 4 3 12 System Status Management Funcd lon enne nennen tnnt nnne tnn nns 58 4 3 13 Interrupt Management FUNCION enne enne nnn nnne tnnt nnne tentes 59 4 3 14 System Configuration Management Function essen nennen 60 4 3 15 Extended Function Long Data Queue nnne nennen nnn nen nnns 61 4 3 16 Extended Function Reset Function seseseeeeeeennn nnne nennen nnn 62 Service call e e 63 5 1 Task Manageme
122. ask I RIST rtst ER ercd ercd ref tst ID main amp rtst Example statement in assembly language gt gt _refdata blkb 4 include mr30 inc GLB task task PUSHM A0 A1 ref_tst ID_TASK2 _refdata TTW_VSDTQ and TTW_VRDTQ are the causes of wait outside the scope of ITRON 4 0 Specification R20UT0655EJ0100 Rev 1 00 Page 83 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 2 Task Dependent Synchronization Function Specifications of the task dependent synchronization function are listed in below Table 5 3 Specifications of the Task Dependent Synchronization Function No Item Content 1 Maximum value of task wakeup request count 15 Maximum number of nested forcible task wait requests count 1 Table 5 4 List of Task Dependent Synchronization Service Call No Service Call Function System State T N E D U L 1 slp_tsk S Puts task to sleep O O O 2 tslp_tsk S Puts task to sleep O O O with timeout 3 wup tsk S Wakes up task O O O O 4 iwup_tsk S O O O O 5 can_wup Cancels wakeup request O O O O 6 ican_wup O O O O 7 rel_wai S Releases task from waiting O O O O 8 irel wai S O O O O 9 sus_tsk S Suspends task O O O O 10 1sus_tsk O O O O 11 rsm_tsk S Resumes suspended task O O O O 12 irsm_tsk O O O O 13 frsm_tsk S Forcibly
123. ask2 app prog section T Task3 Application ROM Task4 Interrupt vector area INTERRUPT VECTOR section FixInterrupt vedor area FIX_INTERRUPT_VECTOR section NV Figure 13 2 Memory map 7 Executing the configurator cfg30 8 Create an mrc file in which every system call is described Compiling the source program creates a file having the extension mrc in the work directory Create an mrc file making refer ence to this 9 Generating a system You execute the build command to generate a system 10 Carrying out steps 4 through 9 with respect to application 2 allows you to generate the system for application 2 The steps given above allows you to form the separate ROMs R20UT0655EJ0100 Rev 1 00 Page 284 of 295 Jun 01 2011 RENESAS 14 Appendix 14 1Common Constants and Packet Format of Structure Common formats TRUE 1 True FALSE 0 f False Formats related to task management TSK SELF 0 Specifies the issuing task itself TPRI RUN 0 Specifies priority of task being executed then typedef struct t rtsk STAT tskstat Task status PRI tskpri Current priority of task PRI tskbpri Base priority of task STAT tskwait Reason for which task is kept waiting ID wid Object ID for which task is kept waiting TMO tskatr Remaining time before task times out UINT actcnt Number of activation requests UINT wupcnt Number of wakeup req
124. at can be Issued from a Task independent 32 Figure 3 25 System Stack and User Stack sese enne enn enn enne nnns 35 Figure 4 1 MR30 RE vg ie DEE 36 Figure42 Task Reset ica Po EEN Ed 38 Figure 4 3 Alteration of task priority eene enne nnne enne nnns 39 Figure 4 4 Task rearrangement in a waiting queue nennen nennen 39 Figure 4 5 Wakeup Request Gtor age 40 Figure 4 6 Wakeup Request Cancellattonm esses eene 40 Figure 4 7 Forcible wait of a task and resume sess ennt enne nnns 41 Figure 4 8 Forcible wait of a task and forcdhereeume sese 42 Figure 4 9 dly tsk service call sse enne nennen nein enn tnnt 43 Figure 4 10 Exclusive Control by Semaphore sss rennen nennen nnns 44 Figure 4 11 Semaphore Counter ANNER 44 Figure 4 12 Task Execution Control by SGemapbore nennen 45 Figure 4 13 Task Execution Control by the eventflag sssssssseeeeeeeeeeen nennen 47 Figure 4 14 Data queue RM 48 FIgure 4 15 MallbOX nice niti denn Teens din aan ena Eee ie ae seats ede eel Aree 49 Figure A 1pMeesageoueie ENEE 50 Figure 4 17 Memory Pool Management 51 Figure 4 18 pget mpl Droeesslng ennt nennen enne en nnne nnns 53 Figure 4 19 rel mpl processing eessessessesiesseeeeneeene nennen nnn nnne nennen rennen entries tenes 53 Figure 4 20 Timeout Processing eseesssseseseeeesenee teen tne ne tnen tnnt nnnn nnne tn trenta enhn inns entren inn
125. atement shown below is output to the kernel_id h file pragma INTERRUPT V4 function name 2 Start address Definition format Symbol or function name Definition range None Default value __SYS_DMY_INH Define the entry address of the interrupt handler When written in the C language add at the end or at the beginning of the function name you have defined 3 Switch passed to PRAGMA extended function Definition format Symbol Definition range EorB Default value None Specify the switch to be passed to pragma INTHANDLER or pragma INTERRUPT If E is specified the E switch is assumed in which case multiple interrupts another interrupt within an interrupt are enabled If B is specified the B switch is assumed in which case register bank is specified R20UT0655EJ0100 Rev 1 00 Page 249 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Two or more switches can be specified at the same time For kernel OS dependent interrupt handlers how ever only the E switch can be specified For non kernel OS independent interrupt handlers the E E and B switches can be specified subject to a limitation that E and B cannot be specified at the same time Precautions 1 Regarding the method for specifying a register bank A kernel OS dependent interrupt handler that uses register bank 1 cannot be written in C language Such an interrupt handler can
126. attribute is TA_MFIFO or TA MPRI R20UT0655EJ0100 Rev 1 00 Page 127 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference The T MSG area is used by the kernel so that it cannot be rewritten after a message has been sent If this area is rewrit ten before the message is received after it was sent operation of the service call cannot be guaranteed If this service call is to be issued from task context use snd_mbx if issued from non task context use isnd mbx Example format of a message gt gt typedef struct user mag T MSG t msg T MSG structure B data 16 User message data USER MSG lt lt Example format of a message with priority included gt gt typedef struct user mag T MSG PRI t msg T MSG PRI structure B data 16 User message data j USER_MSG Example program statement lt lt Example statement in C language gt gt include itron h include lt kernel h gt include kernel id nh typedef struct pri message T MSG PRI msgheader char body 12 PRI MSG void task void PRI MSG msg msg msgheader msgpri 5 snd mbx ID msg T MSG amp msg lt lt Example statement in assembly language gt gt include mr30 inc GLB task _g_userMsg blkb 4 Header DLKB A Body task PUSHM A0 A1 snd_mbx ID_MBX1 _g_userMsg R20UT0655EJ0100 Rev 1 00 Page 128 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call re
127. by Semaphore R20UTO655EJ0100 Rev 1 00 Page 45 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 4 Synchronization and Communication Function Eventflag The eventflag is an internal facility of MR30 that is used to synchronize the execution of multiple tasks The eventflag uses a flag wait pattern and a 16 bit pattern to control task execution A task is kept waiting until the flag wait conditions set are met It is possible to determine whether multiple waiting tasks can be enqueued in one eventflag waiting queue by specifying the eventflag attribute TA WSGL or TA WMUL Furthermore it is possible to clear the eventflag bit pattern to 0 when the eventflag meets wait conditions by specifying TA CLR for the eventflag attribute There are following eventflag service calls that are provided by the MR30 kernel Set Eventflag set To iset To Sets the eventflag so that a task waiting the eventflag is released from the WAITING state e Clear Eventflag clr flg iclr_flg Clears the eventflag e Wait for Eventflag wai To twai_flg Waits until the eventflag is set to a certain pattern There are two modes as listed below in which the eventflag is waited for AND wait Waits until all specified bits are set e OR wait Waits until any one of the specified bits is set e Wait for Eventflag polling pol_flg ipol flg Examines whether the eventflag is in a certain pattern In this service call tasks are not placed in W
128. c handler This information is passed as argument to the cyclic handler when it starts R20UT0655EJ0100 Rev 1 00 Page 247 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Alarm handler definition This definition is necessary to use Alarm handler function lt lt Format gt gt Alarm Handlar Definition alarm hand ID No name ID name entry_address Start address exitf Extended information Ir The ID number must be in the range of 1 to 255 The ID number can be omitted If omitted numbers are automatically assigned sequentially beginning with the smallest lt lt Content gt gt Define the following for each alarm handler ID number 1 ID name Definition format Symbol Definition range None Default value None Define the name by which the alarm handler is specified in a program 2 Start address Definition format Symbol or Function Name Definition range None Define the start address of the alarm handler The function name defined here causes the following declaration statement to be output in the kernel id h file 3 Extended information Definition format Numeric value Definition range 0 to OXFFFF Default value 0 Define the extended information of the alarm handler This information is passed as argument to the alarm handler when it starts R20UT0655EJ0100 Rev 1 0
129. case the service call operates the same way as prcv_mbx Furthermore if specified as tnout TMO_FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as rcv_mbx The task placed into WAITING state by execution of the rev_mbx or trev_mbx service call is released from WAITING state in the following cases When the rcv_mbx trcv_mbx prcv_mbx or iprcv_mbx service call is issued before the tmout time elapses with task awaking conditions thereby satisfied The error code returned in this case is E_OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI If this service call is to be issued from task context use rcv mbx trcv mbx prcv mbx if issued from non task context use iprev_mbx R20UT0655EJ0100 Rev 1 00 Page 130 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h typedef struct fifo_message T_MSG head char body 12 FIFO MSG void task FIFO MSG msg if rcv mbx T MSG amp msg ID mbx E RLWAI error
130. ck pointer is changed from the task type to the real time OS system type 3 Processing is performed in compliance with the request made by the service call 4 The task to be executed next is selected 5 The stack pointer is changed to the task type 6 The register contents are recovered to resume task execution The flowchart in Figure 3 10 shows the process between service call generation and task switching Key input Task Register Save SP lt OS Service call issuance Processing Task Selection Task gt SP LED illumination Task Register Restore Figure 3 10 Service Call Processing Flowchart A different sequence is followed if the issued service call does not evoke task switching R20UT0655EJ0100 Rev 1 00 Page 13 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 2 2 Processing Procedures for Service Calls from Handlers When a service call is issued from a handler task switching does not occur unlike in the case of a service call from a task However task switching occurs when a return from a handler 7 is made The processing procedures for service calls from handlers are roughly classified into the following three types 1 Aservice call from a handler that caused an interrupt during task execution 2 Aservice call from a handler that caused an interrupt during service call processing 3 Aservice call from a handler that caused an inter
131. d RB are specified R20UT0655EJ0100 Rev 1 00 Page 233 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Definition respective maximum numbers of items This definition is to be given only in forming the separate ROMs Here define respective maximum numbers of items to be used in two or more applications lt lt Format gt gt Max Definition maxdefine max task the maximum number of tasks defined max flag the maximum number of eventflags defined max dtq the maximum number of data eues defined max mbx the maximum number of mailboxes defined max sem the maximum number of semaphores defined max mpf the maximum number of fixed size memory pools defined max mpl the maximum number of variable size Remory pools defined max cyh the maximum number of cyclic handlers defined max alh the maximum number of alarm handlers defined max vdtq the maximum number of short data queues defined lt lt Contents gt gt 1 The maximum number of tasks defined Definition format Numeric value Definition range 1 to 255 Default value None Define the maximum number of tasks defined 2 The maximum number of eventflags defined Definition format Numeric value Definition range 1 to 255 Default value None 3 The maximum number of data queu
132. de EV RST is returned R20UT0655EJ0100 Rev 1 00 Page 62 of 295 Jun 01 2011 RENESAS 5 Service call reference 5 1 Task Management Function Specifications of the task management function of MR30 are listed in Table 5 1 below The task description languages in item No 4 are those specified in the GUI configurator They are not output to a configuration file nor are the MR30 ker nel concerned with them The task stack permits a section name to be specified for each task individually Table 5 1 Specifications of the Task Management Function No Item Content Task ID 1 255 Task priority 1 255 3 Maximum number of activation request count 15 TA HLNG Tasks written in high level language 4 Task attribute TA ASM Tasks written in as sem bly language TA ACT Startup attribute 5 Task stack Section specifiable Table 5 2 List of Task Management Function Service Call No Service Call Function System State T N E D U L 1 act_tsk S Activates task O olojo 2 iact_tsk S OJO JO JO 3 can_act S Cancels task activation request O OjO O 4 ican act 0 0O O O 5 sta tsk Starts task and specifies start code O olojo 6 ista_tsk 0 0 O O 7 ext tsk S Exits current task O OJO JO O 8 ter_tsk S Forcibly terminates a task O OJOo O 9 chg pri S Changes task
133. de mr30 inc ret int e Parameters None Error code Not return to the interrupt handler that issued this service call Functional description This service call performs the processing necessary to return from an interrupt handler Depending on return processing it activates the scheduler to switch tasks from one to another If this service call is executed in an interrupt handler task switching does not occur and task switching is postponed until the interrupt handler terminates However if the ret int service call is issued 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 writing this service call in assembly language be aware that the service call cannot be issued from a subroutine that is invoked from an interrupt handler entry routine Always make sure this service call is executed in the entry routine or entry function of an interrupt handler For example a program like the one shown below may not operate normally include mr30 inc NG GLB intr intr jsr b func func ret int Therefore write the program as shown below include mr30 inc OK GLB intr Bligh onan jsr b func ret_int func EUs Make sure this service call is issued from only an interrupt handler If issued from a cyclic handler alarm handler or a task this service call may
134. de the scope of uITRON 4 0 Specification Table 5 28 List of Reset Function Service Call No Service Call Function System State N vrst_dtq Clear data queue area vrst_vdtq Clear Long data queue area vrst_mbx Clear mailbox area vrst_mpf Clear fixed size memory pool area 5 vrst_mpl Clear variable size memory pool area Aor O oj ojojo s O oj ojojo m O OJOJOJO O O oj ojoJoIc Notes e S Standard profile service calls Each sign within System State is a following meaning T Canbe 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state 9999 R20UT0655EJ0100 Rev 1 00 Page 197 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference vrst_dtq Clear data queue area C Language API ER ercd vrst dtq ID dtqid Parameters ID dtqid Data queue ID to be cleared e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc vrst dtq DTOID e Parameters DTQID Data queue ID to be cleared e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO Data queue ID to be cleared Error code None Functional descripti
135. definition H 245 CGydichandler definition decere a e eit eee ee pee ape Pe Ded P Pe ip Rea 246 CAlarrridhandletr definiti on aecenas p re eter drca Pr e rea rc een Ra EE TT 248 Clinterrupt vector definition ici aa ihe ide re aon pere ER 249 8 13 ConfiourationEileEvample A 252 8 2 Configurator Execution Procedures 20 0 eecececeecee cee cee ceeeeeeae eae eeae enne entren nennen nnns sn trennen tnnt 256 8 2 1 Configurator ODvervew nennen nnne nnne entren enn enne enn enne enn nns 256 8 22 Setting Configurator Environment enne ener enne nene 258 8 23 Configurator Start brochure 258 8 24 Precautions on Executing Configurator essssssseseseseeeeeee enne nee 258 8 25 Configurator Error Indications and Remedies 259 Ee BIN e EDITT 259 Warn Ile Bue ENEE 262 Other messages tp ret enge AA eed 262 9 Table Generation Utility einer ener noe rk erre nei ia aa a eo ai 263 St HEITEN EDT TT ETC EDT TATIUS 263 92 Environment SGtUp WEE 263 9 3 Table Generation Utility Start Procechure sss 263 G fl Ke 263 10 lt Sample Program Description guder g dica nadaa haa FX FERE A ea aa aoa vos 264 10 1 Overview of Sample Program ENEE NENNEN 264 10 2 Program Source L isting seesesessseseseseseesseeen nennen nnne een 265 1033 Configuration File te nine c 266 11 Stack Size Calculation Method eseesessseseseeeeee nennen en nnnnn nnne teninta iunet rani 267 11 1 Stack Size Calculation M
136. dler l flag ne RE l IPL 4 in system PL a 4 lt systemIPL lt 4 Figure 3 24 Interrupt control in a Service Call that can be Issued from a Task independent R20UT0655EJ0100 Rev 1 00 Page 32 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 6 4 Permission and prohibition of interrupt The I flag and IPL are changed in the service call as shown in Figure 3 23 and Figure 3 24 Therefore please corre spond as follows when you control the permission prohibition of interrupt in the task and the interrupt handler When prohibiting interrupt in the task 1 2 Interrupt control register SFR of the interrupt to be prohibited is changed loc_cpu unl_cpu is used The interrupt that can be controlled is only kernel OS dependent interrupt according to the loc_cpu service call Please go by the method by 1 or 3 when you control the non kernel OS independent in terrupt flag is operated The service call call cannot be called from clearing flag to the set of I flag when this method is used When permitting interrupt in the interrupt handler When accepting multiple interrupt E switch is added to the interrupt handler definition Multiple interrupt can be permitted by setting pragma switch E in the interrupt handler definition 2 flag is operated There is no limitation in the operation of flag in the interrupt handler 3 Interrupt control register SFR o
137. dware design is complicated 3 Product physical size is enlarged Therefore if you employ the real time OS in which a number of programs to be operated by a number of microcomputers are placed under software control of one microcomputer making it appear that the programs run on separate microcom puters you can obviate all the above disadvantages while retaining the above mentioned advantages Figure 3 3 shows an example system that will be obtained if the real time OS is incorporated in the system indicated in Figure 3 2 R20UT0655EJ0100 Rev 1 00 Page 6 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Key input Task LED illumination Task real time Os Volume control Mechanical Task control Task Figure 3 3 Example System Configuration with Real time OS Audio Equipment In other words the real time OS is the software that makes a one microcomputer system look like operating a number of microcomputers In the real time OS the individual programs which correspond to a number of microcomputers used in a conventional system are called tasks R20UT0655EJ0100 Rev 1 00 Page 7 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 1 2 Operating Principles of Kernel A kernel is the core program of real time OS The kernel is the software that makes a one microcomputer system look like operating a number of microcomputers You should be wondering how the kernel makes a one m
138. e handler only 189 vrcv dtq Receive from Long data ouee enne nennen nentes nennen nnns 192 vprcv dtq Receive from Long data queue polltmg rara rarnnnnnnn 192 viprcv_dtq Receive from Long data queue polling handler only esssss 192 vtrcv do Receive from Long data queue with timeout sssssssssseseeeeeennennenen 192 vref dro Reference Long data queue status 195 viref dro Reference Long data queue status handler olvl sees 195 5 16 Extended Function Reset Funcion eee nnne nnnm nnn nenne nnn nnn 197 vrst do Clear dataoueearen ENEE NENNEN 198 vrst_vdtq Clear Long data queue are 200 vrst mbx Clear mailbox area rnnt tni nentur nn edt hate taeda tne Deka epe aca aat aun 202 vrst mpf Clear fixed size memory pool are 204 vrst mpl Clear variable size memory pool are 205 6 Applications Development Procedure Overview esses nnne nnne nnne nnne nennen 206 E E e EE 206 ZG Detailled Applications eite Cerere ree ree d URL e Eie eL EE REP de ENEE 208 7 1 Program Coding Procedure in C Language 208 7 1 1 Task Description Procechure nnne nennen nnne enne enn enne 208 7 12 Writing a Kernel OS Dependent Interrupt Handler 211 7 13 Writing Non kernel OS independent Interrupt Handler AAA 212 7 14 Writing CydicHandler Alarm Handler sess enne nennen nenne 213 7 2 Program Coding Procedure in Assembly language 214 AAL ele E iiia nui haie nere Ee E coe ORE HE ie 214
139. e Calls Issued from Handlers in bytes Service call Stack size Service call Stack size lact_tsk 14 iprcv mbx 14 5 1can act 10 iref mbx 10 ista tsk 14 ipget mpf 16 5 ichg pri 32 irel_mpf 18 iget_pri 10 5 iref_mpf 10 iref_tsk 22 iset_tim 10 iref_tst 10 iget_tim 10 iwup_tsk 16 ista_cyc 10 ican_wup 10 istp_cyc 10 irel wai 14 iref_cyc 10 isus_tsk 12 ista_alm 10 irsm_tsk 12 istp_alm 10 ifrsm_tsk 12 iref_alm 10 isig sem 16 irot_rdq 10 ipol_sem 10 iget_tid 10 5 iref_sem 10 iloc_cpu 4 iset_flg 24 iunl_cpu 10 iclr_flg 10 ret_int 10 ipol flg 10 5 iref ver 12 iref flg 10 vipsnd dtq 18 ipsnd dtq 18 vifsnd dtq 18 ifsnd dtq 18 viprcv dtq 20 7 iprcv dtq 18 5 viref dtq 10 iref dtq 10 isnd mbx 30 iref mpl 12 Stack sizes used by service call in C programs Table 11 3 Stack Si zes Used by Servi ce Calls ssued f romTasks and Handl ers i n bytes lists the stack sizes system stack used by service calls that can be issued from both tasks and handlers If the service call issued from task system uses user stack If the service call issued from handler system uses system stack Table 11 3 Stack Sizes Used by Service Calls Issued from Tasks and Handlers in bytes Stack size sns loc 10 sns dpn 10 Service call Stack size Service call sns ctx 10 sns dsp 10 R20UT0655EJ0100 Rev 1 00 Jun 01 2011 Page 276
140. e MR30 s kernel MR KERNEL section e MR30 s ROM data MR ROM section Interrupt vector area INTERRUPT VECTOR section Settings of the section files are given below Section MR RAM DBG DATA H R30 s RAM data org 500H The address common to two applications Section MR RAM DATA R30 s RAM data org 600H The address common to two applications Section MR HEAP DATA R30 s RAM data org 10000H The address common to two applications Section MR ROM ROMDATA A R30 s ROM data org 0e0000H The address common to two applications section MR STARTUP CODE Start up program org 0e1000H The address common to two applications Section MR CIF CODE C language I F routine Section app prog CODE Use Program Section INTERRUPT VECTOR Interrupt Vector org Oefd00H The address common to two applications Section MR KERNEL CODE MR30 s kernel org 0 0000H The address common to two applications Section FIX INTERRUPT VECTOR Fixed Interrupt Vector org OfffdcH The address common to two applications The memory map turns to give below See Figure 13 2 R20UT0655EJ0100 Rev 1 00 Page 283 of 295 Jun 01 2011 RENESAS M3T MR30 4 13 Separate ROMs E 0000H Startup program MR KERNEL section Kerna ROM MR30 kernel Task of D 1 program section common program F 0000H MR30 s ROM data MR ROM section C language I F routine T
141. e acquired tget_mpf Register name Content after service call is issued RO Terminated normally E_OK or error code RI Start address of the acquired memory block R3 Timeout value 16 high order bits AO ID number of the target fixed size memory pool to be acquired e R3 Timeout value16 high order bits R1 Timeout value16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 135 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Error code E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out EV_RST Released from WAITING state by clearing of the memory pool area Functional description This service call acquires a memory block from the fixed size memory pool indicated by mpfid and stores the start ad dress of the acquired memory block in the variable p_blk The content of the acquired memory block is indeterminate If the fixed size memory pool indicated by mpfid has no memory blocks in it and the used service call is tget_mpf or get_mpf the task that issued it goes to a memory block wait state and is enqueued in a memory block waiting queue In that case if the attribute of the specified fixed size memory pool is TA_TFIFO the task is enqueued in order of FIFO if TA_TPRI the task is enqueued in order 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
142. e call is to be issued from task context use set flg if issued from non task context use iset_flg 37 The indivisibility of a service call is not guaranteed in the combination of this service call and iclr_flg iref_flg met tsk and an iref tst service call That is being processed to the state under this service call execution may occur R20UT0655EJ0100 Rev 1 00 Page 108 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task void set flg ID_flg FLGPTN Oxff00 lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM A0 R3 set_flg FID_FLG3 0ff00H R20UT0655EJ0100 Rev 1 00 Page 109 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference cir fig Clear eventflag iclr fig Clear eventflag handler only C Language API ER ercd clr flg ID flgid FLGPTIN clrptn ER ercd iclr flg ID flgid FLGPIN clrptn e Parameters ID flgid ID number of the eventflag to be cleared FLGPTN clrptn Bit pattern to be cleared e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc clr flg FLGID CLRPTN iclr flg FLGID CLRPTN Parameters FLGID ID number of the eventflag to be cleared CLRPTN Bit pattern to be cle
143. e following cases When the rcv dro trcv dro prcv dtq or iprcv_dtq service call is issued before the tmout time elapses with task awaking conditions thereby satisfied The error code returned in this case is E OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI When the target data queue being waited for is removed by the vrst dtq service call issued from another task The error code returned in this case is EV RST For fsnd_dtq and ifsnd_dtq 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 If the data queue area is not filled with data fsnd dtq and ifsnd dtq operate the same way as snd dtq If this service call is to be issued from task context use snd_dtq tsnd_dtq psnd_dtq fsnd_dtq if issued from non task con text use ipsnd_dtq ifsnd_dtq R20UT0655EJ0100 Rev 1 00 Page 119 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h VP INT data 10 void task void
144. e from waiting E TMOUT Polling failure or timeout or timed out E ILUSE Service call improperly used Tasks present waiting for TA WSGL attribute eventflag i R2 Timeout value16 high order bits RO Timeout value16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 112 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call waits until the eventflag indicated by flgid has its bits specified by waiptn set according to task awaking conditions indicated by wfmode Returned to the area pointed to by p_flgptn is the eventflag bit pattern at the time the task is released from WAITING state If the target eventflag has the TA_WSGL attribute and there are already other tasks waiting for the eventflag the error code E_ILUSE is returned If task awaking conditions have already been met when this service call is invoked the task returns immediately and responds to the call with E_OK If task awaking conditions are not met and the invoked service call is wai_flg or twai_flg the task is enqueued in an eventflag waiting queue In that case if the attribute of the specified eventflag is TA_TFIFO the task is enqueued in order of FIFO if TA_TPRI the task is enqueued in order of priority For the pol_flg and ipol_flg service calls the task returns immedi ately and responds to the call with the error code E_TMOUT For the twai_flg service call specify a wait time
145. e not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or system manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Blectronics Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1
146. e ref ver service call permits the user to get the version information of MR30 This version information can be obtained in the standardized format of uITRON specification R20UT0655EJ0100 Rev 1 00 Page 60 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 15 Extended Function Long Data Queue The long data queue is a function outside the scope of uITRON 4 0 Specification The data queue function handles data as consisting of 16 bits whereas the short data queue handles data as consisting of 32 bits Both behave the same way except only that the data sizes they handle are different Send to Long Data Queue vsnd dtq visnd_dtq The data is transmitted to the long data queue If the long data queue is full of data the task goes to a data transmission wait state Send to Long Data Queue vpsnd dro vipsnd dtq The data is transmitted to the long data queue If the long data queue is full of data the task returns error code without going to a data transmission wait state Forced Send to Long Data Queue vfsnd dtq vifsnd dtq The data is transmitted to the long data queue If the long data queue is full of data the data at the top of the long data queue or the oldest data is removed and the transmitted data is stored at the tail of the long data queue Receive from Long Data Queue vrcv dtq vtrcv dtq The data is retrieved from the long data queue If the long data queue has no data in it the task is kept waiting until dat
147. e target task is not in SUSPENDED state including DORMANT state the error code E_OBJ is returned to the service call issuing task The rsm tsk irsm tsk frsm tsk and ifrsm tsk service calls each operate the same way because the maximum number of forcible wait requests that can be nested is 1 If this service call is to be issued from task context use rsm_tsk frsm_tsk if issued from non task context use irsm tsk ifrsm tsk R20UT0655EJ0100 Rev 1 00 Page 95 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void taskl 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 1n lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO rsm tsk ID_TASK2 PUSHM AO frsm_tsk ID TASK1 R20UT0655bEJ0100 Rev 1 00 Page 96 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference dly_tsk Delay task C Language API ER ercd dly tsk RELTIM dlytim Parameters RELTIM dlytim Delay time e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc dly tsk e Parameters None e Register contents after s
148. eating a free space in the Long data queue area so that a task enqueued in a transmission wait ing queue is released from WAITING state and starts sending data to the Long data queue area If no data exist in the Long data queue and there is any task waiting to send data i e data bytes in the Long data queue area 0 data for the task at the top of the data transmission waiting queue is received As a result the task kept waiting to send that data is released from WAITING state On the other hand if vrcv dtq or vtrev_dtq is issued for the Long data queue which has no data stored in it the task that issued the service call goes from RUNNING state to a data reception wait state and is enqueued in a data reception waiting queue At this time the task is enqueued in order of FIFO For the vprev_dtq and viprcv do service calls the task returns immediately and responds to the call with the error code E TMOUT For the vtrev_dtq service call specify a wait time for tmout in ms units The values specified for tmout must be within Ox 7fffffff time tick 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 O as a timeout value in which case the service call operates the same way as vprcv dtq Furthermore if specified as tmoutZTMO FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as vrev_dtq The tas
149. ed RO Terminated normally E OK R1 Start address of the memory block to be returned 16 low order bits AO ID number of Variable size Memory pool of the memory block to be released Error code None Funcional description This service call releases a memory block whose start address is indicated by blk The start address of the memory block to be released that is specified here should always be that of the memory block acquired by pget mpl This service call does not check the content of blk so that if the address stored in blk is incorrect the service call may not operate correctly R20UT0655EJ0100 Rev 1 00 Page 145 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task VP p blk if get mpl ID mpll1 200 amp p blk E OK error Not enough memory An rel mpl ID mpl p blk lt lt Example statement in assembly language gt gt include mr30 inc GLB task g blk blkb 4 task PUSHM f AO get_mpl ID_MPL1 200 MOV L i R3R1 g blk PUSHM AO rel_mpf ID_MPL1 _g_blk R20UT0655EJ0100 Rev 1 00 Page 146 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref mpl Reference variable size memory pool status iref mpl Reference variable size memory pool status handler only C Langu
150. el id h void task chg pri ID task2 2 Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task pushm A0 R3 chg_pri ID_TASK3 1 R20UT0655EJ0100 Rev 1 00 Page 76 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference get_pri Reference task priority iget_pri Reference task priority handler only C Language API ER ercd get_pri ID tskid PRI p_tskpri ER ercd iget_pri ID tskid PRI p_tskpri e Parameters ID tskid ID number of the target task PRI p_tskpri Pointer to the area to which task priority is returned e Return Parameters ER ercd Terminated normally E_OK or error code Assembly language API include mr30 inc get pri TSKID iget pri TSKID e Parameters TSKID ID number of the target task Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO Acquired task priority Error code E_OBJ Object status invalid task indicated by tskid is an inactive state Functional description This service call returns the priority of the task indicated by tskid to the area indicated by p_tskpri If TSK_SELF is specified the priority of the issuing task itself is acquired If TSK_SELF is specified for tskid in non task context opera tion of the service call cannot be guaranteed If the task indicated by tskid is in DORMANT state it re
151. elapsed The cyclic handler may be started with or without saving the startup phase In the former case the cyclic handler is started relative to the point in time at which it was generated In the latter case the cyclic handler is started relative to the point in time at which it started operating Figure 4 21 and Figure 4 22 show typical operations of the cyclic handler If the startup cycle is shorter than the time tick interval the cyclic handler is started only once every time tick supplied processing equivalent to isig_tim For example if the time tick interval is 10 ms and the startup cycle is 3 ms and the cyclic handler has started operating when a time tick is supplied then the cyclic handler is started every time tick Cyclic handler created Start operating Stop operating Activation Activation Activation Activation Activation i phase i cyde cycle cycle cycle v v v Handler does Handler does Handler starts Handler starts Handler does not start not start not start Figure 4 21 Cyclic handler operation in cases where the activation phase is saved Start operating Stop operating Activation Activation Activation Activation Activation phase i cycle cycle cycle cycle v v v Handler does Handler does Handler starts Handler starts Handler does not start not start not start Figure 4 22 Cyclic handler operation in cases where the activation phase is not saved Start Cycl
152. em assumes either a CPU locked state or a CPU unlocked state In a CPU locked state all external interrupts are disabled against acceptance and task scheduling is not performed either The system can be placed into a CPU locked state or a CPU unlocked state by the loc_cpu iloc_cpu or unl_cpu iunl_cpu service call respectively Whether the system is in a CPU locked state can be known by the sns_loc service call The service calls that can be issued from a CPU locked state are limited to those that are listed in Table 3 2 Table 3 2 Invocable Service Calls in a CPU Locked State loc_cpu iloc_cpu unl cpu iunl cpu ext tsk sns dpn sns dsp sns ctx sns loc 3 5 4 Dispatch Disabled and CPU Locked States In uITRON 4 0 Specification the dispatch disabled and the CPU locked states are clearly discriminated Therefore if the unl cpu service call is issued in a dispatch disabled state the dispatch disabled state remains intact and no task schedul ing is performed State transitions are summarized in Table 3 3 Table 3 3 CPU Locked and Dispatch Disabled State Transitions Relating to dis dsp and loc cpu State Content of state dis dsp ena dsp loc cpu unl cpu number CPU locked Dispatch disabled executed executed executed executed state state 1 O X X X gt 1 gt 3 2 O O X X gt 2 gt 4 3 X X gt 4 gt 3 gt 1 gt 3 4 X O gt 4 gt 3 gt 2 gt 4 16 If a service call not iss
153. ement functions roses ReturnParameter ioi ege d Extended Function Reset functions roses ReturnParameter ServiceCall INTNo FuncCode a oa fat es amend e ST 3pm ms SI la Je Extended Function Long data queue functions aupa ServiceCall INTNo FuncCode R2 R3 FuncCode a NNI ei GEES efa em wes Tee E fata vaga foca IT s vago fees e fata vaga aca gt Eje eres urs en Le ei ura eu fa mo wr fa ET daf daf dd Led cata fota HEN IIT NE Lap CS Feci Je exa ms es pea ES E lg trout EE Ex Ee Ea Eee Ee 2 EJ 2 MES B wwdg 3 vs 3 ue Mer M 2 MES E 3j R20UT0655EJ0100 Rev 1 00 Page 292 of 295 Jun 01 2011 RENESAS Real time OS for M16C Series and R8C Family M3T MR30 4 V 4 01 User s Manual Publication Date Jun 01 2011 Rev 1 00 Published by Renesas Electronics Corporation Edited by Renesas Solutions Corp 44 NCESAS SALES OFHCES Renesas Electronics Corporation http www renesas com Refer to http www renesas com for the latest and detailed information Renesas Hectronics America Inc 2880 Scott Boulevard Santa Clara CA 95050 2554 U SA Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Hectronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada
154. emory Pool Management Function The technique that allows you to arbitrary define the size of memory block acquirable from the memory pool is termed Variable size scheme The MR30 manages memory in terms of four fixed size memory block sizes The MR30 calculates the size of individual blocks based on the maximum memory block size to be acquired You specify the maximum memory block size using the configuration file variable _memorypooll max_memsize 400 Maximum size heap_size 5000 Defining a variable size memory pool as shown above causes four fixed size memory block sizes to become 56 bytes 112 bytes 224 bytes and 448 bytes in compliance with max_memsize In the case of user requested memory the MR30 performs calculations based on the specified size and selects and allo cates the optimum one of four fixed size memory block sizes The MR30 cannot allocate a memory block that is not one of the four sizes Service calls the MR30 provides include the following Acquire Variable size Memory Block pget mpl Round off a block size you specify to the optimal block size among the four block sizes and acquires memory 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 file X data size for block control 8 byte For example if you request 200 byte the MR3
155. en 54 Figure 4 21 Cyclic handler operation in cases where the activation phase iS saved 56 Figure 4 22 Cyclic handler operation in cases where the activation phase is not saved 56 Figure 4 23 Typical operation of the alarm handler AA 57 Figure 4 24 Ready Queue Management by rot rdq Service Call 58 Figure 4 25 Interrupt process low 59 Figure5 1 Manipulation of the ready queue by the rot_rdq servicecall 169 Figure 6 1 MR30 System Generation Detail Flowchart 0 eee eeceeceeneenee tees eeeeeeeee eee eae eae eeaeeeaeeee 207 Figure 7 1 Example Infinite Loop Task Described in C Lanoage 208 Figure 7 2 Example Task Terminating with ext tsk Described in C Languagge 209 Figure 7 3 Example of Kernel OS dependent Interrupt Handler 211 Figure 7 4 Example of Non kernel OS independent Interrupt Handler 212 Figure 7 5 Example Cyclic Handler Written in C Language sss 213 Figure 7 6 Example Infinite Loop Task Described in Assembly L angoua0ge sss 214 Figure 7 7 Example Task Terminating with ext tsk Described in Assembly Language 214 Figure 7 8 Example of kernel OS depend interrupt handler A 216 Figure 7 9 Example of Non kernel OS independent Interrupt Handler of Specific Level 217 Figure 7 10 Example Handler Written in Assembly Language sse 218 Figure 7 11 C Language Startup Program for M 16C 63 64 65 cartOmr a30 sess 224 Figure 8
156. ent Period 4 8 16 32 Kbyte Program Size Figure 3 1 Relationship between Program Size and Development Period Under these circumstances it is necessary to adopt a method by which large size programs can be developed within a short period of time One way to achieve this purpose is to use a large number of microcomputers having a small ROM capacity Figure 3 2 presents an example in which a number of microcomputers are used to build up an audio equipment system On condition that the ROM program burning step need not be performed R20UT0655EJ0100 Rev 1 00 Page 5 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Key input Remote control LED illumination microcomputer microcomputer microcomputer Arbiter microcomputer Volume control Monitor Mechanical microcomputer microcomputer control microcomputer Figure 3 2 Microcomputer based System Example Audio Equipment Using independent microcomputers for various functions as indicated in the above example offers the following advan tages 1 Individual programs are small so that program development is easy 2 Itis very easy to use previously developed software 3 Completely independent programs are provided for 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 raising the product cost 2 Har
157. ent in assembly language gt gt include mr30 inc GLB task task PUSHM AO sus_tsk FID_TASK2 R20UT0655EJ0100 Rev 1 00 Page 94 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference rsm_tsk Resume suspended task irsm_tsk Resume suspended task handler only frsm_tsk Forcibly resume suspended task ifrsm tsk Forcibly resume suspended task handler only C Language API ER ercd rsm tsk ID tskid ER ercd irsm tsk ID tskid ER ercd frsm tsk ID tskid ER ercd ifrsm tsk ID tskid Parameters ID tskid ID number of the target task e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc rsm tsk TSKID irsm tsk TSKID frsm tsk TSKID ifrsm tsk TSKID e Parameters TSKID ID number of the target task e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO ID number of the target task Error code E OBJ Object status invalid task indicated by tskid is not a forcible wait state Functional description If the task indicated by tskid has been aborted by sus_tsk this service call resumes the target task from SUSPENDED state In this case the target task is linked to behind the tail of the ready queue In the case of frsm_tsk and ifrsm_tsk the task is forcibly resumed from SUSPENDED state If a request is issued while th
158. entflag handler only 110 wai To Wait for eventflag ennemi en iren enses nnne innen 112 pol flg Wait for eventflaotpOlino eese nennen nennen nnn nnne nennen 112 ipol flg Wait for eventflag polling handler only eene 112 twai_flg Wait for eventflag with timeout nnne nnne nnns 112 ref flg Reference eventflag status sssssssisiseseseeeseeeenee trennen nnn nennen rennen enne trennen 115 iref flg Reference eventflag status handler ov 115 5 5 Synchronization amp Communication Function DataOueuel 117 snd dtq Send to data queue isse am etn n Od EE Ce EO os ERR Pee ERR 118 psnd do Send to data queue pGollimnol nnns 118 ipsnd dro Send to data queue polling handler only 118 tsnd dtq Send to data queue with timeout nennen nennen nnne nnn nnns 118 fsnd dtq Forcibly send to data queue sesssssssssseseses essen entente trennen nnns tret tnter nennen 118 ifsnd dro Forcibly send to data queue handler ov 118 rcv dro Receive from data queue enne enne enn enne tnnt antreten nnne nnns 121 prcv dtq Receive from data queue polling nennen 121 iprcv_dtq Receive from data queue polling handler only 121 trcv_dtq Receive from data queue with timeout sess 121 ref dro Reference data queue status 124 iref dro Reference data queue status handler only 124 5 6 Synchronization amp Communication Function Mailbox 126 Gs Bu Ce heet TI EE 127 isnd mbx Send t
159. equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems safety equipment and medical equipment not specifically designed for life support Specific Aircraft aerospace equipment submersible repeaters nuclear reactor control systems medical equipment or systems for life support e g artificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics products ar
160. er a block control Variable size memory pool function needs 8 byte RAM area per a block control Memory pool size needs a size more than a b c or d that can be stored max_memsize 8 Cyclic handler definition This definition is necessary to use Cyclic handler function lt lt Format gt gt Cyclic Handlar Definition cyclic hand ID No name ID name interval counter Activation cycle start TA STA attribute A phsatr TA_PHS attribute phs_counter Activation phase entry address Start address exitf Extended information D I The ID number must be in the range of 1 to 255 The ID number can be omitted If omitted numbers are automatically assigned sequentially beginning with the smallest lt lt Content gt gt Define the following for each cyclic handler ID number 1 IDname Definition format Symbol Definition range None Default value None Define the name by which the memory pool is specified in a program 2 Activation cycle Definition format Numeric value Definition range 1 to Ox7FFFFFFF Default value None Define the activation cycle at which time the cyclic handler is activated periodically The activation cycle here must be defined in the same unit of time as the system clock s unit time that is defined in system clock defini tion item If you want the cyclic handler to be activated at 1 second inter
161. er bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 102 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call acquires one semaphore resource from the semaphore indicated by semid If the semaphore resource count is equal to or greater than 1 the semaphore resource count is decremented by 1 and the service call issuing task continues execution On the other hand if the semaphore count value is 0 the wai_sem or twai_sem service call invoking task is enqueued in a waiting queue for that semaphore If the attribute of the semaphore semid is TA_TFIFO the task is enqueued in order of FIFO if TA_TPRI the task is enqueued in order of priority For the pol sem and ipol sem service calls the task returns immediately and responds to the call with the error code E TMOUT For the twai sem service call specify a wait time for tmout in ms units The values specified for tmout must be within Ox 7fffffff time tick If any value exceeding this limit is specified operation of the service call cannot be guaranteed If TMO POL O is specified for tmout it means specifying 0 as a timeout value in which case the service call operates the same way as pol sem Furthermore if specified as tmoutZ TMO FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as wai sem The task placed into WAITING state by execution of the wai
162. er of FIFO TA MPRI Messages enqueued in order of priority Table 5 12 List of Mailbox Function Service Call No Service Call Function System State T NE DUI L 1 snd mbx S Send to mailbox O O JO O 2 isnd_mbx O O0 0 0 3 rcv_mbx S Receive from mailbox O O O 4 prev_mbx S Receive from mailbox O olojo 5 iprev_mbx polling OJO O O 6 trev_mbx S Receive from mailbox O O O with timeout 7 ref_mbx Reference mailbox status O olojo 8 iref_mbx OJO O O Notes e S Standard profile service calls e Each sign within System State is a following meaning T Can be called from task context N Can be called from non task context 9999 E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 RENESAS Page 126 of 295 M3T MR30 4 5 Service call reference snd_mbx Send to mailbox isnd_mbx Send to mailbox handler only C Language API ER ercd snd_mbx ID mbxid T_MSG pk_msg ER ercd isnd_mbx ID mbxid T_MSG pk_msg e Parameters ID mbxid ID number of the mailbox to which transmitted T_MSG pk_msg Message to be transmitted e Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc snd mbx MBXID PK MBX isnd mbx
163. ercd vfsnd dtq ID vdtqid W data ER ercd vifsnd dtq ID vdtqid W data e Parameters ID vdtqid ID number of the Long data queue to which transmitted TMO tmout Timeout value vtsnd_dtq W data Data to be transmitted e Return Parameters ER ercd Terminated normally E_OK or error code Assembly language API include mr30 inc vsnd dtq VDTQID visnd dtq VDTQID vpsnd dtq VDTQID vipsnd_dtq VDTQID vtsnd dtq VDTQID vfsnd dtq VDTQID vifsnd dtq VDTQID Parameters VDTQID ID number of the Long data queue to which transmitted DTQDATA Data to be transmitted e Register contents after service call is issued vsnd dtq vpsnd dtq vipsnd dtq vfsnd dtq vifsnd dro Register name Content after service call is issued RO Terminated normally E OK or error code R1 Data to be transmitted 16 low order bits R3 Data to be transmitted 16 high order bits AO ID number of the Long data queue to which transmitted E a R3 R3 R3 R3 R2 R3 R3 R3 Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call Timeout value16 high order bits RO Timeout value16 low order bits must be set before calli
164. ervice call is issued Register name Content after service call is issued RO Terminated normally E OK or error code RI Delay time 16 low order bits R3 Delay time 16 high order bits Error code E RLWAI Forced release from waiting Functional description This service call temporarily stops execution of the issuing task itself for a duration of time specified by dlytim to place the task from RUNNING state into WAITING state In this case the task is released from the WAITING state at the first time tick after the time specified by dlytim has elapsed Therefore if specified dlytim 0 the task is placed into WAIT ING state briefly and then released from the WAITING state at the first time tick The task placed into WAITING state by invocation of this service call is released from the WAITING state in the follow ing cases Note that when released from WAITING state the task that issued the service call is removed from the timeout waiting queue and linked to a ready queue When the first time tick occurred after dlytim elapsed The error code returned in this case is E OK When the rel wai or irel wai service call is issued before dlytim elapses The error code returned in this case is E RLWAI Note that even when the wup tsk or iwup_tsk service call is issued during the delay time the task is not released from WATTNG state The delay time dlytim is expressed in ms units Therefore if specified as dly tsk 50 the issuin
165. es each of system stack size is the following Service Call name System Stack Size sta_tsk 2bytes ext_tsk Obytes slp_tsk 2bytes dly_tsk 4bytes Therefore the maximum system stack size among the service calls to be used is the 8 bytes of dly_tsk epi The stack size to be used by the interrupt handler 74 The details will be described later ey Stack size used by the system clock interrupt handler This is detailed later 7 After switchover from user stack to system stack 73 Refer from Table 11 1 Stack Sizes Used by Service Calls Issued from Tasks in bytes to Table 11 3 Stack Sizes Used by Service Calls Issued from Tasks and Handlers in bytes for the system stack size used for each individual service call di OS dependent interrupt handler not including the system clock interrupt handler here and OS independent interrupt handler R20UT0655EJ0100 Rev 1 00 Page 271 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method a The maximum system stack size among the service calls to be used gt BuThe system stack size to be used by the interrupt handler pi NA S gt Interrupt ARS lt Be gt Interrupt ada Bn The necessary system stack Figure 11 4 System Stack Calculation Method R20UT0655bEJ0100 Rev 1 00 Page 272 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method Stack size Bi used by interrupt handlers
166. es defined Definition format Numeric value Definition range 1 to 255 Default value None Define the maximum number of data queues defined 7 For details of forming the into separate ROMs see page 280 R20UT0655EJ0100 Rev 1 00 Page 234 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 4 The maximum number of mailboxes defined Definition format Numeric value Definition range 1 to 255 Default value None Define the maximum number of mailboxes defined 5 The maximum number of semaphores defined Definition format Numeric value Definition range 1 to 255 Default value None Define the maximum number of semaphores defined 6 The maximum number of fixed size memory pools defined Definition format Numeric value Definition range 1 to 255 Default value None 7 The maximum number of variable length memory blocks defined Definition format Numeric value Definition range 1 to 255 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 255 Default value None The maximum number of cyclic handler defined 9 The maximum number of alarm handler defined Definition format Numeric value Definition range 1 to 255 Default value None Def
167. es effective so that the task continues executing again without going to WAIT state See Figure 4 5 Cancel Task Wakeup Requests can wup Clears the stored wakeup request See Figure 4 6 wup tsk wup tsk wup tsk sip tsk slp tsk Task Slee 1 Wakeup request count 0 0 1 2 1 Figure 4 5 Wakeup Request Storage wup tsk wup tsk can wup slp tsk slp tsk Task ETENIM NON Wakeup request count 0 0 1 0 0 Figure 4 6 Wakeup Request Cancellation 21 Note that tasks in WAIT state but kept waiting for the following conditions are not awaken Eventflag wait state semaphore wait state data transmission wait state data reception wait state timeout wait state fixed length memory pool acquisition wait short data transmission wait or short data reception wait R20UT0655EJ0100 Rev 1 00 Page 40 of 295 Jun 01 2011 RENESAS 4 Kernel M3T MR30 4 Suspend task sus_tsk isus_tsk Resume suspended task rsm_tsk irsm_tsk These service calls forcibly keep a task suspended for execution or resume execution of a task If a suspend re quest is issued to a task in READY state the task is placed into SUSPENDED state if issued to a task in WAIT state the task is placed into WAIT SUSPENDED state Since MR30 allows only one forcible wait request to be nested if sus tsk is issued to a task in a forcible wait state the error E QOVR is returned See Figure 4 7 E_QOVR sus tsk sus tsk rsm tsk Task a RUNNING SUSPENDED READY state state
168. es with the following two types of section files e asm_sec inc This file is used when you developed your applications with the assembly language e Cc 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 NC30 Modify the section allocation and start address settings in this file to suit your system R20UT0655EJ0100 Rev 1 00 Page 225 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 4 1 Sections that kernel uses The section allocation of the sample startup program for the assembly language start a30 is defined in asm sec inc The section allocation of the sample startup program for the C language crtOmr a30 is defined in c sec inc It explains each section that MR30 uses as follows e MR RAM DBG section This section is stored MR30 s debug function RAM data This section must be mapped in the Internal RAM area e MR RAM section This section is where the RAM data MR30 s system management data is stored that is referenced in absolute addressing This section must be mapped between 0 and FFFFH near area stack section This section is provided for each task s user stack and system stack This section must be mapped between 0 and FFFFH near area e MR HEAP section This section stores the variable size memorypool e MR KERNEL section This section is where the MR30 kernel prog
169. essary that vector tpl generated by cfg30 be present in the current directory 9 4 Notes Please specify mrc files generated by compilation of application without omission When there is an omission in the specification of mrc files some service call modules might not be build into the load module R20UT0655EJ0100 Rev 1 00 Page 263 of 295 Jun 01 2011 RENESAS 10 Sample Program Description 10 1 Overview of Sample Program As an example application of MR30 the following shows a program that outputs a string to the standard output device from one task and another alternately Table 10 1 Functions in the Sample Program Function Type ID No Priority Description Name main Task 1 1 Starts task1 and task2 task10 Task 2 2 Outputs task1 running task2 Task 3 3 Outputs task2 running cyhlQ Handler 1 Wakes up task1 The content of processing is described below e The main task starts task1 task2 and cyh1 and then terminates itself o task1 operates in order of the following 1 Gets a semaphore 2 Goes to a wakeup wait state 3 Outputs task running 4 Frees the semaphore o task2 operates in order of the following 1 Gets a semaphore 2 Outputs task2 running 3 Frees the semaphore cyhl starts every 100 ms to wake up task1 R20UT0655EJ0100 Rev 1 00 Page 264 of 295 Jun 01 2011 RENESAS M3T MR30 4 10 2Program Source Listing MR30 4 s Copy
170. f the interrupt to be prohibited is changed R20UT0655EJ0100 Rev 1 00 Page 33 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 7 About the power control of M16C and R8C and the operation of the kernel The kernel doesn t take part in the function of the power control supported by M16C and R8C Therefore it is necessary to process the transition processing of the operational mode by the user program Please process it according to the document of the microcomputer when the operational mode changes in the user program Moreover the kernel doesn t take part in the power control function and note the following points especially 1 About the stop and the start of the system clock The kernel doesn t stop and start the timer interrupt used as a system clock to transit the operational mode Please program the stop and the start processing in the user program if necessary 2 About the time out processing and the start processing of the time event handler The change of clock supply for the timer used as a system clock or the stopping it are needed for the transition of the operational mode Please note the following kernel operation The system time is not updated or time is delayed There is an influence in return parameter p systim of the get tim service call Thecyclic handler and the alarm handler don t start nor those start are delayed Neither the time out nor the late waiting release are processed nor the
171. ference rcv mbx Receive from mailbox prcv mbx Receive from mailbox polling iprcv mbx Receive from mailbox polling handler only trcv_mbx Receive from mailbox with timeout C Language API ER ercd rcv mbx ID mbxid T MSG ppk msg ER ercd prcv mbx ID mbxid T MSG ppk msg ER ercd iprcv mbx ID mbxid T MSG ppk msg ER ercd trcv mbx ID mbxid T MSG ppk msg TMO tmout e Parameters ID mbxid ID number of the mailbox from which to receive TMO tmout Timeout value for trcv mbx T MSG ppk msg Pointer to the start of the area in which received message is stored e Return Parameters ER ercd Terminated normally E OK or error code T MSG ppk msg Pointer to the start of the area in which received message is stored Assembly language API include mr30 inc rcv mbx MBXID prcv mbx MBXID iprcv mbx MBXID trcv mbx MBXID Parameters MBXID ID number of the mailbox from which to receive e Register contents after service call is issued rcv mbx prcv mbx iprcv mbx Register name Content after service call is issued RO Terminated normally E OK or error code R2 Received message AO ID number of the mailbox from which to receive trcv mbx Register name Content after service call is issued RO Terminated normally E OK or error code R2 Received message R3 Timeout value 16 high order bits AO ID number of the mailbox from which to receive Error code E RLWAI Forced
172. for a task in DORMANT state as the target task In that case the return parameter is 0 If this service call is to be issued from task context use can_act if issued from non task context use ican_act R20UT0655EJ0100 Rev 1 00 Page 67 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void taskl ER_UINT actcnt actcnt can act ID task2 void task2 ext_tsk lt lt Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task PUSHM AO can_act FID_TASK2 R20UT0655EJ0100 Rev 1 00 Page 68 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sta_tsk Activate task with a start code ista_tsk Activate task with a start code handler only C Language API ER ercd sta_tsk ID tskid VP_INT stacd ER ercd ista_tsk ID tskid VP_INT stacd Parameters ID tskid ID number of the target task VP INT stacd Task start code e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc Sta tsk TSKID STACD ista tsk TSKID STACD Parameters TSKID ID number of the target task STATCD Task start code Register contents after service call is issued Register name Content after service call is issued RO Terminated
173. for tmout in ms units The values specified for tmout must be within Ox7fffffff time tick 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 service call operates the same way as pol flg Furthermore if specified as tmout TMO_FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as wai flg The task placed into a wait state by execution of the wai flg or twai flg service call is released from WAITING state in the following cases When task awaking conditions are met before the tmout time elapses The error code returned in this case is E OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI The following shows how wfmode is specified and the meaning of each mode wfmdoe wait mode Meaning TWF ANDW Wait until all bits specified by waiptn are set wait for the bits AND ed TWF ORW Wait until one of the bits specified by waiptn is set wait for the bits OR ed If this service call is to be issued from task context use wai flg twai flg pol To if issued fr
174. g pending state ans don Gets the dispatching pending status of the system R20UT0655EJ0100 Rev 1 00 Page 58 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 13 Interrupt Management Function The interrupt management function provides a function to process requested external interrupts in real time The interrupt management service calls provided by the MR30 kernel include the following e Returns from interrupt handler ret int The ret int service call activates the scheduler to switch over tasks as necessary when returning from the inter rupt handler When using the C language TL 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 shows an interrupt processing flow Processing a series of operations from task selection to register restora tion is called a scheduler TaskA NN Interrupt Save Registers Handler Processing iwup tsk pragma INTHANDLER Dedare C language TaskB Task Selection Restore Registers Figure 4 25 Interrupt process flow 3 In the case that the interrupt handler is specified by pragma INTHANDLER R20UTO0655EJ0100 Rev 1 00 Page 59 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 14 System Configuration Management Function This function inspects the version information of MR30 e References Version Information ref ver iref ver Th
175. g task is placed from RUNNING state into a delayed wait state for a period of 50 ms The values specified for dlytim must be within Ox7fffffff time tick If any value exceeding this limit is specified the service call may not operate correctly This service call can be issued only from task context It cannot be issued from non task context SS R3 Delayed time value16 high order bits R1 Delayed time value 16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 97 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt tinclude lt kernel h gt include kernel_id h void task d if dly_tsk E_OK error Forced wakeup n lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM RI R3 MOV W 500 R1 MOV W 0 R3 dly_tsk R20UT0655bEJ0100 Rev 1 00 Page 98 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 3 Synchronization amp Communication Function Semaphore Specifications of the semaphore function of MR30 are listed in Table 5 5 Table 5 5 Specifications of the Semaphore Function No Item Content 1 Semaphore ID 1 255 2 Maximum number of resources 1 65535
176. g the configurator requires the following input files e Configuration file XXXX cfg This file contains description of the system s initial setup items It is created in the current directory e Default configuration file default cfg This file contains default values that are referenced when settings in the configuration file are omitted This file is placed in the directory indicated by environment variable LIB30 or the current directory If this file exists in both directories the file in the current directory is prioritized over the other e include template file mr30 inc sys ram inc This file serves as the template file of include file mr30 inc and sys ram inc It resides in the directory in dicated by environment variable LIB30 e MR30 version file version This file contains description of MR30 s version It resides in the directory indicated by environment variable LIB30 The configurator reads in this file and outputs MR30 s version information to the startup message 2 When the configurator is executed the files listed below are output Do not define user data in the files output by the configurator Starting up the configurator after entering data definitions may result in the user defined data being lost e System data definition file sys rom inc sys ram inc This file contains definition of system settings e Include file mr30 inc This is an include file for the assembly language e ID number defini
177. g the interrupt handler start address make the external declara tion Global declaration 3 Make sure that the registers used in a handler are saved at the entry and are restored af ter use 4 Return to the task by ret_int service call INCLUDE mr30 inc s 1 GLB inth ee 2 inth Registers used are saved to a stack 3 iwup tsk ID_taskl process Registers used are restored 3 ret int 4 Figure 7 8 Example of kernel OS depend interrupt handler D Use the GLB peudo directive R20UT0655EJ0100 Rev 1 00 Page 216 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 2 3 Writing Non kernel OS independent Interrupt Handler 1 For the symbol indicating the interrupt handler start address make the external declara tion public declaration 2 Make sure that the registers used in a handler are saved at the entry and are restored af ter use 3 Be sure to end the handler by REIT instruction No service calls can be issued from a non kernel an OS independent interrupt handler NOTE If this restriction is not observed the software may malfunction 5 If you want multiple interrupts to be enabled in a non kernel an OS independent interrupt handler always make sure that the non kernel OS independent interrupt handler is as signed a priority level higher than other non kernel OS dependent interrupt handlers GLB inthand 1 1
178. g with the smallest lt lt Content gt gt 1 IDname Definition format Symbol Definition range None Default value None Define the name by which the memory pool is specified in a program 2 The maximum memory block size to be allocated Definition format Numeric value Definition range 1 to 65520 Default value None Specify within an application program the maximum memory block size to be allocated 3 Section name Definition format Symbol Definition range None Default value MR_HEAP Define the name of the section in which the memory pool is located The section defined here must always have an area allocated for it in the section file asm_sec inc or c sec inc If no section names are defined the memory pool is located in the MR_HEAP section 4 Memory pool size Definition format Numeric value Definition range 16 to OxFFFF Default value None Specify a memory pool size Round off a block size you specify to the optimal block size among the four block sizes and acquires memory having the rounded off size from the memory pool R20UT0655EJ0100 Rev 1 00 Page 245 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator The following equations define the block sizes a max_memsize X 1 X x 8 1 x 8 b ax2 c ax4 d ax8 max_memsize the value specified in the configuration file X data size for block control 8 byte p
179. ge TA_ASM Handlers written in assembly language Table 5 22 List of Alarm Handler Function Service Call No Service Call Function System State T N E D U L 1 sta_alm Starts alarm handler operation O OOO 2 ista_alm CO IOlO 3 stp_alm Stops alarm handler operation OlOlO 4 istp_alm Olololo 5 ref_alm References alarm handler sta O Ololo 6 iref_alm tus oOolololo Notes e S Standard profile service calls Each sign within System State is a following meaning T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Page 161 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sta_alm Start alarm handler operation ista_alm Start alarm handler operation handler only C Language API ER ercd sta_alm ID almid RELTIM almtim ER ercd ista_alm ID almid RELTIM almtim e Parameters ID almid ID number of the alarm handler to be operated RELTIM almtim Alarm handler startup time relative time e Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc sta alm ALMID ALMTIM ista alm ALMID ALMTIM Parameters ALMID ID number of the
180. halted while another task assumes execution control Task execution restarts at the point of last interruption as the register contents prevailing at the time of the last interrup tion are recovered In other words task switching refers to the action performed to save the currently executed task reg ister 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 is only necessary to manage the register for each task and change the register con tents upon each task switching so that it looks as if a number of microcomputers exist See Figure 3 6 Key input Remote control Task Task RO RO R1 R1 m DES E l l l l PC PC Register Register Figure 3 6 Task Switching The example presented in Figure 3 7 indicates how the individual task registers are managed In reality it is necessary to provide not only a register but also a stack area for each task It is figure where all the stack areas of the task were arranged in the same section R20UT0655EJ0100 Rev 1 00 Page 9 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Memory map Remote control Task Key input Task LED illumination Task Real time OS Figure 3 7 Task Register Area Figure 3 8 shows the register and stack area of one task in detail In the MR30 the register of each task is stored in a stack area as
181. has no memory blocks in it the task returns immediately and responds to the call with the error code E TMOUT The value of the memory block acquired by this service call is indeterminate because it is not initialized This service call can be issued only from task context It cannot be issued from non task context Example program statement lt lt Example statement in C language gt gt include itron h include kernel h include kernel id nh VP bik void task if pget mpl ID mpl 200 amp p blk E OK error Not enough memory Nn lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO pget_mpl ID_MPL1 200 R20UT0655EJ0100 Rev 1 00 Page 144 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference rel_mpl Release variable size memory block C Language API ER ercd rel_mpl ID mplid VP blk Parameters ID mplid ID number of Variable size Memory pool of the memory block to be released VP BIk Start address of the memory block to be returned e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc rel mpl MPLID BLK e Parameters MPLID ID number of Variable size Memory pool of the memory block to be released BLK Start address of the memory block to be returned e Register contents after service call is issued Register name Content after service call is issu
182. he time must not begin with period R20UT0655EJ0100 Rev 1 00 Page 229 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 8 1 2 Configuration File Definition Items 68 The following definitions are to be formulated in the configuration file System definition System clock definition Respective maximum number of items e Task definition Eventflag definition Semaphore definition Mailbox definition Data queue definition Short data queue definition Fixed size Memory Pool definition Variable size Memory Pool definition e Cyclic handler definition e Alarm handler definition Interrupt vector definition System Definition Procedure lt lt Format gt gt System Definition system stack_size System stack size priority Maximum value of SERT system_IPL Kernel mask Level OS interrupt disable level timeout Timeout function task_pause Task Pause tic_deno Time tick denominator tic_nume Time tick numerator message_pri Maximum message priority value All items except task definition can omitted If omitted definitions in the default configuration file are referenced R20UT0655EJ0100 Rev 1 00 Page 230 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator lt lt Content gt gt 1 System stack size Definition format Numeric value Definition range
183. head of the semaphore s wait queue the next task to be dequeued If no tasks are kept waiting TSK NONE is returned semcnt Returned to semcnt is the current semaphore resource count If this service call is to be issued from task context use ref sem if issued from non task context use iref sem R20UT0655EJ0100 Rev 1 00 Page 105 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RSEM rsem ER ercd ercd ref sem ID_seml amp rsem lt lt Example statement in assembly language gt gt _ refsem blkb 4 include mr30 inc GLB task task PUSHM A0 A1 ref sem ID_SEM1 _refsem R20UT0655EJ0100 Rev 1 00 Page 106 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 4 Synchronization amp Communication Function Eventflag Specifications of the eventflag function of MR30 are listed in Table 5 7 Table 5 7 Specifications of the Eventflag Function No Item Content 1 EventOflag ID 1 255 2 Number of bits comprising 16 bits eventflag 3 Eventflag attribute TA_TFIFO Waiting tasks enqueued in order of FIFO TA_TPRI Waiting tasks enqueued in order of priority TA_WSGL Multiple tasks cannot be kept waiting TA_WMUL Multiple tasks can be kept waiting TA_CL
184. i current priority of task tskpri has the current priority of the specified task returned to it If the task is in DOMANT state tskpri is indeterminate tskbpri base priority of task tskbpri has the base priority of the specified task returned to it Since the M3T MR30 does not sup port the mutex function tskpri and tskbpri assume the same value If the task is in DOMANT state tskbpri is indeterminate tskwait cause of wait If the target task is in a wait state one of the following causes of wait is returned The values of the respective causes of wait are listed below If the task status is other than a wait state TTS WAI or TTS WAS tskwait is indeterminate e 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 sem TTW FLG 0x0008 Kept waiting by wai flg or twai flg TTW SDTQ 0x0010 Kept waiting by and dro or tsnd_dtq TTW RDTQ 0x0020 Kept waiting by rcv dro or trcv dtq TTW MBX 0x0040 Kept waiting by rcv mbx or trev_mbx TTW MPF 0x2000 Kept waiting by get mpf or tget mpf TTW VSDTQ 0x4000 Kept waiting by vsnd dtq or vtsnd dro e TTW VRDTQ 0x8000 Kept waiting by vrcv dtq or vtrev_dtq wobjid waiting object ID If the target task is in a wait state TTS_WAI or TTS WAS the ID of the waiting target object is re turned Otherwise wobjid is indeterminate 4 lefttmo left time before timeout If the target task has bee
185. i Change task priority ichg_ pri Change task priority handler only C Language API ER ercd chg_pri ID tskid PRI tskpri ER ercd ichg_pri ID tskid PRI tskpri e Parameters ID tskid ID number of the target task PRI tskpri Priority of the target task Return Parameters ER ercd Terminated normally E_OK or error code Assembly language API include mr30 inc chg pri TSKID TSKPRI ichg pri TSKID TSKPRI e Parameters TSKID ID number of the target task TSKPRI Priority of the target task e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code R3 Priority of the target task AO ID number of the target task Error code E OBJ Object status invalid task indicated by tskid is an inactive state R20UT0655EJ0100 Rev 1 00 Page 75 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call changes the priority of the task indicated by tskid to the value indicated by tskpri and performs re scheduling based on the result of that priority change Therefore if this service call is executed on a task enqueued in a ready queue including one that is in an executing state or a task in a waiting queue in which tasks are enqueued in order of priority the target task is moved to behind the tail of a relevant priority part of the queue Even when the same priority as the
186. i TA_FIFO Tasks enqueued in order of FIFO 3 Semaphore attribute SE TA_TPRI Tasks enqueued in order of priority Table 5 6 List of Semaphore Function Service Call No Service Call Function System State T N E D U L 1 sig_sem S Releases semaphore O O O O isig_sem S resource O O O O 3 wai sem S Acquires semaphore O O O resource 4 pol_sem S Acquires semaphore O O O O 5 ipol_sem resource polling O O O O 6 twai_sem S Acquires semaphore O O O resource with timeout 7 ref_sem References semaphore O O O O 8 iref_sem status O O O O Notes e S Standard profile service calls e Each sign within System State is a following meaning T Can be called from task context 9999 R20UT0655EJ0100 Rev 1 00 Jun 01 2011 N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state ztENESAS Page 99 of 295 M3T MR30 4 5 Service call reference sig sem Release semaphore resource isig sem Release semaphore resource handler only C Language API ER ercd sig sem ID semid ER ercd isig sem ID semid e Parameters ID semid Semaphore ID number to which returned e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc Sig sem SEMID isig sem SEMID e Parameters SEMID Semaphore
187. ic Handler Operation sta_cyc ista_cyc Causes the cyclic handler with the specified ID to operational state Stop Cyclic Handler Operation stp cyc istp cyc Causes the cyclic handler with the specified ID to non operational state Reference Cyclic Handler Status ref cyc iref cyc Refers to the status of the cyclic handler The operating status of the target cyclic handler and the remaining time before it starts next time are inspected R20UT0655EJ0100 Rev 1 00 Page 56 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 11 Alarm Handler Function The alarm handler is a time event handler that is started only once at a specified time Use of the alarm handler makes it possible to perform time dependent processing The time of day is specified by a rela tive time Figure 4 23 shows a typical operation of the alarm handler Start St created P a E 3 Activation time Start operating Activation time Handler starts Handler does not start Figure 4 23 Typical operation of the alarm handler e Start Alarm Handler Operation sta alm ista alm Causes the alarm handler with the specified ID to operational state Stop alarm Handler Operation stp alm istp alm Causes the alarm handler with the specified ID to non operational state e Reference Alarm Handler Status ref alm iref alm Refers to the status of the alarm handler The operating status of the target alarm handler and the rema
188. icrocomputer sys tem function like a number of microcomputers As shown in Figure 3 4 the kernel runs a number of tasks according to the time division system That is it changes the task to execute at fixed time intervals so that a number of tasks appear to be executed simultaneously Key input Task Remote control Task LED illumination Task Volume control Task Monitor Task Mechanical control Task _ _ _ 9 HM Time Figure 3 4 Time division Task Operation As indicated above the kernel changes the task to execute at fixed time intervals This task switching may also be re ferred to as dispatching The factors causing task switching dispatching are as follows e Task switching occurs upon request from a task e Task switching occurs due to an external factor such as interrupt When a certain task is to be executed again upon task switching the system resumes its execution at the point of last in terruption See Figure 3 5 R20UT0655EJ0100 Rev 1 00 Page 8 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Program execution Program execution interrupt resumed Key input Task V y During this interval it appears that the key input microcomputer is haled Remote control Task Figure 3 5 Task Execution Interruption and Resumption In the state shown in Figure 3 5 it appears to the programmer that the key input task or its microcomputer is
189. ify message size 16 or 32 of the Mailbox function cfg30 Warning task x XXXX is not defined near line xxx xxxx cfg The task definition item XXXX in ID number is omitted cfg30 Warning Already definition XXXX near line xxx xxxx cfg XXXX has already been defined The defined content is ignored check to delete the extra definition cfg30 Warning interrupt_vector x s default is not defined default cfg The interrupt vector definition of vector number x in the default configuration file is missing cfg30 Warning 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 cfg30 Warning system stack_size is an uneven number near line xxx cfg30 Warning task x stack_size is an uneven number near line xxx Please set even size in system stack_size or task x stack_size Other messages The following message are a warning message that is output only when generating makefile The configurator skips the sections that have caused such a warning as it generates makefile cfg30 Error xxxx line xxx include format error The file read format is incorrect Rewrite it to the correct format cfg30 Warning xxxx line xxx can t find lt XXXX gt cfg30 Warning xxxx line xxx can t find XXXX The include file XX XX cannot be found Check the file name and whether the file actually exists cfg30 Warning
190. ights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information When exporting the products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations You should not use Renesas Electronics products or the technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warr
191. ile name Command Options v Option Displays the command option descriptions and detailed information on the version V Option Displays the information on the files generated by the command 8 2 4 Precautions on Executing Configurator The following lists the precautions to be observed when executing the configurator e Do not modify the startup program name and the section definition file name Otherwise an error may be encountered when executing the configurator R20UT0655EJ0100 Rev 1 00 Page 258 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 8 2 5 Configurator Error Indications and Remedies If any of the following messages is displayed the configurator is not normally functioning Therefore correct the con figuration file as appropriate and the execute the configurator again Error messages cfg30 Error syntax error near line xxx xxxx cfg There is an syntax error in the configuration file cfg30 Error not enough memory Memory is insufficient cfg30 Error illegal option gt lt x gt The configurator s command option is erroneous cfg30 Error illegal argument gt xx The configurator s startup format is erroneous cfg30 Error can t write open lt XXXX gt The XXXX file cannot be created Check the directory attribute and the remaining disk capacity available cfg30 Error can t open lt XXXX gt The XXXX file cannot be accessed Check the attributes of the
192. ine the maximum number of alarm handlers defined 10 The maximum number of short data queues defined Definition format Numeric value Definition range 1 to 255 Default value None Define the maximum number of short data queues defined R20UT0655EJ0100 Rev 1 00 Page 235 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Task definition lt lt Format gt gt Tasks Definition task ID No 11 name ID name entry address Start task of address stack_size User stack size of task priority Initial priority of task context Registers used Stack section Section name in which the stack is located initial start TA ACT attribute initial startup state exinf Extended information The ID number must be in the range of 1 to 255 The ID number can be omitted If omitted numbers are automatically assigned sequentially beginning with the smallest lt lt Content gt gt 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 name defined here is output to the kernel id h file as shown below define Task ID Name task ID 2 Start address of task Definition format Symbol or function name Definition range None Default value None Define the entry addre
193. ining time before it starts are inspected R20UT0655bEJ0100 Rev 1 00 Page 57 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 12 System Status Management Function e Rotate Task Precedence rot rdq irot_rdq This service call establishes the TSS time sharing system That is if the ready queue is rotated at regular in tervals round robin scheduling required for the TSS is accomplished See Figure 4 24 Priority RS 0 O taskB EM taskC O Po taskD m taskE K taskF gt TION Movethe end of the queue Figure 4 24 Ready Queue Management by rot rdq Service Call Reference task ID in the RUNNING state get tid iget tid References the ID number of the task in the RUNNING state If issued from the handler TSK NONE 0 is obtained 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 Frees the system from a CPU locked state Disable dispatching dis dsp Places the system into a dispatching disabled state e Enable dispatching ena dsp Frees the system from a dispatching disabled state Reference context sns_ctx Gets the context status of the system Reference CPU state sns_loc Gets the CPU lock status of the system Reference dispatching state sns_dsp Gets the dispatching disable status of the system e Reference dispatchin
194. ion e prno 2 Reserved for future extension e prno 3 Reserved for future extension If this service call is to be issued from task context use ref ver if issued from non task context use iref ver Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task T_RVER pk_rver ref ver amp pk_rver lt lt Example statement in assembly language gt gt include mr30 inc GLB task _ refver blkb 6 task PUSHM AO ref_ver _refver R20UT0655EJ0100 Rev 1 00 Page 187 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 15Extended Function Long Data Queue Specifications of the Long data queue function of MR30 are listed in Table 5 26 This function is outside the scope of uITRON 4 0 Specification Table 5 26 Specifications of the Long Data Queue Function No Item Content 1 Data queue ID 1 255 2 Capacity data bytes in data queue area 0 65535 3 Data size 32 bits 4 Data queue attribute TA_TFIFO Waiting tasks enqueued in order of FIFO TA_TPRI Waiting tasks enqueued in order of priority Table 5 27 List of Long Dataqueue Function Service Call No Service Call Function System State T N E D U L 1 vsnd_dtq S Sends to long data queue O O O 2 vpsnd_d
195. ion of the service call cannot be guaranteed 4 tskstat task status tskstat has one of the following values returned to it depending on the status of the specified task e TTS RUN 0x0001 RUNNING state e TTS RDY 0x0002 READY state e TTS WAI 0x0004 W AITING state e TTS SUS 0x0008 SUSPENDED state e TTS WAS 0x000C WAITING SUSPENDED state e TTS DMT 0x0010 DORMANT state tskwait cause of wait If the target task is in a wait state one of the following causes of wait is returned The values of the respective causes of wait are listed below If the task status is other than a wait state TTS_WAI or TTS WAS tskwait is indeterminate e TTW SLP 0x0001 Kept waiting by slp tsk or tslp tsk TTW DLY 0x0002 Kept waiting by dv 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 by snd dtq or tsnd_dtq TTW RDTQ 0x0020 Kept waiting by rcv dtq or trev_dtq TTW MBX 0x0040 Kept waiting by rcv mbx or trcv mbx TTW MPF 0x2000 Kept waiting by get mpf or tget mpf TTW VSDTQ 0x4000 Kept waiting by vsnd_dtq or vtsnd da TTW VRDTQ 0x8000 Kept waiting by vrev_dtq or vtrev_dtq If this service call is to be issued from task context use ref tst if issued from non task context use iref_tst Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void t
196. ivation request count of the target task is equal to or greater than 1 the activation request count is decremented by 1 and processing similar to that of act tsk or iact_tsk is performed In that case the task is placed from DORMANT state into READY state The task has its extended informa tion passed to it as parameter when the task starts up If a task specifies its own task ID or TSK SELF an E ILUSE error is returned If the specified task was placed into WAITING state and has been enqueued in some waiting queue the task is dequeued from it by execution of this service call However the semaphore and other resources the specified task had acquired previously are not released If the task indicated by tskid is in DORMANT state it returns the error code E OBJ as a return value for the service call This service call can only be used in task context and cannot be used in non task context R20UT0655EJ0100 Rev 1 00 Page 73 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task ter_tsk ID_main lt lt Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task PUSHM AO ter_tsk FID_TASK3 R20UT0655EJ0100 Rev 1 00 Page 74 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference chg_pr
197. ize 116 117 bss zero clear 118 119 BZERO TOPOF bss FE bss FE 120 BZERO TOPOF bss FO bss FO 121 122 5 123 Copy edata E O section from edata EI OI section 124 125 BCOPY TOPOF data FEI data FE top data FE 126 BCOPY TOPOF data FOI data FO top data FO 127 128 Lde __Sys_Spse0FFFEHA sp 129 ide __Sys_Sp amp OFFFFH fb 130 131 5 132 Initialize standard 1 0 133 53 134 glb init 135 jsr a init 136 137 138 Set System IPL 139 and 140 Set Interrupt Vector 141 142 mov b 0 ROL 143 mov b A SYS IPL ROH R20UT0655EJ0100 Rev 1 00 Page 221 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 144 ldc RO FLG Set system IPL 145 ldc INT VECTOR 516 amp OFFFFH INTBH 146 ldc __INT_VECTORSOFFFFH INTBL 147 148 IF USE_TIMER 149 150 7 System timer interrupt setting 151 152 tmroffset equ 60h Timer register offset for M16C 64 153 for M16C 64 154 155 mov b stmr_mod_val stmr_mod_regttmroffset set timer mode for M16C 64 156 mov b stmr_int_IPL stmr_int_reg set timer IPL 157 mov w stmr_cnt stmr_ctr_regttmroffset set interval count for M16C 64 158 or b stmr_bit 1 stmr_start tmroffset system timer start for M16C 64 159 ENDIF 160 Letz 162 System timer initialize
198. k awaking conditions thereby satisfied The error code returned in this case is E OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI When the target Long data queue being waited for is removed by the vrst vdtq service call issued from another task The error code returned in this case is EV RST For vfsnd dro and vifsnd_dtq the data at the top of the Long data queue or the oldest data is removed and the transmit ted data is stored at the tail of the Long data queue If the Long data queue area is not filled with data vfsnd dtq and vifsnd dtq operate the same way as vsnd dtq If this service call is to be issued from task context use vsnd dtq vtsnd dtq vpsnd dtq vfsnd dtq if issued from non task R20UT0655EJ0100 Rev 1 00 Page 190 of 295 Jun 01 2011 RENESAS M3T MR30 4 context use vipsnd_dtq vifsnd_dtq Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h W data 10 void task void El vsnd dtq ID dtq data 0 E RLWAI error Forced released n if vpsnd dtq ID dro data l error TimeoutWn if vtsnd dt
199. k placed into a wait state by execution of the vrev_dtq or vtrev_dtq service call is released from the wait state in the following cases When the vrcv dro vtrcv dtq vprev_dtq or viprcv dtq service call is issued before the tmout time elapses with task awaking conditions thereby satisfied The error code returned in this case is E OK When the first time tick occurred after tmout elapsed while task awaking conditions remain unsatisfied The error code returned in this case is E TMOUT When the task is forcibly released from WAITING state by the rel wai or irel wai service call issued from another task or a handler The error code returned in this case is E RLWAI If this service call is to be issued from task context use vrev_dtq vtrev_dtq vprev_dtq if issued from non task context use viprcv dtq R20UTO0655EJ0100 Rev 1 00 Page 193 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task W data if vrcv dtq ID dtq amp data E RLWAI error forced wakeup Nn if vprcv dtq ID dro amp data E TMOUT error Timeout n if vtrcv dtq ID dro amp data 10 E TMOUT error Timeoutin lt lt Example statement in assembly language gt gt include mr30 inc
200. kill Another way would be to make use of a structured descriptive assembler C compiler or the like with a view toward facilitating pro gramming It is also possible to enhance debugging efficiency by promoting modular software development However the conventional methods are not adequate for the purpose of solving the problems Under these circumstances it is necessary to introduce a new system named real time OS To answer the above mentioned demand Renesas has developed a real time operating system tradenamed MR30 for use with the M16C 10 M16C 20 M16C 30 M16C 60 M16C Tiny and R8C Tiny series of 16 bit microcomputers When the MR30 is introduced the following advantages are offered 1 Software recycling is facilitated When the real time OS is introduced timing signals are furnished via the real time OS so that programs de pendent on timing can be reused Further as programs are divided into modules called tasks structured pro gramming will be spontaneously provided That is recyclable programs are automatically prepared OS Operating System R20UT0655EJ0100 Rev 1 00 Page 2 of 295 Jun 01 2011 RENESAS M3T MR30 4 2 General Information 2 Ease of team programming is provided When the real time OS is put to use programs are divided into functional modules called tasks Therefore en gineers can be allocated to individual tasks so that all steps from development to debugging can be conducted independen
201. l from other task request from other task WAITING SU SPENDED state WAITING state dear SUSPENDED state DORMANT state Figure 3 16 MR30 Task Status Transition SUSPEND request from other task SUSPENDED state clear request Forced termination request from other task Task activation 1 RUNNING state In this state the task is being executed Since only one microcomputer is used it is natural that only one task is being executed The currently executed task changes into a different state when any of the following conditions occurs The task has normally terminated itself by ext_tsk service call The task has placed itself in the WAITING Since the service call was issued from the RUNNING state task the WAITING state of an other task with a priority higher than the RUNNING state task is cleared Due to interruption or other event occurrence 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 the priority of another READY task is rendered higher When the ready queue of the issuing task priority is rotated by the rot rdq or irot rdq ser vice call and control of execution is thereby abandoned When any of the above conditions occurs rescheduling takes place so that the task having the highest priority among those in the RUNNING o
202. l can only be used in task context This service call can be used even in a CPU locked state but cannot be used in non task context R20UT0655EJ0100 Rev 1 00 Page 71 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task void ext_tsk lt lt Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task axe tsk R20UT0655EJ0100 Rev 1 00 Page 72 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ter_tsk Terminate task C Language API ER ercd ter_tsk ID tskid e Parameters ID tskid ID number of the forcibly terminated task Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc ter tsk TSKID e Parameters TSKID ID number of the forcibly terminated task e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO ID number of the target task Error code E OBJ Object status invalid task indicated by tskid is an inactive state E ILUSE Service call improperly used task indicated by tskid is the issuing task itself Functional description This service call terminates the task indicated by tskid If the act
203. l status 147 iref mpl Reference variable size memory pool status handler only sssssss 147 5 9 Time Management Function sess enne enses enn sn rese tnnt nennt nnn n 149 CS Lu NEE ue IEN 150 iset_tim Set system time handler only ener nnne nennen nns 150 get tim Reference system Ume ANNER 152 iget tim Reference system time handler only 152 isig tim Supply a time tick EE 154 5 10 Time Management Function CvdtcH ander 155 sta cyc Start cyclic handler operatton ener 156 ista cyc Start cyclic handler operation handler only A 156 stp OC Stops cyclic handler operation sess enne enne enne nnne 158 istp cyc Stops cyclic handler operation handler only 158 ref c Reference cyclic handler status 159 iref cyc Reference cyclic handler status handler ov 159 5 11 Time Management Function Alarm Handler 161 sta alm Start alarm handler Operation 162 ista alm Start alarm handler operation handler only 162 stp alm Stop alarm handler operation enne enne nnne nennen 164 istp alm Stop alarm handler operation handler only 164 ref alm Reference alarm handler status 165 iref alm Reference alarm handler status handler only 165 5 12 System Status Management Function essssessseseeen enne nnne nennen sete nnns 167 rot rdq Rotate task precedence essen entente enne tesis nennt nnne nn nennt 168 irot_rdq Rotate task precedence handler only 168 get
204. l_id h void task T_RFLG rflg ER ercd ercd ref_flg ID_FLG1 amp rflg lt lt Example statement in assembly language gt gt _ refflg blkb 4 include mr30 inc GLB task task PUSHM A0 A1 ref flg ID_FLG1 _refflg R20UT0655EJ0100 Rev 1 00 Page 116 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 5 Synchronization amp Communication Function Data Queue Specifications of the data queue function of MR30 are listed in Table 5 9 Table 5 9 Specifications of the Data Queue Function No Item Content 1 Data queue ID 1 255 2 Capacity data bytes in data queue area 0 65535 3 Data size 16 bits 4 Data queue attribute TA_TFIFO Waiting tasks enqueued in order of FIFO TA_TPRI Waiting tasks enqueued in order of priority Table 5 10 List of Dataqueue Function Service Call No Service Call Function System State T N E D U L 1 snd dtq S Sends to data queue O O O 2 psnd_dtq S Sends to data queue O O O O 3 ipsnd_dtq S polling O O O O 4 tsnd_dtq S Sends to data queue O O O with timeout 5 fsnd_dtq S Forced sends to data queue O O O O 6 ifsnd_dtq S O O O O T rcv_dtq S Receives from data queue O O O 8 prev_dtq S Receives from data queue O O O O 9 iprcv dtq polling O O O O 10 trcv dro S Receives from data queue O O O with timeout 11 ref
205. ll is automatically invoked at return from the task regardless of whether it is explicitly written when terminated Terminate Task ter_tsk Other tasks in other than DORMANT state are forcibly terminated and placed into DORMANT state If startup requests are accumulated task startup processing is performed again In that case the task behaves as if it was reset See Figure 4 2 Startup request count gt 0 TaskB ter_tsk B Terminated Task B reset Figure 4 2 Task Resetting Change Task Priority chg_pri ichg_pri If the priority of a task is changed while the task is in READY or RUNNING state the ready queue also is up dated See Figure 4 3 Furthermore if the target task is placed in a waiting queue of objects with TA_TPRI attribute the waiting queue also is updated See Figure 4 4 R20UT0655EJ0100 Rev 1 00 Page 38 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel Priority 1 Task A Task B BEEN 3 gt gt TaskC p R Task B Task D l l L 4 When the priority of task B has been changed from 3to 1 Figure 4 3 Alteration of task priority ID Number O O Y ET a O taskA PA taskB mm taskC I taskB Priority 1 Priority 2 Priority 3 Priority 4 O When the priority of Task B is changed into 4 Figure 4 4 Task rearrangement in a waiting queue e Reference task priority get pri
206. ll reference ref tst Reference task status simplified version iref tst Reference task status simplified version handler only C Language API ER ercd ref tst ID tskid T RTST pk rtst ER ercd iref tst ID tskid T RTST pk rtst e Parameters ID tskid ID number of the target task T RTST pk rtst Pointer to the packet to which task status is returned e Return Parameters ER ercd Terminated normally E OK Contents of pk rtsk typedef struct t rtst STAT tskstat 0 2 Task status STAT tskwait 2 2 Cause of wait T_RTST Assembly language API include mr30 inc ref tst TSKID PK RTST iref tst TSKID PK RTST e Parameters TSKID ID number of the target task PK RTST Pointer to the packet to which task status is returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target task Al Pointer to the packet to which task status is returned Error code None R20UT0655EJ0100 Rev 1 00 Page 82 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call inspects the status of the task indicated by tskid and returns the current information on that task to the area pointed to by pk_rtst as a return value If TSK_SELF is specified the status of the issuing task itself is inspected If TSK SELF is specified for tskid in non task context operat
207. lls related to delay dispatching e dis dsp e ena dsp e loc cpu iloc cpu unl cpu iunl cpu The following describes task handling when dispatch is temporarily delayed by using these service calls 1 When the execution task in delay dispatching should be preempted While dispatch is disabled even under conditions where the task under execution should be preempted no time is dispatched to new tasks that are in an executable state Dispatching to the tasks to be executed is de layed until the dispatch disabled state is cleared When dispatch is being delayed e Task under execution is in a RUN state and is linked to the ready queue Task to be executed after the dispatch disabled state is cleared is in a READY state and is linked to the highest priority ready queue among the queued tasks 2 isus tsk irsm tsk during dispatch delay In cases when isus tsk is issued from an interrupt handler that has been invoked in a dispatch disabled state to the task under execution a task to which dis dsp was issued to place it in a SUSPEND state During delay dispatching The task under execution is handled inside the OS as having 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 OK is returned Then when irsm tsk is issued to the task under execution the task is linked to the ready queue and e
208. lly initialized when the task is started The external and static variables are initialized only by the startup program crtOmr a30 which actuates before MR30 startup 11 The task executed when the MR30 system starts up is setup 5 The configurator generates the file kernel id h that is used to convert the ID number of a task into the string to be specified This means that the define declaration necessary to convert the string specified in the task definition item name into the ID number of the task is made in kernel id h The same applies to the cyclic and alarm handlers 7 The task starts from its start function with the initial priority in a wakeup counter cleared state R20UT0655EJ0100 Rev 1 00 Page 209 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 12 The variable storage classification is described below The MR30 treats the C language variables as indicated in Table 7 1 C Language Variable Treatment Table 7 1 C Language Variable Treatment Variable storage class Treatment Global Variable Variable shared by all tasks Non function static variable Variable shared by the tasks in the same file Auto Variable Register Variable Variable for specific task Static variable in function R20UT0655EJ0100 Rev 1 00 Page 210 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 1 2 Writing a Kernel OS Dependent Interrupt Handler When describing the kernel OS de
209. lue 1 Set the numerator of the time tick The system clock interrupt interval is determined by the time tick denomi nator and numerator that are set here The interval is the time tick numerator divided by time tick denominator ms That is the time tick numerator ms The tic_nume value that can be specified for the M32C 82 or 83 operating with 20 MHz is 26 ms because of the microcomputer specification 8 Maximum message priority value Definition format Numeric value Definition range 1 to 255 Default value None Define the maximum value of message priority System Clock Definition Procedure lt lt Format gt gt System Clock Definition clock timer_clock timer clock timer Timers used for system clock IPL System clock interrupt priority level current_reg_map System clock address correction lt lt Content gt gt y 1 timer clock Definition format Frequency in MHz Definition range None Default value 20MHz Define the clock frequency supplied to timer f1 clock value in MHz units R20UT0655EJ0100 Rev 1 00 Page 232 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 2 Timers used for system clock Definition format Symbol Definition range M16C 60 Series AO A4 BO B5 OTHER NOTIMER M16C 30 Series AO A2 B1 B2 OTHER NOTIMER M16C
210. m is always in a CPU unlocked state when these handlers start Invoking this service call again while the system is already in a CPU locked state does not cause an error in which case task queuing is not performed however R20UT0655EJ0100 Rev 1 00 Page 172 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference If this service call is to be issued from task context use loc cpu if issued from non task context use iloc cpu Example program statement lt lt Example statement in C language gt gt include itron h include kernel h include kernel id h void task loc cpu Example statement in assembly language gt gt include mr30 inc GLB task task loc cpu R20UTO655EJ0100 Rev 1 00 Page 173 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference unl cpu Unlock the CPU iunl cpu Unlock the CPU handler only C Language API ER ercd unl cpu ER ercd iunl_cpu e Parameters None e Reurn Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc unl cpu iunl cpu Parameters None e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK Error code None Functional description This service call frees the system from a CPU locked state that was set by the loc cpu or iloc cpu service call If the unl c
211. m size used by cyclic handler 24 maximum size used by alarm handler C language Using the stack size calculation utility calculate the stack size of each Alarm or Cyclic handler Refer to the manual of the stack size calculation utility for detailed use of the stack size calculation utility Assembly language The stack size to be used by Alarm or Cyclic handler register to be used user size stack size to be used by service call If neither cyclic handler nor alarm handler is used then y 14bytes When using the interrupt handler and system clock interrupt handler in combination add the stack sizes used by both R20UT0655EJ0100 Rev 1 00 Page 274 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 2Necessary Stack Size Table 11 1 Stack Sizes Used by Service Calls Issued from Tasks in bytes lists the stack sizes system stack used by service calls that can be issued from tasks 11 Stack Size Calculation Method Table 11 1 Stack Sizes Used by Service Calls Issued from Tasks in bytes Service call Stack size User stack System stack Service call Stack size User stack act_tsk N rcv mbx 5 can act DECH mbx 14 5 sta tsk trcv mbx 5 ext tsk ref mbx 10 ter tsk BILOIN O get_mpf 5 chg pri o N N pget_mpf 16 5 get_pri tget_mpf 5 ref tsk N N rel_mpf 0 ref_tst o ref_mpf
212. manufacturer code UH prid 2 2 Kernel identification number UH spver 4 2 ITRON specification version number UH prver 6 2 Kernel version number UH prno 4 8 2 Kernel product management information T_RVER e Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc ref ver PK VER iref ver PK VER Parameters PK_VER Pointer to the packet to which version information is returned Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E_OK AO Pointer to the packet to which version information is returned Error code None R20UT0655EJ0100 Rev 1 00 Page 186 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call reads out information about the version of the currently executing kernel and returns the result to the area pointed to by pk_rver The following information is returned to the packet pointed to by pk_rver maker The code H 11B denoting Renesas Electronics Corporation is returned prid The internal identification code IDH 130 of the M3T MR30 is returned spver The code H 5402 denoting that the kernel is compliant with uITRON Specification Ver 4 02 00 is returned prver The code H 0410 denoting the version of the M3T MR30 4 is returned prno e prno 0 Reserved for future extension e prno l Reserved for future extens
213. maphore a task etc is called an object An object is identified by the ID number 3 3 1 The specification method of the object in a service call Each task is identified by the ID number internally in MR30 For example the system says Start the task having the task ID number 1 However if a task number is directly written in a program the resultant program would be very low in readability If for instance the following is entered in a program the programmer is constantly required to know what the No 2 task is act tsk 2 Further if this program is viewed by another person he she does not understand at a glance what the No 2 task is To avoid such inconvenience the MR30 provides means of specifying the task by name function or symbol name The program named configurator cfg30 which is supplied with the MR30 then automatically converts the task name to the task ID number This task identification system is schematized in Figure 3 14 sta tsk Task name Starting the task having the designated Name ID number ID number Configurator Program Real time OS Figure 3 14 Task Identification act tsk ID task This example specifies that a task corresponding to ID task be invoked It should also be noted that task name to ID number conversion is effected at the time of program generation Therefore the processing speed does not decrease due to this conversion feature R20UT0655EJ0100 Rev 1 00
214. memory area used by a task or a handler Extended Function Module Outside the scope of uITRON 4 0 Specification this function performs reset processing on objects and long data queue function 19 This handler actuates once only at preselected times This handler periodically actuates R20UT0655EJ0100 Rev 1 00 Page 37 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 Kernel Function 4 3 1 Task Management Function The task management function is used to perform task operations such as task start stop and task priority updating The MR30 kernel offers the following task management function service calls e Activate Task act_tsk iact_tsk Activates the task changing its status from DORMANT to either READY or RUNNING In this service call unlike in sta_tsk ista_tsk startup requests are accumulated but startup code cannot be specified Activate Task sta_tsk ista_tsk Activates the task changing its status from DORMANT to either READY or RUNNING In this service call unlike in act_tsk iact_tsk startup requests are not accumulated but startup code can be specified Terminate Invoking Task ext_tsk When the issuing task is terminated its state changes to DORMANT state The task is therefore not executed until it is restarted If startup requests are accumulated task startup processing is performed again In that case the issuing task behaves as if it were reset If written in C language this service ca
215. n placed in WAITING state TTS WAI or TTS WAS by other than dv tsk the left time before it times out is returned If the task is kept waiting perpetually TMO FEVR is re turned Otherwise lefttmo is indeterminate actcnt task activation request The number of currently queued task activation request is returned wupcnt wakeup request count The number of currently queued wakeup requests is returned If the task is in DORMANT state wupoent is indeterminate suscnt suspension request count The number of currently nested suspension requests is returned If the task is in DORMANT state suscnt is indeterminate If this service call is to be issued from task context use ref tsk if issued from non task context use iref tsk 31 TTW_VSDTQ and TTW_VRDTQ are the causes of wait outside the scope of ITRON 4 0 Specification R20UT0655EJ0100 Rev 1 00 Page 80 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RTSK rtsk ER ercd ercd ref tsk ID main amp rtsk lt lt Example statement in assembly language gt gt _refdata blkb 20 include mr30 inc GLB task task PUSHM A0 A1 ref_tsk TSK_SELF _refdata R20UT0655bEJ0100 Rev 1 00 Page 81 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service ca
216. n range 1 to 65 535 Default value 1 Define the total number of blocks that comprise the memory pool 4 Size in bytes Definition format Numeric value Definition range 2 to 65 535 Default value 256 Define the size of the memory pool per block The RAM size to be used as a memory pool is determined by this definition number of blocks x size in bytes 5 Selecting a memory pool waiting queue Definition format Symbol Definition range TA TFIFO or TA TPRI Default value TA TFIFO Select a method in which tasks wait for acquisition of the fixed size memory pool If TA TFIFO is selected tasks are enqueued in order of FIFO If TA TPRI is selected tasks are enqueued in order of priority beginning with the one that has the highest priority R20UT0655EJ0100 Rev 1 00 Page 244 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Variable size memory pool definition This definition is necessary to use Variable size memory pool function lt lt Format gt gt Variable Size Memory pool Definition variable memorypool ID No name ID Name max_memsize The maximum memory block size to be allocated mpl_section Section name heap size Memory pool size Ir The ID number must be in the range to 255 The ID number can be omitted If omitted ID numbers are automatically assigned in order of numbers beginnin
217. nagement Function Variable size Memory Pool Specifications of the Variable size Memory pool function of MR30 are listed in Table 5 15 The memory pool area to be acquired can be specified by a section name for each memory pool during configuration Table 5 15 Specifications of the Variable size memory Pool Function No Item Content 1 Variable size memory pool ID 1 255 Size of Variable size Memory pool 16 65535 3 Maximum number of memory blocks to be ac 1 65520 quired 4 Supported attributes When memory is insufficient task waiting APIs are not supported 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 No Service Call Function System State T N E D U L 1 pget_mpl Aquires variable size memory O olojo block polling 2 rel_mpl Releases variable size memory O olojo block 3 ref mpl References variable size memory O OJO O 4 iref_mpl pool status O 0 0 O Notes e S Standard profile service calls Each sign within System State is a following meaning T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Page 142 of 295
218. nchronization service calls Release Semaphore Resource sig sem isig sem Releases one resource to the semaphore This service call wakes up a task that is waiting for the semaphores service or increments the semaphore counter by 1 if no task is waiting for the semaphores service e Acquire Semaphore Resource wai sem twai sem Waits for the semaphores service If the semaphore counter value is one or more the semaphore counter value is decremented by 1 If the semaphore counter value is 0 zero the semaphore cannot be acquired Therefore the WAITING state prevails R20UT0655EJ0100 Rev 1 00 Page 44 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel e Acquire Semaphore Resource pol sem ipol sem Acquires the semaphore resource If the semaphore counter value is one or more the semaphore counter value is decremented by 1 If the semaphore counter value is 0 zero an error code is returned and the WAITING state does not prevail Reference Semaphore Status ref sem iref sem Refers the status of the target semaphore Checks the count value and existence of the wait task for the target semaphore Figure 4 12 shows example task execution control provided by the wai sem and sig sem service calls wai sem sig sem Task eo wai_sem Task e wai sem wai_sem Task WAIT state i l l Geier Sch 3 2 1 0 x 0 Counter Figure 4 12 Task Execution Control
219. nclude kernel id h void task void process Figure 7 1 Example Infinite Loop Task Described in C Language 5 The task is ended by ext_tsk automatically if pramga TASK is declared in the MR30 Similarly it is ended by ext_tsk when returned halfway of the function by return sentence R20UT0655EJ0100 Rev 1 00 Page 208 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications include lt itron h gt include kernel h include kernel id h void task void for process Figure 7 2 Example Task Terminating with ext_tsk Described in C Language 7 To specify a task use the string written in the task definition item name of the configu ration file wup_tsk ID main 8 To specify an event flag semaphore or mailbox use the respective strings defined in the configuration file For example if an event flag is defined in the configuration file as shown below flag 1 name ID_abc D I To designate this eventflag proceed as follows set flg ID abc amp setptn 9 To specify a cyclic or alarm handler use the string written in the cyclic or alarm handler definition item name of the configuration file sta cyc ID cyc 10 When a task is reactivated by the sta tsk service call after it has been terminated by the ter tsk service call the task itself starts from its initial state However the external va riable and static variable are not automatica
220. ndler That is interruption priority level is from system_IPL 1 to 7 A service call cannot be published within an interruption OS independence kernel management outside hair drier However the kernel management generated during service call processing outside even if it is the section where interruption cannot receive a kernel management OS dependence interrupt handler OS independence it is possible to receive interruption kernel management outside OS independence Figure 3 22 shows the relationship between the non kernel OS independent interrupt handlers and ker nel OS dependent interrupt handlers where the kernel mask level OS interrupt disable level is set to 3 Kernel mask level OS Interrupt disable level Kernel Non kernel OS dependent OS independent Interrupt handler Interrupt handler Figure 3 22 Interrupt handler IPLs R20UT0655EJ0100 Rev 1 00 Page 30 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 6 2 The Use of Non maskable Interrupt An NMI interrupt and Watchdog Timer interrupt have to use be a non kernel OS independent interrupt handler If they are a kernel OS dependent interrupt handler the program will not work normally 3 6 3 Controlling Interrupts Interrupt enable disable control in a service call is accomplished by IPL manipulation The IPL value in a service call is set to the kernel mask level OS interrupt disable level system IPL in order to disable interrup
221. ng sevice call Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call Data 16 high order bits R1 Data 16 low order bits must be set before calling sevice call om o o o E PBR on 6 60 4 EE E SE R20UT0655EJ0100 Rev 1 00 Page 189 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference visnd_dtq Register name Content after service call is issued RO Terminated normally E_OK or error code RI Data to be transmitted 16 low order bits R2 Timeout value 16 high order bits R3 Data to be transmitted 16 high order bits AO ID number of the Long data queue to which transmitted Error code E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out E_ILUSE Service call improperly used vfsnd_dtq or vifsnd_dtq is issued for a Long data queue whose dtqcnt 0 EV RST Released from a wait state by clearing of the Long data queue area Functional description This service call sends the signed 4 byte data indicated by data to the Long data queue indicated by vdtqid If any task is kept waiting for reception in the target Long data queue the data is not stored in the Long data queue and instead sent to the task at the top of the reception waiting queue with which the task is released from the reception wait state On the other hand if vsnd_dtq or vtsnd_dtq is issued
222. nition is necessary to use Eventflag function lt lt Format gt gt Eventflag Definition flag ID No II name Name wait_queue Selecting an event flag waitin ueue initial_pattern Initial value of the event fla wait_multi Multi wait attribute clear attribute Clear attribute H The ID number must be in the range of 1 to 255 The ID number can be omitted If omitted numbers are automatically assigned sequentially beginning with the smallest lt lt Content gt gt Define the following for each eventflag ID number 1 ID Name Definition format Symbol Definition range None Default value None Define the name with which an eventflag is specified in a program R20UT0655EJ0100 Rev 1 00 Page 238 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 2 3 4 5 Selecting an event flag waiting queue Definition format Symbol Definition range TA_TFIFO or TA_TPRI Default value TA_TFIFO Select a method in which tasks wait for the event flag If TA_TFIFO is selected tasks are enqueued in order of FIFO If TA_TPRI is selected tasks are enqueued in order of priority beginning with the one that has the highest priority Initial value of the event flag Definition format Numeric value Definition range 0 to OxFFFF Default value 0 Specify the initial bit pattern of the event flag
223. normally E_OK or error code RI Task start code AO ID number of the target task Error code E_OBJ Object status invalid task indicated by tskid is not DOMANT state R20UT0655EJ0100 Rev 1 00 Page 69 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call starts the task indicated by tskid In other words it places the specified task from DORMANT state into READY state or RUNNING state This service call does not enqueue task activation requests Therefore if a task activa tion request is issued while the target task is not DORMANT state the error code E_OBJ is returned to the service call issuing task This service call is effective only when the specified task is in DORMANT state The task start code stacd is 16 bits long This task start code 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 the task 2 Clears the number of queued wakeup requests 3 Clears the number of nested forcible wait requests If this service call is to be issued from task context use sta_tsk if issued from non task context use ista_tsk Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt include lt kernel h gt include kernel_id h void task ER ercd VP_INT stacd
224. not operate normally If the starting function of an interrupt handler is declared by pragma INTHANDLER the ret int service call is automatically issued at the exit of the function R20UT0655EJ0100 Rev 1 00 Page 184 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 14System Configuration Management Function 5 Service call reference Table 5 25 List of System Configuration Management Function Service Call No Service Call Function System State T N E D U L 1 ref ver S References version in O O JO O iref ver formation olo olo Notes e S Standard profile service calls Each sign within System State is a following meaning R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 9999 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state 32 NE SAS Page 185 of 295 M3T MR30 4 5 Service call reference ref ver Reference version information iref ver Reference version information handler only C Language API ER ercd ref ver T RVER pk rver ER ercd iref ver T RVER pk rver e Parameters T_RVER pk rver Pointer to the packet to which version information is returned Contents of pk rver typedef struct t rver UH maker 0 2 Kernel
225. nt F unction ocoocccncccnnconacocannnann conan eae non eee ener enne tnnt tn nnne nnn tnnt nennen enne 63 act tsk Adivate task retener EE ias 65 iact tsk Activate task handler only 65 can act Cancel task activation request nennen 67 ican act Cancel task activation request handler ov 67 sta tsk Activate task with a start code nennen 69 ista tsk Activate task with a start code handler only 69 ext ek Terminate INVOKING task AANEREN 71 teritsk TORII MALS CASK S m 73 chg pri Changetask priority eret iere dvd 75 ichg pri Changetask priority handler only ennt nne 75 get pri Reference task priority sse enne enne enn enne en nre rr senes 77 iget_pri Reference task priority handler only seeseseeeeeeeneeeneeenetnn enne 77 ref tsk Reference task status sssini tiura nteti nnne ninth teintes tentent ann anna 79 iref tsk Referencetask status handler ov 79 ref tst Reference task status simplified version 82 iref tst Reference task status simplified version handler only 82 5 2 Task Dependent Synchronization Functon eene nnn 84 slp tsk Puttask to sleep a ande te a i ic Eee e e DXX or ERR Pe genie 85 tslp tsk Put task to sleep with timeout enne nnne enn nnns 85 wup_tsk Wakeup task one tie ete tet tien eer enin EES Eten 87 iwup tsk Wakeup task handler only nnne nnne entren innen nnn 87 can wup Cancel wakeup reest 89 ican wup Cancel wakeup request handle
226. nt Procedure Overview Details the applications program development procedure for the MR30 7 Detailed Applications Presents useful information and precautions concerning applications program development with MR30 8 Using Configurator Describes the method for writing a configuration file and the method for using the configurator in detail 9 Table Generation Utility Describes the method for executing table generation utility in detail 10 Sample Program Description Describes the MR30 sample applications program which is included in the product in the form of a source file 11 Stack Size Calculation Method Describes the calculation method of the task stack size and the system stack size 12 Note Presents useful information and precautions concerning applications program development with MR30 13 Separate ROMs Explains about how to Form Separate ROMs e 14 Appendix Data type and assembly language interface R20UT0655EJ0100 Rev 1 00 Page 1 of 295 Jun 01 2011 RENESAS 2 General Information 2 1 Objective of MR30 Development In line with recent rapid technological advances in microcomputers the functions of microcomputer based products have become complicated In addition the microcomputer program size has increased Further as product development com petition has been intensified manufacturers are compelled to develop their microcomputer based products within a short period of time In other words engineers engaged in micr
227. o be operated e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the cyclic handler to be operated Error code None Functional description This service call places the cyclic handler indicated by cycid into an operational state If the cyclic handler attribute of TA PHS is not specified the cyclic handler is started every time the activate cycle elapses start with the time at which this service call was invoked If while TA PHS is not specified this service call is issued to a cyclic handler already in an operational state it sets the time at which the cyclic handler is to start next If while TA PHS is specified this service call is issued to a cyclic handler already in an operational state it does not set the startup time If this service call is to be issued from task context use sta cyc if issued from non task context use ista cyc R20UT0655EJ0100 Rev 1 00 Page 156 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task sta_cyc ID_cycl lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO sta cyc ID_CYC1 R20UT0655EJ0100 Rev 1 00 Page 157 of 295 Jun 01 2011 RENE
228. o mailbox handler only 127 rcv mbx Receive from mailbOx sess nre nren rennen nnne nnns 129 prov mbx Receive from mailbox polling sese nnne 129 iprcv mbx Receive from mailbox polling handler only 129 trcv mbx Receive from mailbox with met 129 ref mbx Reference mailbox status eeseseesseeeeeeen ener enne nennen nen innen tinte 132 iref mbx Reference mailbox status handler only coooccccocccnncccnonocccoonnnonononanonononnnconcnnnnrnnnnnnnccnnnnos 132 5 7 Memory Pool Management Function Fixed size Memory Pool 134 get mpf Aquirefixed size memory block sse enne nnn nene 135 pget mpf X Aquirefixed size memory block polling eene 135 ipget mpf Aquirefixed size memory block polling handler only 135 tget mpf Aquirefixed size memory block with timeout ssessseseseeeeenene 135 rel mpf Release fixed size memory block nnne nennen nnne nnns 138 irel mpf Release fixed size memory block handler only 138 ref mpf Reference fixed size memory pool status ssssssseeeeeeennee nennen 140 iref mpf Reference fixed size memory pool status handler only 140 5 8 Memory Pool Management Function Variable size Memory Pol 142 pget mpl Aquire variable size memory block polling eee 143 rel mpl Release variable size Memory Dock AAA 145 ref mpl Reference variable size memory poo
229. oad module converter optink or Imc30 ROM write format Figure 6 1 MR30 System Generation Detail Flowchart R20UT0655bEJ0100 Rev 1 00 Page 207 of 295 Jun 01 2011 RENESAS T Detailed Applications 7 1 Program Coding Procedure in C Language 7 1 1 Task Description Procedure 1 Describe the task as a function To register the task for the MR30 enter its function name in the configuration file When for instance the function name task is to be registered as the task ID number 3 proceed as follows task 3 name ID_task entry_address task stack_size 100 priority 3 h 2 At the beginning of file be sure to include itron h kernel h which is in system direc tory as well as kernel id h which is in the current directory That is be sure to enter the following two lines at the beginning of file include 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 A function that is declared to be static cannot be registered as a task 5 It isn t necessary to describe ext tsk at the exit of task start function If you exit the task from the subroutine in task start function please describe ext tsk in the subrou tine 6 Itis also possible to describe the task startup function using the infinite loop include lt itron h gt include lt kernel h gt i
230. ocomputer software development are now required to develop larger size pro grams within a shorter period of time To meet such stringent requirements it is necessary to take the following consid erations into account 1 To enhance software recyclability to decrease the volume of software to be developed One way to provide for software recyclability is to divide software into a number of functional modules wher ever possible This may be accomplished by accumulating a number of general purpose subroutines and other program segments and using them for program development In this method however it is difficult to reuse programs that are dependent on time or timing In reality the greater part of application programs are dependent on time or timing Therefore the above recycling method is applicable to only a limited number of programs 2 To promote team programming so that a number of engineers are engaged in the develop ment of one software package There are various problems with team programming One major problem is that debugging can be initiated only when all the software program segments created individually by team members are ready for debugging It is essential that communication be properly maintained among the team members 3 To 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 s
231. od tasks are placed in a waiting queue in order of priority TA TPRI attribute in another tasks are placed in a waiting queue in order of FIFO TA TFIFO Figure 3 18 and Figure 3 19 depict the manner in which tasks are placed in a waiting queue in order of taskD taskC taskA and taskB ID No 1 Priority 1 Priority 5 Priority 6 Priority 9 n Figure 3 18 Waiting queue of the TA_TPRI attribute ID No 1 2 taskD taskC I1 taskA taskB Priority 9 Priority 6 Priority 1 Priority 5 n Figure 3 19 Waiting queue of the TA_TFIFO attribute R20UT0655EJ0100 Rev 1 00 Page 24 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 4 4 Task Control Block TCB The task control block TCB refers to the data block that the real time OS uses for individual task status priority and other control purposes The MR30 manages the following task information as the task control block Task connection pointer Task connection pointer used for ready queue formation or other purposes Task status Task priority Task register information and other data storage stack area pointer current SP register value Wake up counter Task wake up request storage area Time out counter or wait flag pattern When a task is in a time out wait state the remaining wait time is stored if in a flag wait state the flag s wait pattern is stored in this area
232. oes from WAITING state to READY state when the request is met or the specified time has elapsed If the task is placed into WAITING state for a wait request by the wai flg wai sem rcv mbx snd dtq rcv dtq vsnd do vrcv dtq get mpf twai_flg twai sem trcv mbx tsnd dtq trev_dtq vtsnd dtq vtrcv dtq or tget mpf service call the task is queued to one of the fol lowing waiting queues depending on the request Event flag waiting queue Semaphore waiting queue Mailbox message reception waiting queue Data queue data transmission waiting queue Data queue data reception waiting queue Short data queue data transmission waiting queue Short data queue data reception waiting queue Fixed size memory pool acquisition waiting queue 4 SUSPENDED state When the sus tsk service call is issued from a task in the RUNNING state or the isus_tsk service call is issued from a handler the READY task designated by the service call or the currently executed task enters the SUS PENDED state If a task in the WAITING state is placed in this situation it goes into the WAIT ING SUSPENDED state b Depends on the dv tsk slp tsk tslp tsk wai flg twai flg wai sem twai sem rcv mbx trcv mbx snd dtq tsnd dtq rcv dro trcv dro vtsnd dtq vsnd_dtq vtrev_dtq tget_mpf get mpf or vrcv_dtq service call R20UT0655bEJ0100 Rev 1 00 Page 21 of 295 Jun 01 2011 32 NE SAS M3T MR30 4 3 Introduction to Kernel The SUSPENDED state is
233. of 295 ztENESAS 12 Note 12 1 The Use of INT Instruction MR30 has INT instruction interrupt numbers reserved for issuing service calls as listed in Table 12 1 Interrupt Number Assignment For this reason when using software interrupts in a user application do not use interrupt numbers 32 through 40 and be sure to use some other numbers Table 12 1 Interrupt Number Assignment Interrupt No Service calls Used 32 Service calls that can be issued from only task context 33 Service calls that can be issued from only non task context Service calls that can be issued from both task context and non task context 34 ret_int service call 35 dis_dsp service call 36 loc_cpu iloc_cpu service call 37 ext_tsk service call 38 tsnd dro twai_flg visnd_diq service call 39 Reserved for future extension 40 Reserved for future extension 12 2The Use of registers of bank The registers of bank is 0 when a task starts on MR30 MR30 does not change the registers of bank in processing kernel You must pay attention to the followings e Don t change the registers of bank in processing a task e f an interrupt handler with registers of bank 1 have multiple interrupts of an interrupt handler with registers of bank 1 the program can not execute normally R20UT0655EJ0100 Rev 1 00 Page 277 of 295 Jun 01 2011 RENESAS M3T MR30 4 12 Note 12 3Regarding Delay Dispatching MR30 has four service ca
234. om non task context use ipol flg R20UT0655EJ0100 Rev 1 00 Page 113 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task UINT flgptn if wai flg ID flg2 FLGPTN OxOffO WE ANDW amp flgptn E OK error Wait Released n if pol flg ID flg2 FLGPTN Ox0ff0 TWF ORW amp flgptn E OK printf Not set EventFlag in if twai flg ID flg2 FLGPTIN OxOff0 TWF ANDW amp flgptn 5 E OK error Wait Released n lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM A0 R1 R3 wai Elo ID FLG1 40003H 4TWF ANDW PUSHM _ AO R1 R3 pol_flg ID_FLG2 0008H TWF_ORW PUSHM AO RO R1 R2 R3 MOV W 20 R0 MOV W 0 R2 twai flg ID_FLG3 0003H TWF_ANDW R20UT0655EJ0100 Rev 1 00 Page 114 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref flg Reference eventflag status iref flg Reference eventflag status handler only C Language API ER ercd ref flg ID flgid T RFLG pk rflg ER ercd iref flg ID flgid T RFLG pk rflg e Parameters ID flgid ID number of the target eventflag T RFLG pk rflg Pointer to the packet to which eventflag status is returned e Return Parameters ER ercd Termina
235. on This service call clears the data stored in the data queue indicated by dtqid If the data queue area has no more areas to be added and tasks are enqueued in a data transmission waiting queue all of the tasks enqueued in the data transmission waiting queue are released from WAITING state Furthermore the error code EV_RST is returned to the tasks that have been released from WAITING state Even when the number of data queues defined is 0 all of the tasks enqueued in a data transmission waiting queue are released from WAITING state This service call can be issued only from task context It cannot be issued from non task context R20UTO0655EJ0100 Rev 1 00 Page 198 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void taskl void vrst_dtq ID_dtql lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO vrst dtq FID_DTO1 R20UT0655EJ0100 Rev 1 00 Page 199 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference vrst_vdtq Clear Long data queue area C Language API ER ercd vrst_vdtq ID vdtgid Parameters ID vdtqid Long data queue ID to be cleared Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc v
236. only be written in assembly language When writing in assembly language make sure the statements at the entry and exit of the interrupt handler are written as shown below Always be sure to clear the B flag before issuing the ret int service call Example interrupt fset B fclr B ret int Internally in the MR30 kernel register banks are not switched over 2 Do not use NMI and watchdog timer interrupts in the kernel OS dependent interrupt R20UT0655EJ0100 Rev 1 00 Page 250 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator Table 8 3 Interrupt Causes and Vector Numbers Interrupt cause Interrupt vector number Section Name DMAO 8 INTERRUPT_VECTOR DMA1 9 INTERRUPT_VECTOR DMA2 10 INTERRUPT_VECTOR DMA3 11 INTERRUPT_VECTOR Timer AO 12 INTERRUPT_VECTOR Timer A1 13 INTERRUPT_VECTOR Timer A2 14 INTERRUPT_VECTOR Timer A3 15 INTERRUPT_VECTOR Timer A4 16 INTERRUPT_VECTOR UARTO transmit 17 INTERRUPT_VECTOR UARTO receive 18 INTERRUPT_VECTOR UART1 transmit 19 INTERRUPT_VECTOR UART1 receive 20 INTERRUPT_VECTOR Timer BO 21 INTERRUPT_VECTOR Timer B1 22 INTERRUPT_VECTOR Timer B2 23 INTERRUPT_VECTOR Timer B3 24 INTERRUPT_VECTOR Timer B4 25 INTERRUPT_VECTOR INT5 external interrupt 26 INTERRUPT_VECTOR INT4 external interrupt 27
237. owed to use it for the other purposes You should also note that this manual does not guarantee or permit the exercise of the right of software use 1 Hereinafter abbreviated real time OS ulTRON4 0 Specification is the open real time kernel specification upon which the TRON association decided The specification document of uITRON4 0 specification can come to hand from a TRON association homepage http www assoc tron org The copyright of uITRONA O specification belongs to the TRON association Contents Requirements Tor MAZO Use icant aie a ante dtd e TU HM RO RE ees Be ein ue ME l Right of Software Use ied oa aie ea a He ane i i d b Hee e eene eai E E A T AE A T lI IB dio IQUITOS uec LEE VIII Eu Teal REP x Tze User s Manual OrganlzatiOn direi e E DX ERR e n Ra aT EYE EET e ELA AER e ea ern iia 1 2 General nformation EEN 2 2 1 Objective of MR30 Development 2 2 2 Relationship between TRON Specification and MR20 sse 4 2 3 MR3Qkeatu res EE 4 EM Ha lio 0 Tante QUI 4 a WEE 5 3 1 Concept oFRealtiMeOS ciao e ere aia eee abe ee 5 3 1 1 Why Real time OS is Necessary teens enn nnns 5 3 1 2 Operating Principles of Kern 8 3 2 Service CIE 12 32 1 Service Call Processing iie itd eene Le UU IER ER EATER euge alone tee 13 3 2 2 Processing Procedures for Service Calls from Handlers sse 14 Service Calls from a Handler That Caused an Interrupt during Task Execution
238. pendent interrupt handler in C language observe the following precautions 1 Describe the kernel OS dependent interrupt handler as a function 2 Be sure to use the void type to declare the interrupt handler start function return value and argument 3 At the beginning of file be sure to include itron h kernel h which is in the system di rectory as well as kernel id h which is in the current directory Do not use the ret int service call in the interrupt handler 5 The static declared functions can not be registered as an interrupt handler include lt itron h gt include lt kernel h gt include kernel id h void inthand void process iwup_tsk ID_main Figure 7 3 Example of Kernel OS dependent Interrupt Handler 5 A configuration file is used to define the relationship between handlers and functions 5 When an kernel OS dependent interrupt handler is declared with pragma INTHANDLER code for the ret int service call is auto matically generated R20UT0655EJ0100 Rev 1 00 Page 211 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 1 3 Writing Non kernel OS independent Interrupt Handler When describing the non kernel OS independent interrupt handler in C language observe the following precautions 1 Be sure to declare the return value and argument of the interrupt handler start function as a void type 2 No service call can be issued from a non kernel an OS
239. plication ROM Start up program MR30 s ROM data the MR_ROM section C language I F routines the MR_CIF section Application programs the app_prog section Interrupt vector area the INTERRUPT_VECTOR section Fixed interrupt vector area FIX_INTERRUPT_VECTOR section 9999 e How to locate individual programs is given below Changing the section name of user program In dealing with application programs written in C language you change the section name of the programs to be located in the application ROM by use of pragma SECTION as shown below In NC30WA the section name of user program if not given turns to program section So you need to assign a different section name to the task you locate in the application ROM 75 You need not change the names of sections for tasks to be located int the kernel ROM R20UT0655EJ0100 Rev 1 00 Page 282 of 295 Jun 01 2011 RENESAS M3T MR30 4 13 Separate ROMs pragma SECTION program app_prog Changing section of program The section names of task2 and task3 turn to app_prog void task2 void void task3 void Locating sections Here you change the section files c_sec inc asm_sec inc and set addresses of programs you locate in the ap plication ROM In this instance the respective first addresses of the sections given below must agree with each other between two applications e MR30 s RAM data MR RAM MR_RAM_DBG section e MR HEAP section
240. previous one is specified the task is moved to behind the tail of the queue The smaller the number the higher the task priority with 1 assigned the highest priority The minimum value specifiable as priority is 1 The specifiable maximum value of priority is the maximum value of priority specified in a configuration file providing that it is within the range 1 to 255 For example if system specification in a configuration file is as fol lows system stack_size 0x100 priority 13 D I then priority can be specified in the range 1 to 13 If TSK SELF is specified the priority of the issuing task is changed If TSK SELF is specified for tskid in non task con text operation of the service call cannot be guaranteed If TPRI INI is specified the task has its priority changed to the initial priority that was specified when the task was created The changed task priority remains effective until the task is terminated or this service call is executed again If the task indicated by tskid is in DORMANT state it returns the error code E OBJ as a return value for the service call Since the M3T MR30 does not support the mutex function in no case will the error code E ILUSE be returned If this service call is to be issued from task context use chg pri if issued from non task context use ichg_ pri Example program statement lt lt Example statement in C language gt gt include itron h include kernel h include kern
241. pt priority level for system clock definition item exceeds the value of IPL within ser vice call of system definition item cfg30 Error system timer s vector lt x gt conflict near line xxx A different vector is defined for the system clock timer interrupt vector Confirm the vector No x for interrupt vector definition cfg30 Error XXXX is not defined xxxx cfg XXXX item must be set in your configuration file cfg30 Error system s default is not defined These items must be set int the default configuration file cfg30 Error double definition lt XXXX gt near line xxx xxx cfg XXXX is already defined Check and delete the extra definition cfg30 Error double definition XXXX x near line xxx default cfg cfg30 Error double definition XXXX x near line xxx xxxx cfg The ID number in item XXXX is already registered Modify the ID number or delete the extra definition cfg30 Error you must define XXXX near line xxx xxxx cfg XXXX cannot be omitted cfg30 Error you must define SYMBOL near line xxx xxxx cfg This symbol cannot be omitted cfg30 Error start up file XXXX not found The start up file XXXX cannot be found in the current directory The startup file start a30 or crtOmr a30 is required in the current directory cfg30 Error bad start up file XXXX There is unnecessary start up file in the current directory cfg30 Error no source file No source file is found in the current directory cfg3
242. pu 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 cpu within an interrupt handler the system must always be placed out of a CPU locked state by invoking iunl cpu before it returns from the interrupt handler The CPU locked state and the dispatching disabled state are managed independently of each other Therefore the system cannot be freed from a dispatching disabled state by the unl cpu or iunl cpu service call unless the ena dap service call is used If this service call is to be issued from task context use unl cpu if issued from non task context use iunl cpu Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task unl cpu lt lt Example statement in assembly language gt gt include mr30 inc GLB task task unl cpu R20UT0655EJ0100 Rev 1 00 Page 174 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference dis_dsp Disable dispatching C Language API ER ercd dis_dsp e Parameters None e Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc dis dap Parameters None e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK Error code
243. q ID dtq data 2 error Timeout An if vfsnd dtq ID dtq data 3 error error Nn ll Ed H IS o d H 10 E MOUT lt lt Example statement in assembly language gt gt include mr30 inc GLB task g dtq LONG 12345678H task PUSHM RO R1 R2 R3 A0 OV W g dtq R1 OV W _9_dtq 2 R3 OV W 100 R0 OV W 0 R2 vtsnd_dtq ID_DTQ1 PUSHM R1 R3 A0 OV W 1234H R1 OV W 5678H R3 vpsnd dtq ID DTO2 PUSHM R1 R3 A0 OV W 1234H R1 OV W 5678H R3 vfsnd_dtq ID_DTQ3 R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 RENESAS 5 Service call reference Page 191 of 295 M3T MR30 4 5 Service call reference vrcv dtq vprcv dtq viprcv dtq vircv_dtq C Language API ER ercd vrcv dtq ID dtqid W p data ER ercd vprcv dtq ID dtqid W p data ER ercd viprcv dtq ID dtgaid W p data ER ercd vtrcv dtq ID dtqid W p data TMO tmout Parameters Receive from Long data queue Receive from Long data queue polling Receive from Long data queue polling handler only Receive from Long data queue with timeout ID vdtqid ID number of the Long data queue from which to receive TMO tmout Timeout value vtrev_dtq W p data Pointer to the start of the area in which received data is stored e Return Parameters ER ercd Terminated normally E_OK or error code W p data Pointer to the start of the area in which received data is stored
244. queued activation request counts UINT wupent 416 2 Number of queued wakeup request counts UINT suscnt 418 2 Number of nested suspension request counts T RTSK Assembly language API include mr30 inc ref tsk TSKID PK RTSK iref tsk TSKID PK RTSK Parameters TSKID ID number of the target task PK RTSK Pointer to the packet to which task status is returned Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target task Al Pointer to the packet to which task status is returned Error code None R20UT0655EJ0100 Rev 1 00 Page 79 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Functional description This service call inspects the status of the task indicated by tskid and returns the current information on that task to the area pointed to by pk_rtsk as a return parameter If TSK_SELF is specified the status of the issuing task itself is in spected If TSK_SELF is specified for tskid in non task context operation of the service call cannot be guaranteed tskstat task status tskstat has one of the following values returned to it depending on the status of the specified task e TTS RUN 0x0001 RUNNING state e TTS RDY 0x0002 READY state e TTS WAI 0x0004 W AITING state e TTS SUS 0x0008 SUSPENDED state e TTS WAS 0x000C WAITING SUSPENDED state e TTS DMT 0x0010 DORMANT state tskpr
245. r assigned in order of numbers beginning with the smallest lt lt Content gt gt For each data queue ID number define the items described below 1 IDname Definition format Symbol Definition range None Default value None Define the name by which the data queue is specified in a program 2 Number of data Definition format Numeric Value Definition range 0 to OXGFFF Default value 0 Specify the number of data that can be transmitted What should be specified here is the number of data and not a data size 3 Selecting a data queue waiting queue Definition format Symbol Definition range TA TFIFO or TA TRPI Default value TA TFIFO Select a method in which tasks wait for data queue transmission If TA_TFIFO is selected tasks are enqueued in order of FIFO If TA TPRI is selected tasks are enqueued in order of priority beginning with the one that has the highest priority Long data queue definition This definition must always be set when the long data queue function is to be used lt lt Format gt gt Ndataqueue Definition vdataqueue ID No name ID name buffer size Number of data queues wait queue Select data queue waiting queue Ir The ID number must be in the range to 255 The ID number can be omitted If omitted ID numbers are automatically assigned in order of numbers beginning with the smallest
246. r READY state is placed in the RUNNING state and the execution of that task starts 2 READY state The READY state refers to the situation in which the task that meets the task execution conditions is still wait ing for execution because a different task having a higher priority is currently being executed By issuing dly_tsk slp tsk tslp tsk wai flg twai flg wai sem twai sem rcv mbx trev_mbx snd_dtq tsnd_dtq rcv_dta trev_dta vtsnd dtq vsnd dtq vtrcv dtq vrcv dtq get mpf and tget mpf service call R20UT0655EJ0100 Rev 1 00 Page 20 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel When any of the following conditions occurs the READY task that can be executed second according to the ready queue is placed in the RUNNING state 4 4 A currently executed task has normally terminated itself by ext_tsk service call A currently executed task has placed itself in the WAITING state A currently executed task has changed its own priority by chg_ pri or ichg pri service call so that the priority of a different READY task is rendered higher Due to interruption or other event occurrence the priority of a currently executed task has been changed so that the priority of a different READY task is rendered higher When the ready queue of the issuing task priority is rotated by the rot rdq or irot rdq ser vice call and control of execution is thereby abandoned 3 WAITING state When a task in
247. r only 89 rel wai Release task from waiting nennen nennen nennen nen 91 ire wai Release task from waiting handler ov 91 sus tsk Suspend task creer yaaya ais 93 isus tsk Suspend task handler only ssssssssssssesseeeenee nennen nnne 93 rsm tsk Resume suspended task eeseseeesssseseeeeeeee ener nnne nnnm nennen teniente nn 95 irsm tsk Resume suspended task handler ov 95 frsm tsk Forcibly resume suspended task AAA 95 ifrsm tsk Forcibly resume suspended task handler only 95 dly tsk Delay task epe eine e ere iei n beati re a ba 97 5 3 Synchronization amp Communication Function Semaphore eese 99 sig sem Release semapborereeource enne enne enne nennen nnne 100 isig sem Release semaphore resource handler only sse 100 wai sem Acquire semaphore reeource enne nennen nnne nnn enne nennen 102 pol sem Acquire semaphore resource polling seseseeeeeeneeenenennen nennen 102 ipol sem Acquire semaphore resource polling handler only eese 102 twai sem Acquire semaphore resource with meurt 102 ref sem Reference semaphore status enne nennen nnne nnne nre 105 iref sem Reference semaphore status handler only 105 5 4 Synchronization amp Communication Function Eventflag 107 set flg Set eventflag EE 108 iset flg Set eventflag handler only nennen nnne nennen nnne 108 erotig ee e E DEE 110 idr flg Clear ev
248. ram is stored e MR CIF section This section stores the MR30 C language interface library e MH ROM section This section stores data such as task start addresses that area referenced by the MR30 kernel e NTERRUPT VECTOR section e FIX INTERRUPT VECTOR section This section stores interrupt vectors The start address of this section varies with the type of M16C 60 series microcomputer used The address in the sample startup program is provided for use by the M16C 60 series micro computers This address must be modified if you are using a microcomputer of some other group R20UT0655EJ0100 Rev 1 00 Page 226 of 295 Jun 01 2011 RENESAS 8 Using Configurator 8 1 Configuration File Creation Procedure When applications program coding and startup program modification are completed it is then necessary to register the applications program in the MR30 system This registration is accomplished by the configuration file 8 1 1 Configuration File Data Entry Format This chapter describes how the definition data are entered in the configuration file Comment Statement A statement from to the end of a line is assumed to be a comment and not operated on End of statement Statements are terminated by Numerical Value Numerical values can be entered in the following format 1 Hexadecimal Number Add Ox or OX to the beginning of a numerical value or h or H to the end If the value
249. re is any task waiting to send data i e data bytes in the data queue area 0 data for the task at the top of the data transmission waiting queue is received As a result the task kept waiting to send that data is released from WAITING state On the other hand if rev_dtq or trev_dtq is issued for the data queue which has no data stored in it the task that issued the service call goes from RUNNING state to a data reception wait state and is enqueued in a data reception waiting queue At this time the task is enqueued in order of FIFO For the prev_dtq and iprcv dtq service calls the task returns immediately and responds 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 Ox 7fffffff time tick If any value exceeding this limit is specified the service call may not operate correctly If TMO POL O is specified for tmout it means specifying 0 as a timeout value in which case the service call operates the same way as prcv dtq Furthermore if specified as tmoutZTMO FEVR 1 it means specifying an infinite wait in which case the service call operates the same way as rcv d The task placed into a wait state by execution of the rcv dtq or trev_dtq service call is released from the wait state in the following cases When the rcv dtq trcv dtq prcv dtq or iprcv dtq service call is issued before the tmout time elapses with task
250. resumes suspended O O O O 14 ifrsm_tsk task O O O O 15 dly_tsk S Delays task O O O Notes e S Standard profile service calls Each sign within System State is a following meaning T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Page 84 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference slp tsk Put task to sleep tslp tsk Put task to sleep with timeout C Language API ER ercd slp tsk ER ercd tslp tsk TMO tmout e Parameters slp tsk None tslp tsk TMO tmout Timeout value e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc slp_tsk tslp tsk e Parameters None Register contents after service call is issued tslp tsk Register name Content after service call is issued RO Terminated normally E OK or error code RI Timeout value 16 low order bits R3 Timeout value 16 high order bits slp_tsk Register name Content after service call is issued RO Terminated normally E_OK or error code Error code E_TMOUT Timeout E_RLWAI Forced release from waiting 2 R3 Timeout value16 high order bits R1 Timeout value16 low order bits must be set before calling sevice call
251. right C 1996 1997 2011 include lt itron h gt include kernel h include kernel_id h include lt stdio h gt PREP BWNHRPOOMIAUBRWNE 16 void main VP INT stacd 17 18 sta tsk ID task1 0 19 sta tsk ID task2 0 20 Sta Cyc ID cyh1 21 22 void task1 VP INT stacd 23 24 while 1 25 wai sem ID seml 26 slp tsk 27 printf taskl runni 28 sig_sem ID_seml1 30 32 void task2 VP_INT stacd 33 34 while 1 35 wai sem ID seml 36 printf task2 runni 37 sig sem ID seml1 39 41 void cyhl VP INT exinf 42 43 iwup_tsk ID_task1l 44 R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 ample program 10 Sample Program Description kk AK Ck kk kk e RR RR Ck Ck Ck Kk e Kk Kk kk e kk kk Ck kk kk I kk ke ke e ke Renesas Electronics Corporation and Renesas Solutions Corp All rights reserved ng n ng n 2tENESAS Id demo c 695 2011 06 02 07 40 24Z toshiyuki inui xk renesas com FARA A A AAR AR AIR A KCKCKCk KCKCKCKCKCKCKCk KCKCKCkCKCKCKCkCkCKCkCkCkCkCk kck ck AA AA A A A A ke e ke X e x f Page 265 of 295 M3T MR30 4 10 Sample Program Description 10 3Configuration File T J A hkk kkkk kk kk kkk kkk kkk RR RR kkk kkk k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k k 2 3 Copyright C 1996 1997 2011 Renesas Electronics Corporation 4 and Renesas Solutions Corp All rights reserved
252. ription This service call returns TRUE when the system is in a CPU locked state or returns FALSE when the system is in a CPU unlocked state This service call can also be invoked from a CPU locked state Example program statement lt lt Example statement in C language include lt itron h gt include lt kernel h gt include kernel_id h void task BOOL stat stat sns_loc lt lt Example statement in assembly language gt gt include mr30 inc GLB task task sns loc R20UT0655EJ0100 Rev 1 00 Page 179 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sns_dsp Reference dispatching state C Language API BOOL state sns_dsp e Parameters None Return Parameters BOOL state TRUE Dispatching disabled state FALSE Dispatching enabled state Assembly language API include mr30 inc sns dsp Parameters None e Register contents after service call is issued Register name Content after service call is issued RO TRUE Dispatching disabled state FALSE Dispatching enabled state Error code None Funcional description This service call returns TRUE when the system is in a dispatching disabled state or returns FALSE when the system is in a dispatching enabled state This service call can also be invoked from a CPU locked state Example program statement Example statement in C language gt gt include lt itron h g
253. rogram SYS INITIAL that is activated immediately after a reset 69 249 in Figure 7 11 Setting the System Stack pointer 73 in Figure 7 11 Setting the processor mode register 75 77 in Figure 7 11 Setting the SB FB register 79 81 in Figure 7 11 Initial set the C language 100 126 in Figure 7 11 Setting OS interrupt disable level 142 144 in Figure 7 11 Setting the address of interrupt vector table 145 and 146 in Figure 7 11 Set MR30 s system clock interrupt 152 158 in Figure 7 11 Initialization of standard UO function 134 135 in Figure 7 11 hen using no standard input output functions remove the lines 134 and 135 in Figure 7 11 Initial set MR30 s system timer 165 167 in Figure 7 11 Initial set parameters inherent in the application 175 in Figure 7 11 Initialize the RAM data used by MR30 182 235 in Figure 7 11 Sets the bit which shows the end of start up processing 239 in Figure 7 11 Activate the initial startup task 245 248 in Figure 7 11 10 This is a system clock interrupt handler 282 291 in Figure 7 11 rezo ror o o t m cm R20UT0655EJ0100 Rev 1 00 Page 224 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 4 Memory Allocation This section describes how memory is allocated for the application program data The sections which are used by MR30 is describe in c_sec inc or asm_sec inc To set the memory arrangement it changes on High performance Embedded Workshop MR30 com
254. rror code E OK is returned However tasks are not switched over until delay dispatching is cleared The task to be executed after disabled dispatching is re enabled is linked to the ready queue 3 rot rdq irot rdq during dispatch delay When rot rdq TPRI RUN 0 is issued during dispatch delay the ready queue of the own task s priority is rotated Also when irot rdq TPRI RUN 0 is issued the ready queue of the executed task s priority is ro tated In this case the task under execution may not always be linked to the ready queue Such as when isus tsk is issued to the executed task during dispatch delay 4 Precautions e No service call e g slp tsk wai sem can be issued that may place the own task in a wait state while in a state where dispatch is disabled by dis dsp loc cpu or iloc cpu e ena dsp and dis dsp cannot be issued while in a state where interrupts and dispatch are disabled by loc cpu iloc cpu e Disabled dispatch is re enabled by issuing ena dsp once after issuing dis dsp several times The above status transition can be summarized in Table 3 3 R20UT0655EJ0100 Rev 1 00 Page 278 of 295 Jun 01 2011 RENESAS M3T MR30 4 12 Note 12 4Regarding Initially Activated Task MR30 allows you to specify a task that starts from a READY state at system startup In a word TA_STA is added as a task attribute This specification is set with the configuration file Refer to 8 1 2 for details on how to set
255. rst vdtq VDTOID Parameters VDTQID Long data queue ID to be cleared e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E_OK AO Long data queue ID to be cleared Error code None Functional description This service call clears the data stored in the Long data queue indicated by vdtqid If the Long data queue area has no more areas to be added and tasks are enqueued in a data transmission waiting queue all of the tasks enqueued in the data transmission waiting queue are released from WAITING state Furthermore the error code EV RST is returned to the tasks that have been released from WAITING state Even when the number of Long data queues defined is 0 all of the tasks enqueued in a data transmission waiting queue are released from WAITING state This service call can be issued only from task context It cannot be issued from non task context R20UTO0655EJ0100 Rev 1 00 Page 200 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void taskl void vrst vdtq ID_vdtql lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO vrst vdtq ID VDTOl R20UT0655EJ0100 Rev 1 00 Page 201 of 295 Jun 01 2011 RENESAS
256. rupt multiplex interrupt during handler exe cution 7 The service call can t be issued from OS independent handler Therefore The handler described here does not include the OS independent handler R20UT0655EJ0100 Rev 1 00 Page 14 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Service Calls from a Handler That Caused an Interrupt during Task Execution Scheduling task switching is initiated by the ret int service call See Figure 3 11 TaskA Interrupt handler OS Interrupt Save Registers Service call processing Restore Registers ret_int Task selection SP lt User Scheduler TaskB Restore Registers Figure 3 11 Processing Procedure for a Service Call a Handler that caused an interrupt during Task Execution 8 The ret int service call is issued automatically when OS dependent handler is written in C language when pragma INTHANDLER specified R20UT0655EJ0100 Rev 1 00 Page 15 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Service Calls from a Handler That Caused an Interrupt during Service Call Processing Scheduling task switching is initiated after the system returns to the interrupted service call processing See Figure 3 12 TaskA OS Interrupt handler wup tsk Save Registers SP lt System Interrupt i Service call processing Restore Registers Task selection ret int SP
257. s and the specified timeout value is 40 ms then the timer times out at the fifth oc 5 get tim service call 2 set tim service call 7 SUSPENDED state is not included Ss Strictly in a dly_tsk service call the timeout value is not correct delay time is correct Strictly in a dly_tsk service call a timeout is not carried out but the waiting for delay is canceled and the service call carries out the normal end R20UT0655EJ0100 Rev 1 00 Page 54 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel currence of the time tick Similarly if the time tick interval is 5 ms and the specified timeout value is 15 ms then the timer times out at the fourth occurrence of the time tick 3 If the timeout value is not a multiple of time tick interval The timer times out at the timeout value time tick interval second time tick For example if the time tick interval is 10 ms and the specified timeout value is 35 ms then the timer times out at the fifth occurrence of the time tick Set System Time set_tim iset_tim Reference System Time get tim iget tim The system time indicates an elapsed time from when the system was reset by using 48 bit data The time is ex pressed in ms units R20UT0655EJ0100 Rev 1 00 Page 55 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 10 Cyclic Handler Function The cyclic handler is a time event handler that is started every startup cycle after a specified startup phase has
258. s dsp R20UT0655EJ0100 Rev 1 00 Page 176 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ena_dsp Enables dispatching C Language API ER ercd ena_dsp Parameters None e Return Parameters ER ercd Terminated normally E_OK Assembly language API include mr30 inc ena dsp e Parameters None e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK Error code None Functional description This service call frees the system from a dispatching disabled state that was set by the dis dsp service call As a result task scheduling is resumed when the system has entered a task execution state Invoking this service call from a task execution state does not cause an error in which case task queuing is not performed however This service call can be issued only from task context It cannot be issued from non task context Example program statement lt lt Example statement in C language include lt itron h gt include lt kernel h gt include kernel_id h void task ena dsp lt lt Example statement in assembly language gt gt include mr30 inc GLB task task ena_dsp R20UTO655EJ0100 Rev 1 00 Page 177 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sns_ctx Reference context C Language API BOOL state sns_ctx e Parame
259. s service call is to be issued from task context use stp alm if issued from non task context use istp alm Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task stp_alm ID_alml lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO stp alm ID_ALM1 R20UT0655EJ0100 Rev 1 00 Page 164 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref alm Reference alarm handler status iref alm Reference alarm handler status handler only C Language API ER ercd ref alm ID almid T RALM pk ralm ER ercd iref alm ID almid T RALM pk ralm e Parameters ID almid ID number of the target alarm handler T RALM pk ralm Pointer to the packet to which alarm handler status is returned e Return Parameters ER ercd Terminated normally E OK T RALM pk ralm Pointer to the packet to which alarm handler status is returned Contents of pk ralm typedef struct t ralm STAT almstat 0 2 Operating status of alarm handler RELTIM lefttim 2 4 This service call returns various statuses of the alarm handler indicat T RALM Assembly language API include mr30 inc ref alm ALMID PK RALM iref alm ALMID PK RALM Parameters ALMID ID number of the target alarm handler PK RALM Pointer to the packet to which alarm handler status is
260. service call is issued RO Terminated normally E OK AO ID number of the target mailbox Al Pointer to the packet to which mailbox status is returned Error code None Functional description This service call returns various statuses of the mailbox indicated by mbxid wtskid Returned to wtskid is the ID number of the task at the top of a reception waiting queue the next task to be de queued If no tasks are kept waiting TSK NONE is returned pk msg Returned to pk msg is the start address of the next message to be received If there are no messages to be re ceived next NULL is returned T MSG should be specified with a 16 bit address If this service call is to be issued from task context use ref mbx if issued from non task context use iref mbx R20UT0655EJ0100 Rev 1 00 Page 132 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RMBX rmbx ER ercd ercd ref mbx ID MBX1 amp rmbx lt lt Example statement in assembly language gt gt include mr30 inc GLB task _ refmbx blkb 6 task PUSHM A0 A1 ref_mbx ID_MBX1 _refmbx R20UT0655bEJ0100 Rev 1 00 Page 133 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 7 Memory Pool Management Function Fixed size
261. shown in Figure 3 8 This figure shows the state prevailing after register storage R20UTO0655EJ0100 Rev 1 00 Page 10 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Register not stored Key input Register stored SFR Key input task stack Figure 3 8 Actual Register and Stack Area Management R20UT0655EJ0100 Rev 1 00 Jun 01 2011 RENESAS Page 11 of 295 M3T MR30 4 3 Introduction to Kernel 3 2 Service Call How does the programmer use the kernel functions in a program First it is necessary to call up kernel function from the program in some way or other Calling a kernel function is re ferred to as a service call Task activation and other processing operations can be initiated by such a service call See Figure 3 9 Key input Recte contra Task as Service call Task switching Figure 3 9 Service call This service call is realized by a function call when the application program is written in C language as shown below act_tsk ID_main 3 Furthermore if the application program is written in assembly language it is realized by an assembler macro call as shown below act tsk ID_main R20UT0655EJ0100 Rev 1 00 Page 12 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 2 1 Service Call Processing When a service call is issued processing takes place in the following sequence 1 The current register contents are saved 2 The sta
262. snd dtq DTQID DTOQDATA fsnd dtq DTQID DTQDATA ifsnd dtq DTOID DTQDATA e Parameters DTQID ID number of the data queue to which transmitted DTQDATA Data to be transmitted e Register contents after service call is issued snd dtq psnd dtq ipsnd dtq fsnd dtq ifsnd dra Register name Content after service call is issued RO Terminated normally E OK or error code R1 Data to be transmitted AO ID number of the data queue to which transmitted tsnd_dtq Register name Content after service call is issued RO Terminated normally E_OK or error code R1 Data to be transmitted R2 Timeout value 16 high order bits AO ID number of the data queue to which transmitted SS R2 Timeout value16 high order bits RO Timeout value16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 118 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Error code E_RLWAI Forced release from waiting E_TMOUT Polling failure or timeout or timed out E_ILUSE Service call improperly used fsnd_dtq or ifsnd_dtq is issued for a data queue whose dtqent 0 EV_RST Released from WAITING state by clearing of the data queue area Functional description This service call sends the 2 byte data indicated by data to the data queue indicated by dtqid If any task is kept waiting for reception in the target data queue the data is not stored in the data queue and instead
263. software maintainability is provided because developed software maintenance can be car ried out simply by maintaining small tasks 6 Increased software reliability is assured The introduction of the real time OS makes it possible to carry out program evaluation and testing in the unit of a small module called task This feature facilitates evaluation and testing and increases software reliability 7 The microcomputer performance can be optimized to improve the performance of microcom puter based products With the real time OS it is possible to decrease the number of unnecessary microcomputer operations such as I O waiting It means that the optimum capabilities can be obtained from microcomputers and this will lead to microcomputer based product performance improvement R20UT0655EJ0100 Rev 1 00 Page 3 of 295 Jun 01 2011 RENESAS M3T MR30 4 2 General Information 2 2 Relationship between TRON Specification and MR30 MR30 is the real time operating system developed for use with the M16C 10 M16C 20 M16C 30 M16C 60 M16C Tiny and R8C Tiny series of 16 bit microcomputers compliant with uITRON 4 0 Specification uITRON 4 0 Specification stipulates standard profiles as an attempt to ensure software portability Of these standard profiles MR30 has implemented in it all service calls except for static APIs and task exception APIs 2 3 MR30 Features The MR30 offers the following features 1 Real time operating system conforming
264. ss of a task When written in the C language add at the end or at the beginning of the function name you have defined The function name defined here causes the following declaration statement to be output in the kernel id h file pragma TASK Function Name R20UT0655EJ0100 Rev 1 00 Page 236 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 3 User stack size of task Definition format Numeric value Definition range 6 or more Default value 256 Define the user stack size for each task The user stack means a stack area used by each individual task MR30 requires that a user stack area be allocated for each task which amount to at least 12 bytes 4 Initial priority of task Definition format Numeric value Definition range 1 to maximum value of priority in system definition Default value 1 Define the priority of a task at startup time As for MR30 s priority the lower the value the higher the priority 5 Registers Used Definition format Symbol Symbol Definition range Selected from RO R1 R2 R3 A0 A1 SB FB Default value All registers Define the registers used in a task MR30 handles the register defined here as a context Specify the RO register because task startup code is set in it when the task starts 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
265. startup time of day is determined by a time of day relative to the time of day set by sta_alm ista_alm and is unaffected by a change in the time of day by set_tim iset_tim The cyclic and alarm handlers are invoked by a subroutine call from the system clock interrupt timer interrupt handler Therefore cyclic and alarm handlers operate as part of the system clock interrupt handler Note that when the cyclic or alarm handler is invoked it is executed in the interrupt priority level of the system clock interrupt R20UT0655EJ0100 Rev 1 00 Page 27 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel Task System clock interrupt handler Cydic handler Alarm handler Subroutine call Timer interrupt Figure 3 21 Cyclic Handler Alarm Handler Activation R20UT0655EJ0100 Rev 1 00 Page 28 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 5 2 Dispatch Enabled Disabled States The system assumes either a dispatch enabled state or a dispatch disabled state In a dispatch disabled state no task scheduling is performed Nor can service calls be invoked that may cause the service call issuing task to enter a wait 16 state The system can be placed into a dispatch disabled state or a dispatch enabled state by the dis_dsp or ena_dsp service call respectively Whether the system is in a dispatch disabled state can be known by the sns_dsp service call 3 5 3 CPU Locked Unlocked States The syst
266. startup programs as described below e start a30 This startup program is used when you created a program using the assembly language e crt mr a30 This startup program is used when you created a program using the C language This program is derived from start a30 by adding an initialization routine in C language The startup programs perform the following e Initialize the processor after a reset e Initialize C language variables crtOmr a30 only e Set the system timer Initialize MR30 s data area Copy these startup programs from the directory indicated by environment variable LIB30 to the current directory If necessary correct or add the sections below Setting processor mode register Set a processor mode matched to your system to the processor mode register 75th line in crtOmr a30 e Adding user required initialization program When there is an initialization program that is required for your application add it to the 175th line in the C language startup program crtOmr a30 Initialization of the standard I O function Comment out the 134th 135th line in the C language startup program crtOmr a30 if no standard I O func tion is used R20UT0655EJ0100 Rev 1 00 Page 219 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 3 1 C Language Startup Program crtOmr a30 Figure 7 11 shows the C language startup program crtOmr a30 7 Detailed Applications
267. suing task is rotated TPRI SELF cannot be specified in the mot rdq service call TPRI SELF cannot be specified by mot rdq service call However an error is not returned even if it is specified If the priority of the issuing task itself is specified in this service call the issuing task is relocated to behind the tail of the ready queue in which it is enqueued Note that if the ready queue of the specified priority has no tasks in it no operation is performed If this service call is to be issued from task context use rot rdq if issued from non task context use irot_rdq Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task rot rdq 2 lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM R3 rot rdq 2 R20UT0655EJ0100 Rev 1 00 Page 169 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference get_tid Reference task ID in the RUNNING state iget_tid Reference task ID in the RUNNING state handler only C Language API ER ercd get_tid 1D p_tskid ER ercd iget_tid ID p_tskid e Parameters ID p_tskid Pointer to task ID Return Parameters ER ercd Terminated normally E_OK ID p_tskid Pointer to task ID Assembly language API include mr30 inc get tid iget tid Parameters None e Register contents after ser
268. sumption ssssseseeeeeenenene 9 Figure 3 o Ee e ln DEET 9 Figure 3 7 Task Register Area cnet edge de eet iere Ete E ne e EE te OR ENEE 10 Figure 3 8 Actual Register and Stack Area Management AA 11 le te 12 Figure 3 10 Service Call Processing Flowchart sss eene enne nnn nnne nnns 13 Figure 3 11 Processing Procedure for a Service Call a Handler that caused an interrupt during Task Execution 15 Figure 3 12 Processing Procedure for a Service Call from a Handler that caused an interrupt during Service Call Processi gitse an a aaa esee rr 16 Figure 3 13 Processing Procedure for a service call from a Multiplex interrupt Handler 17 Figure 3 14 Task Identification imsi i aa aaa aa a a aa aaa nnne entren nnns nens 18 Figure 3 15 Task E TE 19 Figure 3 16 MR30 Task Status Transition 20 Figure 3 17 Ready Queue Execution Queue eee eene enne nnne ns 23 Figure 3 18 Waiting queue of the TA_TPRI attribute nennen nnns 24 Figure 3 19 Waiting queue of the TA_TFIFO attribute nennen 24 Figure 3 20 Task control block etd Ete HE e e EE e e 26 Figure 3 21 Cyclic Handler Alarm Handler Activation esses 28 Figure 3 22 Interrupt handler IPLs essssssesesessseeese ener enne entren ennt nn nnn nentes 30 Figure 3 23 Interrupt control in a Service Call that can be Issued from only a Task 31 Figure 3 24 Interrupt control in a Service Call th
269. t include lt kernel h gt include kernel_id h void task BOOL stat stat sns_dsp lt lt Example statement in assembly language gt gt include mr30 inc GLB task task sns dsp R20UT0655EJ0100 Rev 1 00 Page 180 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sns_dpn Reference dispatching pending state C Language API BOOL state sns dpn e Parameters None Return Parameters BOOL state TRUE Dispatching pending state FALSE Not dispatching pending state Assembly language API include mr30 inc sns dpn Parameters None e Register contents after service call is issued Register name Content after service call is issued RO TRUE Dispatching pending state FALSE Not dispatching pending state Error code None Funcional description This service call returns TRUE when the system is in a dispatching pending state or returns FALSE when the system is not in a dispatching pending state More specifically FALSE is returned when all of the following conditions are met otherwise TRUE is returned 1 The system is not in a dispatching pending state 2 The system is not in a CPU locked state 3 The object made pending is a task This service call can also be invoked from a CPU locked state It returns TRUE when the system is in a dispatching dis abled state or returns FALSE when the system is in a dispatching enabled state
270. t gt O0 printf wupcnt d n wupcnt lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO can_wup FID_TASK3 R20UT0655EJ0100 Rev 1 00 Page 90 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference rel_wai Release task from waiting irel_wai Release task from waiting handler only C Language API ER ercd rel_wai ID tskid ER ercd irel wai ID tskid e Parameters ID tskid ID number of the target task e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc rel wai TSKID irel wai TSKID e Parameters TSKID ID number of the target task e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK or error code AO ID number of the target task Error code E OBJ Object status invalid task indicated by tskid is not an wait state Functional description This service call forcibly release the task indicated by tskid from waiting except SUSPENDED state to place it into READY or RUNNING state The forcibly released task returns the error code E RLWAI If the target task has been en queued in some waiting queue the task is dequeued from it by execution of this service call If this service call is issued to a task in WAITING SUSPENDED state the target task is released from WAITING state and goes to S
271. t included wait state 999999999 R20UT0655EJ0100 Rev 1 00 Page 42 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel e Delay task dly_tsk Keeps a task waiting for a finite length of time Figure 4 9 shows an example in which execution of a task is kept waiting for 10 ms by the dly_tsk service call The timeout value should be specified in ms units and not in time tick units dly tsk 10 Tak Eege 4 amp 4 l0mse _______ Figure 4 9 dly tsk service call R20UT0655EJ0100 Rev 1 00 Page 43 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 3 Synchronization and Communication Function Semaphore The semaphore is a function executed to coordinate the use of devices and other resources to be shared by several tasks in cases where the tasks simultaneously require the use of them When for instance four tasks simultaneously try to acquire a total of only three communication lines as shown in Figure 4 10 communication line to task connections can be made without incurring contention Communication Line Communication Line Communication Line x Figure 4 10 Exclusive Control by Semaphore The semaphore has an internal semaphore counter In accordance with this counter the semaphore is acquired or released to prevent competition for use of the same resource See Figure 4 11 Acquired Returned after use Figure 4 11 Semaphore Counter The MR30 kernel offers the following semaphore sy
272. t system time is returned e Return Parameters ER ercd Terminated normally E_OK SYSTIM p_systim Pointer to the packet to which current system time is returned Contents of p_systim typedef struct t_systim UH utime 0 2 16 high order bits UW time 4 4 32 low order bits SYSTIM Assembly language API include mr30 inc get_tim PK_TIM iget_tim PK_TIM e Parameters PK_TIM Pointer to the packet to which current system time is returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E_OK AO Pointer to the packet to which current system time is returned Error code None Functional description This service call stores the current value of the system time in p systim If this service call is to be issued from task context use get tim if issued from non task context use iget tim R20UT0655EJ0100 Rev 1 00 Page 152 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task SYSTIME time Time data storing variable get_tim amp time Refers to the system time lt lt Example statement in assembly language gt gt include mr30 inc GLB task _g_systim blkb 6 task PUSHM AO get tim 4 g systim
273. ta 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 ezed ezed ezed Task A Task B Figure 4 14 Data queue Data in width of 16 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 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 MR30 kernel e 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 e Send to Data Queue psnd dtq ipsnd dro 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 dro 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 e Receive from Data Queue rcv dro trev_dtq The data is retrieved from the data queue If the data q
274. task Context Table 3 1 Task Context and Non task Context Task context Non task context Invocable service call Those that can be invoked from Those that can be invoked from task context non task context Task scheduling Occurs when the queue state has It does not occur changed to other than dispatch dis abled and CPU locked states Stack User stack System stack The processes executed in non task context include the following 1 Interrupt Handler A program that starts upon hardware interruption is called the interrupt handler The MR30 is not concerned in interrupt handler activation Therefore the interrupt handler entry address is to be directly written into the interrupt vector table There are two interrupt handlers Non kernel 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 these interrupt handlers 2 Cyclic Handler The cyclic handler is a program that is started cyclically every preset time The set cyclic handler may be started or stopped by the sta_cyc ista_cyc or stp_cyc istp_cyc service call The cyclic handler startup time of day is unaffected by a change in the time of day by set_tim iset_tim 3 Alarm Handler The alarm handler is a handler that is started after the lapse of a specified relative time of day The alarm handler
275. task with small priority value is executed Task Management Module Exercises the management of various task states such as the RUNNING READY WAIT and SUSPENDED state Task Synchronization Module Accomplishes inter task synchronization by changing the task status from a different task Interrupt Management Module Makes a return from the interrupt handler Time Management Module Sets up the system timer used by the MR30 kernel and starts the user created alarm handler and cyclic han dler System Status Management Module Gets the system status of MR30 System Configuration Management Module Reports the MR30 kernel version number or other information Sync Communication Module This is the function for synchronization and communication among the tasks The following three functional modules are offered Eventflag Checks whether the flag controlled within the MR30 is set up and then determines whether or not to initi ate task execution This results in accomplishing synchronization between tasks Semaphore Reads the semaphore counter value controlled within the MR30 and then determines whether or not to initiate task execution This also results in accomplishing synchronization between tasks Mailbox Provides inter task data communication by delivering the first data address Data queue Performs 16 bit data communication between tasks Memory pool Management Module Provides dynamic allocation or release of a
276. ted normally E OK T RFLG pk rflg Pointer to the packet to which eventflag status is returned Contents of pk rflg typedef struct t rflg ID wtskid 0 2 Reception waiting task ID FLGPTN flgptn 2 2 Current eventflag bit pattern T_RFLG Assembly language API include mr30 inc ref flg FLGID PK RFLG iref flg FLGID PK RFLG Parameters FLGID ID number of the target eventflag PK RFLG Pointer to the packet to which eventflag status is returned Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target eventflag Al Pointer to the packet to which eventflag status is returned Error code None Functional description This service call returns various statuses of the eventflag indicated by flgid wtskid Returned to wtskid is the ID number of the task at the top of a waiting queue the next task to be dequeued If no tasks are kept waiting TSK NONE is returned 9 figptn Returned to flgptn is the current eventflag bit pattern If this service call is to be issued from task context use ref_flg if issued from non task context use iref_flg R20UT0655EJ0100 Rev 1 00 Page 115 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kerne
277. tem time O OO oO 4 iset tim oOlololo 5 isig_tim S Supply a time tick oOlololo Notes e Il Standard profile service calls Each sign within System State is a following meaning T Can be called from task context N Can be called from non task context 9999 E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 32 NE SAS Page 149 of 295 M3T MR30 4 5 Service call reference set_tim Set system time iset_tim Set system time handler only C Language API ER ercd set_tim SYSTIM p_systim ER ercd iset_tim SYSTIM p_systim e Parameters SYSTIM p_systim Pointer to the packet that indicates the system time to be set Contents of p_systim typedef struct t_systim UH utime 0 2 16 high order bits UW time 4 4 32 low order bits SYSTIM e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc set tim PK TIM iset tim PK TIM e Parameters PK TIM Pointer to the packet that indicates the system time to be set Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO Pointer to the packet that indicates the system time to be set Error code None Functional description This service
278. ters None e Return Parameters BOOL state TRUE Non task context FALSE Task context Assembly language API include mr30 inc sns_ctx Parameters None e Register contents after service call is issued Register name Content after service call is issued RO TRUE Non Task context FALSE Task context Error code None Funcional description This service call returns TRUE when it is invoked from non task context or returns FALSE when invoked from task con text This service call can also be invoked from a CPU locked state Example program statement Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task BOOL stat stat sns_ctx lt lt Example statement in assembly language gt gt include mr30 inc GLB task task sns ctx R20UT0655EJ0100 Rev 1 00 Page 178 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference sns_loc Reference CPU state C Language API BOOL state sns_loc e Parameters None e Return Parameters BOOL state TRUE CPU locked state FALSE CPU unlocked state E Assembly language API include mr30 inc sns loc Parameters None e Register contents after service call is issued Register name Content after service call is issued RO TRUE CPU locked state FALSE CPUCPU unlocked state Error code None Funcional desc
279. the PC SB RO and FLG registers 5 To specify a task use the string written in the task definition item name of the configu ration file wup tsk ID_task 6 To specify an event flag semaphore or mailbox use the respective strings defined in the configuration file For example if a semaphore is defined in the configuration file as shown below semaphore 1 name abc y To specify this semaphore write your specification as follows sig sem ID_abc 2 Use the GLB pseudo directive R20UT0655EJ0100 Rev 1 00 Page 214 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 To specify a cyclic or alarm handler use the string written in the cyclic or alarm handler definition item name of the configuration file For example if you want to specify a cyclic handler cyc write your specification as follows sta cyc ID_cyc 8 Seta task that is activated at MR30 system startup in the configuration file 9 The relationship between task ID numbers and tasks program is defined in the configuration file R20UT0655EJ0100 Rev 1 00 Page 215 of 295 Jun 01 2011 RENESAS M3T MR30 4 7 Detailed Applications 7 2 2 Writing Kernel OS dependent Interrupt Handler When describing the kernel OS dependent interrupt handler in assembly language observe the following precautions 1 At the beginning of file be sure to include mr30 inc which is in the system directory 2 For the symbol indicatin
280. the task will be kept waiting perpetually with the service call operating the same way as slp tsk The values specified for tmout must be within Ox7fffffff time tick If any value exceeding this limit is specified opera tion of the service call cannot be guaranteed This service call can only be issued from task context and cannot be issued from non task context Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task if slp_tsk E_OK error Forced wakeup n if tslp_tsk 10 E_TMOUT error time outin lt lt Example statement in assembly language gt gt include mr30 inc GLB task task slp_tsk PUSHM f R1 R3 tslp_tsk TMO_FEVR PUSHM R1 R3 MOV W 100 R1 MOV W 0 R3 tslp_tsk R20UT0655EJ0100 Rev 1 00 Page 86 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference wup tsk Wakeup task iwup tsk Wakeup task handler only C Language API ER ercd wup tsk ID tskid ER ercd iwup tsk ID tskid e Parameters ID tskid ID number of the target task e Return Parameters ER ercd Terminated normally E OK or error code Assembly language API include mr30 inc wup tsk TSKID iwup tsk TSKID e Parameters TSKID ID number of the target task e Register contents after service call is issued Register name Content after
281. tion file kernel_id h ID number is defined in this file R20UT0655EJ0100 Rev 1 00 Page 256 of 295 Jun 01 2011 RENESAS M3T MR30 4 Configuration File xxx cfg Default Configuration File default cfg Template File sys ram inc mr30 inc MR30 Version File version R20UT0655EJ0100 Rev 1 00 Jun 01 2011 cfg30 an de T9 us d 8 Using Configurator System Data Difinition File Sys ram inc sys rom inc IndudeFile mr30 inc kernel id h Figure 8 1 The operation of the Configurator 32 NE SAS Page 257 of 295 M3T MR30 4 8 Using Configurator 8 2 2 Setting Configurator Environment Before executing the configurator check to see if the environment variable LIB30 is set correctly The configurator cannot be executed normally unless the following files are present in the directory indicated by the en vironment variable LIB30 Default configuration file default cfg This file can be copied to the current directory for use In this case the file in the current directory is given priority e System RAM area definition database file sys ram inc e mr30 inc template file mr30 inc Section definition file c_sec inc or asm sec inc Startup file crtOmr a30 or start a30 e MR30 version file version 8 2 3 Configurator Start Procedure Start the configurator as indicated below C cfg30 vV Configuration file name Normally use the extension cfg for the configuration f
282. tly for each task Further the introduction of the real time OS makes it easy to start debugging some already finished tasks even if the entire program is not completed yet Since engineers can be allocated to individual tasks work assign ment is easy 3 Software independence is enhanced to provide ease of program debugging As the use of the real time OS makes it possible to divide programs into small independent modules called tasks the greater part of program debugging can be initiated simply by observing the small modules 4 Timer control is made easier To perform processing at 10 ms intervals the microcomputer timer function was formerly used to periodically initiate an interrupt However as the number of usable microcomputer timers was limited timer insufficiency was compensated for by for instance using one timer for a number of different processing operations When the real time OS is introduced however it is possible to create programs for performing processing at fixed time intervals making use of the real time OS time management function without paying special attention to the microcomputer timer function At the same time programming can also be done in such a manner as to let the programmer take that 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 Therefore increased
283. tq S Sends to long data queue O O O O 3 vipsnd_dtq S polling O O O O 4 vtsnd_dtq S Sends to long data queue O O O with timeout 5 vfsnd_dtq S Forced sends to long data O O O O 6 vifsnd_dtq S queue O O O O 7 vrcv dtq S Receives from long data O O O queue 8 vprev_dtq S Receives from long data O O O O 9 viprcv dtq queue polling O O O O 10 vtrcv dtq S Receives from long data O O O queue with timeout 11 vref_dtq References long data queue O O O O 12 viref dtq status O O O O Notes e S Standard profile service calls e Each sign 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 state U Can be called from CPU unlocked state L Can be called from CPU locked state R20UT0655EJ0100 Rev 1 00 Page 188 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference vsnd_dtq Send to Long data queue vpsnd_dtq Send to Long data queue polling vipsnd_dtq Send to Long data queue polling handler only vtsnd dtq Send to Long data queue with timeout vfsnd dtq Forcibly send to Long data queue vifsnd dtq Forcibly send to Long data queue handler only C Language API ER ercd vsnd dtq ID vdtqid W data ER ercd vpsnd dtq ID vdtqid W data ER ercd vipsnd dtq ID vdtqid W data ER ercd vtsnd dtq ID vdtgid W data TMO tmout ER
284. ts for the kernel OS dependent interrupt handler In sections where all interrupts can be enabled it is returned to the initial IPL value when the service call was invoked For service calls that can be issued from only task context When thel flag before issuing a service call is 1 Task Service call issued Service call processing l flag 1 dt 0 44 1 i 1 l i IPL O lt system IPL la 0 lt system IPL 0 l When the flag before issuing a service call is O Task Service call issued Service call processing y T RER l flag 0 lt 0 1 i 0 i I IPL 0 lt system IPL 0 l I 1 lt system PL a inc 0 Figure 3 23 Interrupt control in a Service Call that can be Issued from only a Task R20UT0655EJ0100 Rev 1 00 Page 31 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel e For service calls that can be issued from only non task context or from both task context and non task context When the flag before issuing a service call is 1 p Servi Il issued service call processin Task or Handler ervice call Issu p g Handles r l l flag Luis 0 1 l 1 IPL 4 lt systemlPL Al 4 lt systemIPL lt 4 When thel flag before issuing a service call is O Tee Servi Il issued service call processin Task or Handler ervice call issu p g Han
285. ture The MR30 kernel consists of the modules shown in Figure 4 1 Each of these modules is composed of functions that ex ercise individual module features The MR30 kernel is supplied in the form of a library and only necessary features are linked at the time of system genera tion More specifically only the functions used are chosen from those which comprise these modules and linked by means of the Linkage Editor LN30 However the scheduler module part of the task management module and part of the time management module are linked at all times because they are essential feature functions The applications program is a program created by the user It consists of tasks interrupt handler alarm handler and cy clic handler Application Program Task Time Management Mailbox Semaphore Management Task dependent Memorypool System stae synchronization Eventfl ag Management Management System configuration Interrupt Management Scheduler Data queue Management M16C Microcomputer 18 For details See 4 3 9 R20UT0655EJ0100 Rev 1 00 Jun 01 2011 Figure 4 1 MR30 Structure ztENESAS User Module MR30 kernel Hardware Page 36 of 295 M3T MR30 4 4 Kernel 4 2 Module Overview The MR30 kernel modules are outlined below Scheduler Forms a task processing queue based on task priority and controls operation so that the high priority task at the beginning in that queue
286. turned wtskid Returned to wtskid is the ID number of the task at the top of a reception waiting queue the next task to be de queued If no tasks are kept waiting TSK_NONE is returned sdtqcnt Returned to sdtqcnt is the number of data bytes stored in the data queue area If this service call is to be issued from task context use ref dtq if issued from non task context use iref dro R20UT0655EJ0100 Rev 1 00 Page 124 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T_RDTO rdtq ER ercd ercd ref drot ID_DTQl amp rdtq lt lt Example statement in assembly language gt gt refdtq blkb 6 include mr30 inc GLB task task PUSHM A0 A1 ref dtq ID_DTQ1 _refdtq R20UT0655bEJ0100 Rev 1 00 Page 125 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 6 Synchronization amp Communication Function Mailbox Specifications of the mailbox function of MR30 are listed in Table 5 11 Table 5 11 Specifications of the Mailbox Function No Item Content 1 Mailbox ID 1 255 2 Mailbox priority 1 255 TA_TFIFO Waiting tasks enqueued in order of FIFO TA TPRI Waiting tasks enqueued in order of priority 3 Mailbox attribute TA MFIFO Messages enqueued in ord
287. turned This time is expressed in ms units If the target cyclic handler is non operational state the returned value is indeterminate If this service call is to be issued from task context use ref_cyc if issued from non task context use iref_cyc R20UT0655EJ0100 Rev 1 00 Page 159 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task T RCYC rcyc ER ercd ercd ref cyc ID CYC1l amp rcyc lt lt Example statement in assembly language gt gt include mr30 inc GLB task _ refcyc blkb 6 task PUSHM A0 A1 ref cyc ID_CYC1 _refcyc R20UT0655EJ0100 Rev 1 00 Page 160 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference 5 11 Time Management Function Alarm Handler Specifications of the alarm handler function of MR30 are listed in Table 5 21 The alarm handler description languages in item No 4 are those specified in the GUI configurator They are not output to a configuration file nor are the MR30 ker nel concerned with them Table 5 21 Specifications of the Alarm Handler Function No Item Content 1 Alarm handler ID 1 255 2 Activation time 0 Ox7FFFFFFF time tick ms 3 Extended information 16 bits 4 Alarm handler attribute TA_HLNG Handlers written in high level langua
288. turns the error code E_OBJ as a return value for the service call If this service call is to be issued from task context use get_pri if issued from non task context use iget_pri R20UT0655EJ0100 Rev 1 00 Page 77 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task PRI p_tskpri ER ercd ercd get_pri ID_task2 amp p_tskpri lt lt Example statement in assembly language gt gt INCLUDE mr30 inc GLB task task PUSHM AO get_pri ID_TASK2 R20UT0655bEJ0100 Rev 1 00 Page 78 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref tsk Reference task status iref tsk Reference task status handler only C Language API ER ercd ref tsk ID tskid T RTSK pk rtsk ER ercd iref tsk ID tskid T RTSK pk rtsk e Parameters ID tskid ID number of the target task T RTSK pk rtsk Pointer to the packet to which task status is returned e Return Parameters ER ercd Terminated normally E OK Contents of pk rtsk typedef struct t rtsk STAT tskstat 0 2 Task status PRI tskpri 2 2 Current priority of task PRI tskbpri 4 2 Base priority of task STAT tskwait 6 2 Cause of wait ID wobjid 8 2 Waiting object ID TMO lefttmo 10 4 Left time before timeout UINT actcnt 14 2 Number of
289. twai sem ID SEM3 R20UT0655EJ0100 Rev 1 00 Page 104 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference ref sem Reference semaphore status iref sem Reference semaphore status handler only C Language API ER ercd ref sem ID semid T RSEM pk rsem ER ercd iref sem ID semid T RSEM pk rsem e Parameters ID semid ID number of the target semaphore T RSEM pk rsem Pointer to the packet to which semaphore status is returned e Return Parameters ER ercd Terminated normally E OK T RSEM pk rsem Pointer to the packet to which semaphore status is returned Contents of pk rsem typedef struct t rsem ID wtskid 0 2 ID number of the task at the head of the semaphore s wait queue UINT semcnt 2 2 Current semaphore resource count T RSEM Assembly language API include mr30 inc ref sem SEMID PK RSEM iref sem SEMID PK RSEM e Parameters SEMID ID number of the target semaphore PK RSEM Pointer to the packet to which semaphore status is returned e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the target semaphore Al Pointer to the packet to which semaphore status is returned Error code None Funcional description This service call returns various statuses of the semaphore indicated by semid wtskid Returned to wtskid is the ID number of the task at the
290. tween the stacks O User stack This stack is provided for each task Therefore writing an application by using the MR30 requires to allocate the stack area for each stack O System stack This stack is used inside the MR30 or during the execution of the handler When a task issues a service call the MR30 switches the user stack to the system stack See Figure 11 1 System Stack and User Stack The system stack uses interrupt stack ISP Task MBO Service Call Processi ng Position Register save Stack switching Service call rocessing Task Sdedioan Stack switching Register return User Stack System Stack interruput stack X909 User Stack Figure 11 1 System Stack and User Stack R20UT0655EJ0100 Rev 1 00 Page 267 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method The sections of the system stack and user stack each are located in the manner shown below However the diagram shown below applies to the case where the stack areas for all tasks are located in the stack section during configuration System Stack User satck of Taskl D No 1 User satck of Taskl D No 2 Stack Section User satck of Taskl D No n Figure 11 2 Layout of Stacks R20UT0655EJ0100 Rev 1 00 Page 268 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method 11 1 1 User Stack Calculation Method User stacks must be calculated for each task The following sho
291. ty of message in the mailbox Fixed size memory pool definition This definition must always be set when the fixed size memory pool function is to be used lt lt Format gt gt Fixed Memory pool Definition memorypool ID No Ir name ID name section Section Name num_block Number of blocks in memory pool siz_block Block size of Memory pool siz_block Select memory pool waiting queue The ID number must be in the range 1 to 255 The ID number can be omitted If omitted ID numbers are automatically assigned in order of numbers beginning with the smallest R20UT0655EJ0100 Rev 1 00 Page 243 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator lt lt Content gt gt For each memory pool ID number define the items described below 1 ID name Definition format Symbol Definition range None Default value None Define the name by which the memory pool is specified in a program 2 Section name Definition format Symbol Definition range None Default value MR HEAP Define the name of the section in which the memory pool is located The section defined here must always have an area allocated for it in the section file asm sec inc or c sec inc If no section names are defined the memory pool is located in the MR HEAP section 3 Number of block Definition format Numeric value Definitio
292. uable is issued when dispatch disabled MR30 doesn t return the error and doesn t guarantee the operation 17 MR30 does not return an error even when an uninvocable service call is issued from a CPU locked state in which case however its operation cannot be guaranteed R20UT0655bEJ0100 Rev 1 00 Jun 01 2011 ztENESAS Page 29 of 295 M3T MR30 4 3 Introduction to Kernel 3 6 Regarding Interrupts 3 6 1 Types of Interrupt Handlers MR30 s interrupt handlers consist of kernel OS dependent interrupt handlers and non kernel OS independent interrupt handlers The following shows the definition of each type of interrupt handler Kernel OS dependent interrupt handler An interrupt handler whose interrupt priority level is lower than a kernel interruption mask level OS interrupt prohibition level is called kernel OS dependent interrupt handler That is interruption priority level is from 0 to system_IPL A service call can be issued within a kernel OS dependent interrupt handler However interrupt is delayed un til it becomes receivable the kernel management OS dependence interrupt handler generated during service call processing kernel management OS dependence interruption Non kernel OS independent interrupt handler An interrupt handler whose interrupt priority level is higher than a kernel interrupt mask level OS interrupt prohibition level is called non kernel interrupt handler OS independent ha
293. ued the service call with the wakeup request count left intact If this service call is to be issued from task context use wup_tsk if issued from non task context use iwup tsk R20UT0655EJ0100 Rev 1 00 Page 87 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task if wup_tsk ID_main E_OK printf Can t wakeup main n lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO wup_tsk ID_TASK1 R20UT0655bEJ0100 Rev 1 00 Page 88 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference can_wup Cancel wakeup request ican_wup Cancel wakeup request handler only C Language API ER UINT wupcnt can wup ID tskid ER UINT wupcnt ica wup ID tskid e Parameters ID tskid ID number of the target task e Return Parameters ER UINT wupcnt gt 0 Canceled wakeup request count wupcnt 0 wupcnt lt 0 Error code Assembly language API include mr30 inc can wup TSKID ican wup TSKID e Parameters TSKID ID number of the target task Register contents after service call is issued Register name Content after service call is issued RO Error code Canceled wakeup request count AO ID number of the target task Error code
294. uests UINT suscnt Number of suspension requests T_RTSK typedef struct t_rtst STAT tskstat Task status STAT tskwait Reason for which task is kept waiting T_RTST Formats related to semaphore typedef struct t_rsem ID wtskid 1D number of task at the top of waiting queue INT semcnt Current semaphore count value T RSEM Formats related to eventflag wfmod TWF ANDW H 0000 AND wait TWF ORW H 0001 OR wait typedef struct t rflg ID wtskid 1D number of task at the top of waiting queue UINT flgptn Current bit pattern of eventflag T RFLG Formats related to data queue and short data queue typedef struct t rdtq ID stskid ID number of task at the top of transmission waiting queue ID rtskid 1D number of task at the top of reception waiting queue UINT sdtqcnt Number of data bytes contained in data queue y T_RDTQ Formats related to mailbox typedef struct t msg VP msghead Message header T_MSG typedef struct t msg pri T MSG msgque Message header PRI msgpri Message priority T MSG PRI typedef struct t mbx ID wtskid 1D number of task at the top of waiting queue T MSG pk msg Next message to be received T RMBX Formats related to fixed size memory pool R20UT0655EJ0100 Rev 1 00 Page 285 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix
295. ueue 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 do 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 e 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 2 First In First Out R20UT0655EJ0100 Rev 1 00 Page 48 of 295 Jun 01 2011 RENESAS M3T MR30 4 4 Kernel 4 3 6 Synchronization and Communication Function Mailbox The mailbox is a mechanism to perform data communication between tasks In Figure 4 15 for example task A can drop a message into the mailbox and task B can retrieve the message from the mailbox Since mailbox based communication is achieved by transferring the start address of a message from a task to another this mode of communication is per formed at high speed independently of the message size The kernel manages the message queue by means of a link list The application should prepare a header area that is to be used for a link list This is called the message header The message header and the area actually used by the application to store a message are called the message packet The kernel rewrites the content of the message header as it manages the message queue The message he
296. used in user program size of registers used Sections used in MR30 Size of registers used should be added 2bytes by each register Figure 3 1 shows an example for calculating a user stack In the example below the registers used by the task are RO R1 and AO If written in the C language this size is fixed R20UT0655EJ0100 Rev 1 00 Page 269 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method Stack growing direction _ _ oo When use register RO R1 R2 A0 8bytes 2bytes jsr subl 12bytes P C F LG 4size of registers used sta tsk 16bytes PC F LG size of registers used stack size used by prcv msg bm prcv_dtq 18bytes Figure 11 3 Example of Use Stack Size Calculation R20UT0655EJ0100 Rev 1 00 Page 270 of 295 Jun 01 2011 RENESAS M3T MR30 4 11 Stack Size Calculation Method 11 1 2 System Stack Calculation Method The system stack is most often consumed when an interrupt occurs during service call processing followed by the occur rence of multiple interrupts The necessary size the maximum size of the system stack can be obtained from the fol lowing relation Necessary size of the system stack a 2Pi y The maximum system stack size among the service calls to be used When sta_tsk ext_tsk slp_tsk and dly_tsk are used for example according to the Table 11 1 Stack Sizes Used by Service Calls Issued from Tasks in byt
297. ution of a service call routine by a software interrupt If you issue service calls directly without using a service call invocation macro your program may not be guaranteed of compatibility with future versions of MR30 The table below lists the assembly language interface parameters The values set forth in uITRON specifications are not used for the function code Task Management Function EE ServiceCall INTNo FuncCode AO Al AO EG 9 3 iact t sk EICHER eat 3 ee em ux l olea s je was elea s les ex A LL new 2 wl hea jea O mp rm se s le mmm se s es mm x p s es fe mp 3 se jew ww Desk 5 ee me es Hes s m se mm es mm 2 se xm es em m O 1s me es R20UT0655EJ0100 Rev 1 00 Page 287 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix Task Dependent Synchronization Function F Al DEE Lea R3 AO RO ServiceCall INTNo mes Heus al R20UT0655EJ0100 Rev 1 00 Page 288 of 295 Jun 01 2011 RENESAS M3T MR30 4 14 Appendix Synchronization amp Communication Function EE ServiceCall INTNo FuncCode R2 FuncCode ET PLUME EC i E C CN RU CR RR Das 2 9 e e ES wsm 3 e esl L E wsm s e e ES mise wer E fees ES ES sm 3
298. vals for example the activation cycle here must be set to 1000 R20UT0655EJ0100 Rev 1 00 Page 246 of 295 Jun 01 2011 RENESAS M3T MR30 4 8 Using Configurator 3 TA STA attribute Definition format Symbol Definition range ON or OFF Default value OFF Specify the TA STA attribute of the cyclic handler If ON is selected the TA STA attribute is added if OFF is selected the TA STA attribute is not added 4 TA PHS attribute Definition format Symbol Definition range ON or OFF Default value OFF Specify the TA PHS attribute of the cyclic handler If ON is selected the TA PHS attribute is added if OFF is selected the TA PHS attribute is not added 5 Activation phase Definition format Numeric value Definition range 0 to OX7FFFFFFF Default value None Define the activation phase of the cyclic handler The time representing this startup phase must be defined in ms units 6 Start Address Definition format Symbol or Function Name Definition range None Default value None Define the start address of the cyclic handler Note that the function name defined here will have the declaration statement shown below output to the ker nel id h file pragma CYCHANDLER function name 7 Extended information Definition format Numeric value Definition range 0 to OXFFFF Default value 0 Define the extended information of the cycli
299. vice call is issued Register name Content after service call is issued RO Terminated normally E OK AO Acquired task ID Error code None Functional description This service call returns the task ID currently in RUNNING state to the area pointed to by p_tskid If this service call is issued from a task the ID number of the issuing task is returned If this service call is issued from non task context the task ID being executed at that point in time is returned If there are no tasks currently in an executing state TS amp NONE is returned If this service call is to be issued from task context use get tid if issued from non task context use get tid R20UT0655EJ0100 Rev 1 00 Page 170 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt tinclude lt itron h gt tinclude lt kernel h gt include kernel_id h void task ID tskid get tid amp tskid lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO get_tid R20UT0655EJ0100 Rev 1 00 Page 171 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference loc cpu Lock the CPU iloc cpu Lock the CPU handler only C Language API ER ercd loc cpu ER ercd iloc cpu e Parameters None e Return Parameters ER ercd Terminated normally E_OK Assembly language AP
300. voked time value16 low order bits must be set before calling sevice call R20UT0655EJ0100 Rev 1 00 Page 162 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference Example program statement lt lt Example statement in C language gt gt include lt itron h gt include lt kernel h gt include kernel_id h void task sta alm ID alm1 100 lt lt Example statement in assembly language gt gt include mr30 inc GLB task task PUSHM AO R1 R3 MOV W 100 R1 MOV W 0 R3 sta alm ID_ALM1 POPM AO R1 R3 R20UT0655EJ0100 Rev 1 00 Page 163 of 295 Jun 01 2011 RENESAS M3T MR30 4 5 Service call reference stp_alm Stop alarm handler operation istp_alm Stop alarm handler operation handler only C Language API ER ercd stp_alm ID almid ER ercd istp_alm ID almid e Parameters ID almid ID number of the alarm handler to be stopped e Return Parameters ER ercd Terminated normally E OK Assembly language API include mr30 inc stp alm ALMID istp alm ALMID e Parameters ALMID ID number of the alarm handler to be stopped e Register contents after service call is issued Register name Content after service call is issued RO Terminated normally E OK AO ID number of the alarm handler to be stopped Error code None Funcional description This service call places the alarm handler indicated by almid into a non operational state If thi
301. waiting release is delayed behind specified time There is an influence in the task of waiting with time out or the delay waiting by the following ser vice call calls dly tsk tslp tsk twai sem twai flg trcv mbx tsnd dtq trcv dtq tget mpf vtsnd dtq vtrcv dtq R20UT0655EJ0100 Rev 1 00 Page 34 of 295 Jun 01 2011 RENESAS M3T MR30 4 3 Introduction to Kernel 3 8 Stacks 3 8 1 System Stack and User Stack The MR30 provides two types of stacks system stack and user stack e User Stack One user stack is provided for each task Therefore when writing applications with the MR30 it is necessary to furnish the stack area for each task e System Stack This stack is used within the MR30 during service call processing When a service call is issued from a task the MR30 switches the stack from the user stack to the system stack See Figure 3 25 The system stack use the interrupt stack ISP Task MR30 service call processing User Stack Save Registers XXX_XXX Stack switching Service call processing System Stack Task selection Stack switching Restore Registers User Stack Figure 3 25 System Stack and User Stack Switchover from user stack to system stack occurs when an interrupt of vector numbers 0 to 31 or 247 to 255 is generated Consequently all stacks used by the interrupt handler are the system stack R20UT0655EJ0100 Rev 1 00 Page 35 of 295 Jun 01 2011 RENESAS 4 Kernel 4 1 Module Struc
302. ws an example for calculating user stacks in cases when an application is written in the C language and when an application is written in the assembly language When an application is written in the C language Using the stack size calculation utility calculate the stack size of each task The necessary stack size of a task is the sum of the stack size output by the stack size calculation utility plus a context storage area of 20 bytes The following shows how to calculate a stack size using e When an application is written in the assembly language Sections used in user program The necessary stack size of a task is the sum of the stack size used by the task in subroutine call plus the size used to save registers to a stack in that task Sections used in MR30 The sections used in MR30 refer to a stack size that is used for the service calls issued MR30 requires that if you issue only the service calls that can be issued from tasks 6 bytes of area be allocated Also if you issue the service calls that can be issued from both tasks and handlers see the stack sizes listed in Table 11 2 Stack Sizes Used by Service Calls Issued from Handlers in bytes to ensure that the necessary stack area is allocated Furthermore when issuing multiple service calls include the maximum value of the stack sizes used by those service calls as the sections used by MR30 as you calculate the necessary stack size Therefore User stack size Sections
Download Pdf Manuals
Related Search
Related Contents
MAQUINAS DE ENSAYO HUMAX PR FOX C Bedienungsanleitung Samsung BN59-00654D-00 User's Manual LG BP530 TRUMPF iLed OR Light Service Manual Manual de instrucciones Cam Analyzer v4.0 for Windows User`s Manual Home Decorators Collection YG423-BN Instructions / Assembly Copyright © All rights reserved.
Failed to retrieve file