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.

Summary of Contents for RTX51

Page 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...

Page 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...

Page 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...

Page 4: ......

Page 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...

Page 6: ......

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 20: ......

Page 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...

Page 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...

Page 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...

Page 24: ......

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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_...

Page 39: ...RTX Tiny 39 4...

Page 40: ......

Page 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...

Page 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...

Page 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...

Page 44: ...44 RTX51 Tiny Specifications 5...

Page 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...

Page 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...

Page 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_...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 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...

Page 68: ...RTX51 TINY REAL TIME OPERATING SYSTEM User s Guide 2 95...

Reviews: