USBB17RX78K4-XXX NEC Electronics, USBB17RX78K4-XXX Datasheet
USBB17RX78K4-XXX
Related parts for USBB17RX78K4-XXX
USBB17RX78K4-XXX Summary of contents
Page 1
SERIES REAL-TIME OS © 1994 RX78K/IV Document No. U10603EJ3V0UM00 (3rd edition) Date Published January 1997 N Printed in Japan FUNDAMENTAL ...
Page 2
TRON is an abbreviation of The Realtime Operating system Nucleus. ITRON is an abbreviation of Industrial TRON. MS-DOS is a trademark of Microsoft Corporation. IBM-PC/ trademark of IBM Corporation. The other company names and product names appearing in ...
Page 3
... Madrid, Spain Tel: 01-504-2787 Fax: 01-504-2860 NEC Electronics (Germany) GmbH Scandinavia Office Taeby, Sweden Tel: 08-63 80 820 Fax: 08-63 80 388 NEC Electronics Hong Kong Ltd. Hong Kong Tel: 2886-9318 Fax: 2886-9022/9044 NEC Electronics Hong Kong Ltd. Seoul Branch Seoul, Korea Tel: 02-528-0303 Fax: 02-528-4411 NEC Electronics Singapore Pte ...
Page 4
Thank you for buying NEC’s 78K/IV Series Real-time OS RX78K/IV, which is embedded software for the 78K/IV Series. This manual is intended to introduce to the user the general idea of 78K/IV series real-time OS RX78K/IV. [Readers assumed ...
Page 5
The following symbols are used throughout this manual: … : Repeat [ ] : Can be omitted “ ” : Character string ‘ ’ : Character string ( ) : Character Bold : Character Important ...
Page 6
CHAPTER 1 GENERAL ....................................................................................................................... 1.1 Multi-task OS ............................................................................................................................................ 1.2 RX78K/IV ................................................................................................................................................... 1.3 Outline and Features of RX78K/IV .......................................................................................................... 1.4 Configuration and Size of RX78K/IV....................................................................................................... 1.5 Memory Confuguration of RX78K/IV ...................................................................................................... CHAPTER 2 BASIC FUNCTIONS OF RX78K/IV ............................................................................. 2.1 Task State ...
Page 7
Synchronization and Communication .................................................................................................... 4.2.1 set_flg (Set Eventflag) iset_flg (Set Eventflag for Interrupt)................................................................................................. 4.2.2 clr_flg (Clear Eventflag) ................................................................................................................... 4.2.3 wai_flg (Wait Eventflag)................................................................................................................... 4.2.4 cwai_flg (Wait and Clear Eventflag) ................................................................................................ 4.2.5 pol_flg (Poll Eventflag)..................................................................................................................... 4.2.6 cpol_flg (Poll and Clear Eventflag) ...
Page 8
Figure No. 1-1 Memory Structure Example (Large Model).................................................................................................... 1-2 Memory Structure Example (Small Model) .................................................................................................... 2-1 RX78K/IV Task State Transition.................................................................................................................... 2-2 Example of “ret_int” ....................................................................................................................................... 2-3 Example of “ret_int” ....................................................................................................................................... 2-4 Memory Pool Configuration ........................................................................................................................... 3-1 Stack State in Dispatching ...
Page 9
[MEMO ...
Page 10
Systems in the field of control equipment are required to respond immediately to changes in external and internal events. The conventional systems have tried to satisfy this requirement by using simple interrupt programs. As the application systems have increasingly become ...
Page 11
... Convenient utilities for system configuration Two utilities useful for configuring system are provided. Configurator • High-level language interface • (5) RX78K/IV supports the following cross tools for 78K/IV series. RA78K4 • CC78K4 • (6) Two types of memory models supported The RX78K/IV supports the memory models supported by the CC78K4 as follows: Large model (1M-byte space) : supports location 0fh • ...
Page 12
Configuration and Size of RX78K/IV The RX78K/IV consists of the following three subsystems. (1) Nucleus This is the central part of the RX78K/IV embedded in the target system along with the application program and actually carries out ...
Page 13
Memory Confuguration of RX78K/IV The memory of the system using RX78K/IV consists of the following: (1) Nucleus (2) Reset routine for system initialization (3) System call entry address storage table Note (4) OS management area (5) Initialization information table ...
Page 14
CHAPTER 1 Fig. 1-1 Memory Structure Example (Large Model) FFFFFH FFF00H · Object management block · OS management table FF700H 10000H · Nucleus · System initialization information table · System call entry address storage table · User program (Task & ...
Page 15
[MEMO] 6 ...
Page 16
CHAPTER 2 Because RX78K/ multi-task OS, it can process two or more tasks concurrently. 78K/IV series microcomputer has 8 register banks. With RX78K/IV, bank 0 of these register banks is used by the OS. Tanks can be allocated ...
Page 17
CHAPTER 2 2.1 Task State A task can be in any of the following 4 states: (1) RUN state In this state, the task is given the privilege to use the CPU and is under execution. Only one task in ...
Page 18
CHAPTER 2 2.1.1 Task state transition Fig. 2-1 illustrates state transition of a task. Each state transition has the following meaning, and system calls that places a task in one state from another are available. (1) Starting A task is ...
Page 19
CHAPTER 2 Fig. 2-1 RX78K/IV Task State Transition READY Start Forced termination 10 BASIC FUNCTIONS OF RX78K/IV DISPATCH PREEMPT Wait release Wait conditon WAIT Forced termination DORMANT Normal termination RUN ...
Page 20
CHAPTER 2 2.2 Task Manipulation RX78K/IV allows the following manipulation of tasks: (1) Starting task All the tasks created when the system is started are placed in the DORMANT state. A task in the DORMANT state cannot be dispatched until ...
Page 21
CHAPTER 2 2.3 Synchronization and Communication A task is executed under its own environments as an independent program. To execute two or more independent tasks in parallel and thereby to organize one system necessary to control execution flow ...
Page 22
CHAPTER 2 2.3.1 Event flag An event flag is used to make a task wait. Since an event flag is a 1-bit flag not ORed or ANDed with the other flags. A task issues system call “wai_flg”, “cwai_flg” ...
Page 23
CHAPTER 2 2.3.2 Semaphore A semaphore is used to mutually exclude tasks. The semaphore is a measurement that can check whether currently usable resources exist, or manage the number of resources. The number of requested resources of the wait manipulation ...
Page 24
CHAPTER 2 2.3.3 Mail box A mail box transmits messages between tasks and has a queue of tasks waiting for reception of a message and a queue of messages waiting to be transmitted. A task can request reception of a ...
Page 25
CHAPTER 2 2.4 Interrupt Management Interrupt management is for managing processing that is driven taking an interrupt as an event. A processing routine that is vectored by an interrupt is called an interrupt handler, which is independent of tasks. There ...
Page 26
CHAPTER 2 Fig. 2-3 shows an example where task A has a lower priority than task B. <1> Task B has issued system call “wai_flg” and is now in the WAIT state. <2> Task A is under execution (has the ...
Page 27
CHAPTER 2 2.5 Memory Management RX78K/IV performs dynamic memory management based on a memory block of fixed size. This means that a task acquires memory when necessary, and releases it when unnecessary. By using this feature not necessary ...
Page 28
CHAPTER 2 2.6 Time management Time management refers to delayed wake up of tasks and the running of cyclic handlers. Delayed wake up tasks means performing wake up processing on a task after the elapsing of a specified amount of ...
Page 29
[MEMO] 20 ...
Page 30
CHAPTER 3 RX78K/IV BASIC OPERATIONS AND CONTROL BLOCKS This chapter describes the basic operations of a system running RX78K/IV and the control block configuration managed by RX78K/IV. 21 ...
Page 31
CHAPTER 3 RX78K/IV BASIC OPERATIONS AND CONTROL BLOCKS 3.1 RX78K/IV Configuration 3.1.1 Flow of overall processing RX78K/IV uses register bank 0 of the 8 register banks of the 78K/IV series microcomputers. For user tasks, multiple tasks can be allocated to ...
Page 32
CHAPTER 3 RX78K/IV BASIC OPERATIONS AND CONTROL BLOCKS Register bank 1 is shared by multiple tasks. Therefore, dispatching or preempting make it necessary for registers to be saved or restored. This causes the overhead of these tasks to be slightly ...
Page 33
CHAPTER 3 RX78K/IV BASIC OPERATIONS AND CONTROL BLOCKS 3.1.2 Configuration of ready queue and dispatching When RX78K/IV passes CPU execution privilege to a task, it searches for a task having the highest priority in the READY state. At this time, ...
Page 34
CHAPTER 3 RX78K/IV BASIC OPERATIONS AND CONTROL BLOCKS 3.2 RX78K/IV Control Block RX78K/IV has control blocks to manage each object. The control blocks are created by the user at time of configuration, and RX78K/IV uses these blocks for system calls ...
Page 35
CHAPTER 3 RX78K/IV BASIC OPERATIONS AND CONTROL BLOCKS 3.2.2 Control blocks (1) Task control block (TCB) This control block is used by RX78K/IV to manage tasks. One control block of this type is assigned to each task. One TCB is ...
Page 36
CHAPTER 4 This chapter describes the following items of each system calls: [Function]: Outline of the function of the system call [Remarks]: Describes the function of the system call [System call ID number]: Number particular to system call when the ...
Page 37
CHAPTER 4 [C format]: Description format used when the system call is issued in the C language and the data type of the parameter ¡ ¡ Interface with C language The high-level language supported in developing an application program is ...
Page 38
CHAPTER 4 Be sure to directly call the following i the branching module. The values in the brackets indicate the addresses of the CALLT table. addresses corresponding to unused system calls can be used by users. ichg_pri (42H), irot_rdq (44H), ...
Page 39
CHAPTER 4 4.1 System Calls Related to Task The following system calls are related to tasks: (1) sta_tsk Starts task (2) ext_tsk Normally terminates task itself (3) ter_tsk Forcibly terminates another task (4) chg_pri Changes the tasks priority ichg_pri Changes ...
Page 40
CHAPTER 4 4.1.1 sta_tsk (Start Task) [Function] Starts a task by placing it in the READY state from the DORMANT state. [Remarks] This system call starts the task specified by tskid result, the task enters the READY state ...
Page 41
CHAPTER 4 4.1.2 ext_tsk (Exit Task) [Function] Normally terminates the task itself and places the task in the DORMANT state from the RUN state. [Remarks] This system call normally terminates the task that issues this system call itself ...
Page 42
CHAPTER 4 4.1.3 ter_tsk (Terminate Task) [Function] Forcibly aborts another task. [Remarks] This system call forcibly aborts the task specified by tskid. If the specified task is placed in a queue, the task is released from the queue when the ...
Page 43
CHAPTER 4 4.1.4 chg_pri (Change Task Priority) ichg_pri (Change Task Priority for Interrupt) [Function] Changes the priority of a task. [Remarks] Changes the priority of the current task indicated by tskid to a value indicated by tskpri. The own task ...
Page 44
CHAPTER 4 4.1.5 rot_rdq (Rotate Ready Queue) irot_rdq (Rotate Ready Queue for Interrupt) [Function] Rotates the ready queue of the specified priority. [Remarks] Rotates the ready queue of the priority indicated by tskpri. Consequently, the task placed at the top ...
Page 45
CHAPTER 4 4.1.6 tsk_sts (Get Task Status) [Function] Gets a task’s state. [Remarks] References each status of the task indicated by tskid, and sets the current priority of the target task “tskpri” and task state “tskstat” specified address ...
Page 46
CHAPTER 4 4.1.7 slp_tsk (Sleep Task) [Function] Places a task in the WAIT state. [Remarks] Places the task itself in the WAIT state from the RUN state. This WAIT state is released issuing the system call “wup_tsk (iwup_tsk)” or “ret_wup” ...
Page 47
CHAPTER 4 4.1.8 wai_tsk (Wait for Wakeup Task) [Function] Places a task in the WAIT state for a fixed amount of time. [Remarks] Places the task itself in the WAIT state for a fixed amount of time from the RUN ...
Page 48
CHAPTER 4 4.1.9 wup_tsk (Wakeup Task) iwup_tsk (Wakeup Task for Interrupt) [Function] Wakes up a task and places it in the READY state from the WAIT state. [Remarks] Places a task that has been placed in the WAIT state by ...
Page 49
CHAPTER 4 4.1.10 can_wup (Cancel Wakeup Task) [Function] Cancels a task wake-up request. [Remarks] Stores the number of wake-up requests queued to the target task indicated by tskid to a specified pointer, and at the same time cancels all wake-up ...
Page 50
CHAPTER 4 4.2 Synchronization and Communication The following system calls are used for synchronization and communication: (1) set_flg Sets an event flag (2) iset_flg Sets an event flag (when used in interrupt handler) (3) clr_flg Clears an event flag (4) ...
Page 51
CHAPTER 4 4.2.1 set_flg (Set Eventflag) iset_flg (Set Eventflag for Interrupt) [Function] Sets an event flag. [Remarks] The event flag indicated by flgid is set task exists that has been made to wait for the event ...
Page 52
CHAPTER 4 4.2.2 clr_flg (Clear Eventflag) [Function] Clears an event flag. [Remarks] Clears the event flag indicated by flgid. Even if a task exists that has been made to wait for the event flag by “wai_flg”, “cwai_flg”, that task is ...
Page 53
CHAPTER 4 4.2.3 wai_flg (Wait Eventflag) [Function] Waits for an event flag (without clear). [Remarks] Waits until an event flag indicated by flgid is set to 1. The value of the event flag remains set after it has been set ...
Page 54
CHAPTER 4 4.2.4 cwai_flg (Wait and Clear Eventflag) [Function] Waits for an event flag (with clear). [Remarks] Waits until an event flag indicated by flgid is set to 1. The event flag is cleared when it has been set and ...
Page 55
CHAPTER 4 4.2.5 pol_flg (Poll Eventflag) [Function] Obtains an event flag (without clear). [Remarks] Checks whether the event flag indicated by flgid is set. If the flag is set, the task is terminated normally; if not, an error is returned ...
Page 56
CHAPTER 4 4.2.6 cpol_flg (Poll and Clear Eventflag) [Function] Obtains an event flag (with clear). [Remarks] Checks whether the event flag indicated by flgid is set. If the flag is set, the flag is cleared and the task is terminated ...
Page 57
CHAPTER 4 4.2.7 sig_sem (Signal Semaphore) isig_sem (Signal Semaphore for Interrupt) [Function] Executes signal manipulation for semaphore (V instruction). [Remarks] If tasks exist that wait for a semaphore indicated by semid, the task at the top of the queue is ...
Page 58
CHAPTER 4 4.2.8 wai_sem (Wait on Semaphore) [Function] Executes wait manipulation for a semaphore (P instruction). [Remarks] If the count value of the semaphore indicated by semid more, the count value of the semaphore is decremented by ...
Page 59
CHAPTER 4 4.2.9 preq_sem (Poll and Request Semaphore) [Function] Obtains a semaphore resource. [Remarks] If the count value of the semaphore indicated by semid more, the count value of the semaphore is decremented by one, and the ...
Page 60
CHAPTER 4 4.2.10 snd_msg (Send Message to Mailbox) isnd_msg (Send Message to Mailbox for Interrupt) [Function] Sends a message. [Remarks] Sends a message at the address pk_msg to a mail box indicated by mbxid task exists that is ...
Page 61
CHAPTER 4 [C format] On issuing snd_msg • ret = snd_msg (mbxid, pk_msg); char *mbxid; char *pk_msg; 52 RX78K/IV SYSTEM CALL LIST On issuing isnd_msg • ret = isnd_msg (mbxid, pk_msg); char *mbxid; char *pk_msg; ...
Page 62
CHAPTER 4 4.2.11 rcv_msg (Receive Message from Mailbox) [Function] Waits for reception from a mail box. [Remarks] Receives a message from a mail box indicated by mbxid and sets the top address of the received message in an address specified ...
Page 63
CHAPTER 4 4.2.12 prcv_msg (Poll and Receive Message from Mailbox) [Function] Receives a message. [Remarks message has arrived to the mail box indicated by mbxid, it receives the message and sets the top address of the received message ...
Page 64
CHAPTER 4 4.3 Memory Management The following system calls are related to memory: (1) pget_blk Gets a fixed-length memory block (2) rel_blk Releases a fixed-length memory block RX78K/IV SYSTEM CALL LIST 55 ...
Page 65
CHAPTER 4 4.3.1 pget_blk (Poll and Get Fixed-Length Memory Block) [Function] Gets a memory block of a fixed length. [Remarks] Gets a memory block of a fixed length from a memory pool indicated by mplid. This memory block can be ...
Page 66
CHAPTER 4 4.3.2 rel_blk (Release Fixed-Length Memory Block) [Function] Releases a memory block of a fixed length. [Remarks] Releases the memory block indicated by blk to a memory pool specified by mplid. [System call ID number] rel_blk = 23 [Parameter] ...
Page 67
CHAPTER 4 4.4 Interrupt Processing The following system calls can be used for interrupt processing: (1) ret_int Terminates the interrupt handler (2) ret_wup Returns from an interrupt and wakes up a task 58 RX78K/IV SYSTEM CALL LIST ...
Page 68
CHAPTER 4 4.4.1 ret_int (Return from Interrupt Handler) [Function] Returns from an interrupt handler. [Remarks] This system call is issued when execution is returned from an interrupt handler. ´´´ Even if “i _yyy” system call is issued in the interrupt ...
Page 69
CHAPTER 4 4.4.2 ret_wup (Return and Wakeup Task) [Function] Returns from an interrupt handler and wakes up a task. [Remarks] Returns from an interrupt handler and wakes up an interrupt processing task indicated by tskid (the task placed in the ...
Page 70
CHAPTER 4 Fig. 4-2 Stack Status When ret_int and ret_wup Are Called When large model is used High address +17H PC19-16 PSWH7-4 +16H PSWL +15H PC15-8 +14H PC7-0 +13H W +12H H(R15) +11H L(R14) +10H T +0FH D(R13) +0EH E(R12) ...
Page 71
CHAPTER 4 4.5 Version Management The following system call can be used for version management: (1) get_ver Gets the version number of RX78K/IV 62 RX78K/IV SYSTEM CALL LIST ...
Page 72
CHAPTER 4 4.5.1 get_ver (Get Version No.) [Function] Gets the version number of RX78K/IV. [Remarks] Sets the top address of the version management block in an address specified by the parameter. The version management block stores the following information. The ...
Page 73
CHAPTER 4 4.6 Time Management The system calls for time management are as follows: (1) act_cyc Controls activation of a cyclic handler. iact_cyc Controls activation of a cyclic handler. (When used within an interrupt handler) 64 RX78K/IV SYSTEM CALL LIST ...
Page 74
CHAPTER 4 4.6.1 act_cyc (Activate Cyclic Handler) iact_cyc (Activate Cyclic Handler for Interrupt) [Function] Controls activation of a cyclic handler. [Remarks] Changes the activation state of the cyclic handler shown by cyhid to the state specified by the cyhact. The ...
Page 75
CHAPTER 4 [Assembler format] n the case of act_cyc: • I [Large model] MOV bnk0_b, #26 MOV bnk0_e, #cyhact MOVW bnk0_up, #cyhid MOV bnk0_d, #tskpri CALLT [40H register = return parameter n the case of iact_cyc: • I ...
Page 76
CHAPTER 5 A system running RX78K/IV is initialized when the system initialization reset routine stored with RX78K/IV in the internal ROM or external memory of the 78K/IV series is expected. After resetting the device, the system is branched out to ...
Page 77
CHAPTER 5 5.1 Hardware Used With RX78K/IV, hardware such as the timer/counter unit used for “wai_tsk”, “act_cyc(iact_cyc)” is used (refer to Table 5-1). Since RX78K/IV does not initialize the timer/counter unit, initialize the unit within the user initialization routine. When ...
Page 78
APPENDIX 1 Error code list • Value Error code (8 bits, char type) E_OK 0 E_NODMT 1 E_DMT 2 E_QOVR 3 E_TMOUT 4 E_PLFAIL 5 Task status list • Value 0x0 DORMANT status 0x1 RUN or READY status 0x2 WAIT ...
Page 79
[MEMO] 70 ...
Page 80
APPENDIX 2 C Compiler CC78K4 of version 2.00 or above supports tasks and interrupt handlers. Examples of describing a task and an interrupt handler in the C language are shown below. Task • Description format #pragma rtos_task [task function name] ...
Page 81
[MEMO] 72 ...
Page 82
APPENDIX 3 System Call sta_tsk Starts task by placing it in RUN state from DORMANT state ext_tsk Normally terminates task itself by placing it in DORMANT state from RUN state ter_tsk Forcibly terminates another task by placing it DORMANT state ...
Page 83
[MEMO] 74 ...
Page 84
APPENDIX 4 When creating a cyclic handler, be careful about the following points. (1) The cyclic handler can be mapped in the 1MB memory space. (Large model only) (2) The cyclic handler is invoked with the “br rg” command from ...
Page 85
[MEMO] 76 ...
Page 86
APPENDIX 5 On RX78K/IV possible to set an area capable of generating objects (TCB, event flag, semaphore, mail box, memory pool, and cyclic handler arbitrary area. However, the area of 20 bytes starting from the start ...
Page 87
APPENDIX 5 0FFEFFH 0FF97CH 0FF954H 0FF7BCH 0FF7B0H 0FF7A0H 0FF78CH 0FF778H 0FF714H (?objhead) 0FF700H 78 ESTIMATING MEMORY CAPACITY (LARGE MODEL) Stack area per each task Ready queue 4 bytes*10 Memory pool 16 bytes* 5+4 bytes 32 bytes*10+4 bytes Mail box 4 ...
Page 88
APPENDIX 6 ESTIMATING MEMORY CAPACITY (SMALL MODEL) On RX78K/IV possible to set an area capable of generating objects (TCB, event flag, semaphore, mail box, memory pool, and cyclic handler) in 256 bytes of the internal RAM area 0F700H ...
Page 89
APPENDIX 6 0FEFFH 0F7F8H 0F7E4H 0F786H 0F780H 0F778H 0F76EH 0F75EH 0F70EH (?objhead) 0F700H 80 ESTIMATING MEMORY CAPACITY (SMALL MODEL) Stack area per each task Ready queue 2 bytes*10 Memory pool 10 bytes* 3+2 bytes 6 bytes*10+2 bytes Mail box 2 ...
Page 90
The RX78K/IV places the CPU in the HALT status as default assumption when there are no longer any selected tasks. In some systems, however, the STOP mode or IDLE mode may be preferred to the HALT mode. With the RX78K/IV, ...
Page 91
The following sample indicates an example of changing the internal system clock if the clock is fixed in the user system. Sample 1 public @nuc_idl cseg base @nuc_idl: ei mov stbc, #00000001b ret ; end Remark The above sample is ...
Page 92
APPENDIX 8 MAXIMUM STACK SIZE USED BY EACH SYSTEM CALL The stack area of the task that has issued the system call is used as a stack area used for system call processing. Therefore, the stack size of each system ...
Page 93
APPENDIX 8 System Call Name sta_tsk ext_tsk ter_tsk chg_pri ichg_pri rot_rdq irot_rdq tsk_sts slp_tsk wai_tsk wup_tsk iwup_tsk can_wup set_flg iset_flg clr_flg wai_flg cwai_flg pol_flg cpol_flg sig_sem isig_sem wai_sem preq_sem snd_msg isnd_msg rcv_msg prcv_msg pget_blk rel_blk ret_int ret_wup get_ver act_cyc iact_cyc ...
Page 94
APPENDIX 9 RX78K/IV uses the following symbols as public symbols. Therefore, make sure that the same names are not used on tasks and interrupt handlers. ?objhead brproc ?sysrt ?qin ?qin1 ?qout ?qout1 ?canc1 ?cnsav ?itdsp ?tmdsp ?tkdsp ?tm_ret x_serial bittbl ...
Page 95
[MEMO] 86 ...
Page 96
...