background image

Preface

1

Preface

This manual explains how to use the RTX51 Tiny Real-Time Operating System and gives
an overview of the functionality of RTX51 Full.  The manual is not a detailed introduc-
tion to real-time applications and assumes that you are familiar with Keil C51, A51, the
related Utilities, the DOS operating system and the hardware and instruction set of the
8051 microcontrollers.

The following literature is recommended as an extensive introduction in the area of real-
time programming:

Deitel, H.M., Operating Systems, second edition,
Addison-Wesley Publishing Company, 1990

Ripps, David, A Guide to Real-Time Programming, Englewood Cliffs, N.J,
Prentice Hall, 1988/

Allworth, S.T., Introduction to Real-Time Software Design,
Springer-Verlag Inc., New York

This user’s guide contains 6 parts:

Part 1:

Overview,

 describes the functionality of a the RTX51 real-time opeating

systems and discusses the basic features and differences of RTX51 Tiny and
RTX51 Full.  Also included are the technical data of RTX51 Full and
RTX51 Tiny.

Part 2:

Requirements and Definitions, 

discusses the development tools and the

target system requirements of RTX51 Tiny, explains the terms used in the
the RTX51 Tiny manual and decribes the task definition.

Part 3:

Creating RTX51 Tiny Applicaitons, 

describes the steps necessary to cre-

ate RTX51 Tiny applications.

Part 4:

Library Functions,

 provides a reference for all RTX51 Tiny library rou-

tines.

Part 5:

System Debugging, 

describes the stack handling of RTX51 Tiny and con-

tains information about the system debugging.

Part 6:

Applications Examples, 

contains several examples using RTX51 Tiny and

describes the software development process.  This information can be used
as a guideline for your real-time designs.

Содержание RTX51

Страница 1: ...guide contains 6 parts Part 1 Overview describes the functionality of a the RTX51 real time opeating systems and discusses the basic features and differences of RTX51 Tiny and RTX51 Full Also included...

Страница 2: ...Interrupt Handling 15 Reentrant Functions 16 C51 Library Functions 16 Usage of Multiple Data Pointers and Arithmetic Units 16 Registerbanks 17 Task Definition 17 Task Management 17 Task Switching 18...

Страница 3: ...SYSTEM DEBUGGING 41 Stack Management 41 Debugging with dScope 51 41 APPLICATION EXAMPLES 45 RTX_EX1 Your First RTX51 Program 45 RTX_EX2 A Simple RTX51 Application 47 TRAFFIC A Traffic Light Controlle...

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

Страница 5: ...ly required to enter these commands using all capital letters Courier Text in this typeface is used to represent the appearance of information that would be displayed on the screen or printed on the p...

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

Страница 7: ...supports round robin and the use of sig nals for task switching Preemptive task switching is not sup ported No message routines are included No memory pool allo cation routines are available The remai...

Страница 8: ...counter 0 while 1 repeat forever check_serial_io process_serial_cmds process serial input check_kbd_io process_kbd_cmds process keyboard input adjust_ctrlr_parms adjust the controller counter increme...

Страница 9: ...b0 This process is repeated in definitely include rtx51tny h int counter0 int counter1 void job0 void _task_ 0 os_create 1 mark task 1 as ready while 1 loop forever counter0 update the counter void jo...

Страница 10: ...waiting for 3 clock ticks to elapse before it can continue executing job0 The result of this example is that counter0 gets incremented every 3 timer ticks and counter1 gets incremented every 5 timer...

Страница 11: ...emption NOTE Preemption and priority levels are not supported by RTX51 Tiny You can modify the above function declaration for job1 to give it a higher priority than job0 By default all tasks are assig...

Страница 12: ...implemented with RTX51 CAN RTX51 CAN is a CAN task integrated into RTX51 Full A RTX51 CAN task implements message passing via the CAN network Other CAN stations can be configured either with or witho...

Страница 13: ...receive a message call from interrupt 71 with message os_create_pool define a memory pool 644 size 20 10 bytes os_get_block get a block from a memory pool 148 os_free_block return a block to a memory...

Страница 14: ...requirements 6KB 8KB 900 bytes Hardware requirements timer 0 or timer 1 timer 0 System clock 1000 40000 cycles 1000 65535 cycles Interrupt latency 50 cycles 20 cycles Context switch time 70 100 cycles...

Страница 15: ...external data memory However the application can access external memory RTX51 Tiny can use all memory models supported by C51 The selected memory model only influences the location of application obj...

Страница 16: ...nformation Reentrant functions store their parameters and local data variables on a reentrant stack and the data are protected in this way against multiple calls However RTX51 Tiny does not contain an...

Страница 17: ...d job0 void _task_ 0 while 1 counter0 increment counter defines the function job0 to be task number 0 All that this task does is increment a counter and repeat You should note that all tasks are imple...

Страница 18: ...e task calls the os_wait function and the specified event has not occurred 2 The task has executed for longer than the defined round robin time out Another task is started if 1 No other task is runnin...

Страница 19: ...RTX Tiny 19 2 Note The event SIGNAL can be combined with the events TIMEOUT and so that RTX51 Tiny waits for both a signal and a time period...

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

Страница 21: ...started A portion of this file is listed below This file is part of the RTX51 tiny Real Time Operating System Package CONF_TNY A51 This code allows configuration of the RTX51 tiny Real Time Operating...

Страница 22: ...em interrupt INT_CLOCK defines the interval for the system clock The system clock generates an interrupt using this interval The defined number specifies the number of CPU cycles per interrupt TIMESHA...

Страница 23: ...pplications n If possible disable round robin multitasking Tasks which use round robin multi tasking require 13 bytes of stack space to store the task context registers etc This context storage is not...

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

Страница 25: ...ized in the following table and described in detail in the func tion reference that follows Routine Description isr_send_signal Sends a signal to a task from an interrupt os_clear_signal Deletes a sig...

Страница 26: ...s Summary Briefly describes the routine s effect lists include file s containing its declaration and prototype illustrates the syntax and describes any arguments Description Provides a detailed descri...

Страница 27: ...function call will ready the task for execution Otherwise the signal is stored in the signal flag of the task The isr_send_signal function may be called only from interrupt functions Return Value The...

Страница 28: ...e signal flag for the task specified by task_id Return Value The os_clear_signal function returns a value of 0 if the signal flag was successfully cleared A value of 1 is returned if the specified tas...

Страница 29: ...executed according to the rules specified for RTX51 Tiny Return Value The os_create_task function returns a value of 0 if the task was successfully started A value of 1 is returned if the task could...

Страница 30: ...d argument The specified task is removed from the task list Return Value The os_delete_task function returns a value of 0 if the task was successfully stopped and deleted A return value of 1 indicates...

Страница 31: ...the currently executing task function Return Value The os_running_task_id function returns the task ID of the cur rently executing task This value is a number in the range 0 to 15 See Also os_create_t...

Страница 32: ..._id If the specified task is already waiting for a signal this function call readies the task for execution Otherwise the signal is stored in the signal flag of the task The os_send_signal function ma...

Страница 33: ...RTX Tiny 33 4 Example include rtx51tny h include stdio h for printf void signal_func void _task_ 2 os_send_signal 8 signal task 8 void tst_os_send_signal void _task_ 8 os_send_signal 2 signal task 2...

Страница 34: ...ents can be logically ORed using the vertical bar character For example K_TMO K_SIG specifies that the task wait for a time out or for a signal The ticks argument specifies the number of timer ticks t...

Страница 35: ...void tst_os_wait void _task_ 9 while 1 char event event os_wait K_SIG K_TMO 50 0 switch event default this should never happen break case TMO_EVENT time out 50 tick time out occurred break case SIG_E...

Страница 36: ...it offers The event_sel argument specifies the event to wait for and can have only the value K_SIG which will wait for a signal Return Value When the signal events occurs the task is enabled for execu...

Страница 37: ...tants Event constant Description K_IVL Wait for a timer tick interval K_SIG Wait for a signal K_TMO Wait for a time out The above events can be logically ORed using the vertical bar character For exam...

Страница 38: ...rary 4 Return Value Description SIG_EVENT A signal was received TMO_EVENT A time out has completed or an interval has expired NOT_OK The value of the event_sel argument is invalid See Also os_wait os_...

Страница 39: ...RTX Tiny 39 4...

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

Страница 41: ...rea for Task 0 50H STACK 0F8H 0F0H Task0 Running Task Stack Assignment for Stack Area for Task 2 0FFH RAMTOP Stack Area for Task 1 Stack Area for Task 0 50H STACK 0F8H 58H Task1 Running Task Stack Ass...

Страница 42: ...he debug function is activated by pressing the F3 KEY and displays then the status of RTX51 Tiny In addition every task switch is displayed with a message Example DS51 TRAFFIC INCLUDE DBG_TINY INC G F...

Страница 43: ...time out are placed in the TIME OUT STATE This state is equivalent to the READY STATE Wait for Event Indicates which events the task is currently waiting for The events can be a combination of the fo...

Страница 44: ...44 RTX51 Tiny Specifications 5...

Страница 45: ...er for task 1 int counter2 counter for task 2 Task 0 job0 RTX51 tiny starts execution with task 0 job0 _task_ 0 os_create_task 1 start task 1 os_create_task 2 start task 2 while 1 endless loop counter...

Страница 46: ...displayed in the watch window at the top of the screen Enter CTRL C to halt execution of RTX_EX1 then type INCLUDE DBG_TINY INC at the DS51 command prompt This will load an include file that allows y...

Страница 47: ...b0 RTX51 tiny starts execution with task 0 job0 _task_ 0 os_create_task 1 start task 1 os_create_task 2 start task 2 os_create_task 3 start task 3 while 1 endless loop counter0 increment counter 0 os_...

Страница 48: ...the four counters as follows counter0 incremented every 5 RTX51 timer ticks counter1 incremented every 10 RTX51 timer ticks counter2 incremented as fast as possible this task gets most of the availabl...

Страница 49: ...isted in the following table These commands are composed of ASCII text characters All commands must be terminated with a car riage return Command Serial Text Description Display D Display clock start...

Страница 50: ...rform as well GETLINE C is the command line editor for characters received from the serial port This source file is also used by the MEASURE application TRAFFIC C TRAFFIC C Traffic Light Controller us...

Страница 51: ...f task get_escape struct time structure of the time record unsigned char hour hour unsigned char min minute unsigned char sec second struct time ctime 12 0 0 storage for clock time values struct time...

Страница 52: ...time 0 flag signal cmd state display_time Task 2 clock clock _task_ CLOCK while 1 clock is an endless loop if ctime sec 60 calculate the second ctime sec 0 if ctime min 60 calculate the minute ctime m...

Страница 53: ...AT n return 0 return 1 define ESC 0x1B ESCAPE character code bit escape flag mark ESCAPE character entered Task 6 get_escape check if ESC escape character was entered get_escape _task_ GET_ESC while 1...

Страница 54: ...loop escape 0 clear escape flag display_time 1 set display time flag os_clear_signal COMMAND clear pending signals while escape while no ESC entered printf Clock Time 02bd 02bd 02bd r display time cti...

Страница 55: ...check if clock time is between start and end bit signalon if memcmp start end sizeof struct time 0 if memcmp start ctime sizeof struct time 0 memcmp ctime end sizeof struct time 0 return 1 else if mem...

Страница 56: ...ffic light operation red 1 red stop lights on yellow 0 green 0 stop 1 walk 0 while 1 endless loop os_wait K_TMO 30 0 wait for timeout 30 ticks if signalon if traffic signal time over os_create_task BL...

Страница 57: ...nd_signal LIGHTS send signal to task lights os_wait K_TMO 2 0 wait for timeout 2 ticks SERIAL C SERIAL C Interrupt Controlled Serial Interface for RTX 51 tiny include reg52 h special function register...

Страница 58: ...dactive flag marks transmitter active bit sendstop flag marks XOFF character putbuf write a character to SBUF or transmission buffer putbuf char c if sendfull transmit only if buffer not full if senda...

Страница 59: ...clear output task number putbuf c send character return c return character ANSI requirement _getkey interrupt controlled _getkey char _getkey void while iend istart itask os_running_task_id set input...

Страница 60: ...nal itask break if TI start_trans if transmitter interrupt TI 0 clear interrupt request flag if ostart oend if characters in buffer and if sendstop if not Control S received SBUF outbuf ostart OLEN 1...

Страница 61: ...Line Editor void getline char idata line unsigned char n unsigned char cnt 0 char c do if c _getkey CR c LF read character if c BACKSPACE c DEL process backspace if cnt 0 cnt decrement count line and...

Страница 62: ...ialization file This file will automati cally load the IOF driver load the traffic program load an include file for displaying task status active watchpoints for the traffic lights define a function f...

Страница 63: ...d and the walk light switch to on You can display the task status using F3 much as before The following task information will be displayed Task ID Start State Wait for Event Signal Timer Stack 0 0026H...

Страница 64: ...ent Tool Requirements 15 E Event 9 12 18 Interval 18 Signal 18 Timeout 18 F FREE_STACK 22 I INT_CLOCK 22 INT_REGBANK 17 22 Interrupt Handling 15 Interrupts 12 isr_send_signal 25 27 K K_IVL 34 37 K_SIG...

Страница 65: ...Configuration 21 RTX51 Tiny System Functions 25 RTX51TNY H 15 21 RTX51TNY LIB 15 S SIG_EVENT 34 36 38 Single Task Program 8 Stack Management 41 STACK_ERROR 22 System Debugging 41 System Functions 13...

Страница 66: ...is manual and or databases may be reproduced or transmitted in any form or by any means electronic or mechanical including photocopy ing recording or information storage and retrieval systems for any...

Страница 67: ...ftware Inc KEIL ELEKTRONIK GmbH has representatives in the following countries Australia Austria Belgium CFR Denmark Finland France Germany India Ireland Israel Italy Netherlands Norway Poland Spain S...

Страница 68: ...RTX51 TINY REAL TIME OPERATING SYSTEM User s Guide 2 95...

Отзывы: