rtx51tiny2.02中文手册
- 格式:doc
- 大小:135.50 KB
- 文档页数:33
RTX51 Tiny 实时内核理解声明:以下来自网络整理而来并非本人作品,觉得挺容易懂所以放入博客以便后来学习者参考RTX51 Tiny中容易混淆的问题RTX51 Tiny是 Keil uVision中自带的一个小型嵌入式RTOS,具有小巧、速度快、系统开销小、使用方便等优点。
使用RTX51 Tiny能够提高系统的稳定性,优化程序的性能;而且它是为51单片机专门定制的,所以在51单片机上的运行效率比其它一些通用的RTOS性能也要好一些。
但是,由于RTX51 Tiny的相关资料和书籍比较少,大部分只是对程序自带帮助文件的简单翻译,很少进行深入探讨。
下面就RTX51 Tiny使用中经常遇到的一些问题进行探讨。
1 关于时间片的问题RTX51 Tiny使用的是无优先级时间片轮询法,每个任务使用相同大小的时间片,但是时间片是怎样确定的呢?RTX51 Tiny的配置参数(Conf_tny.a51文件中)中有INT_CLOCK和TIMESHARING两个参数。
这两个参数决定了每个任务使用时间片的大小:INT_CLOCK是时钟中断使用的周期数,也就是基本时间片;TIMESHARING是每个任务一次使用的时间片数目。
两者决定了一个任务一次使用的最大时间片。
如假设一个系统中INT_CLOCK设置为10000,即10ms,那么TIMESHARING=1时,一个任务使用的最大时间片是 10ms;TIMESHARING=2时,任务使用最大的时间片是20ms;TIMESHARING=5时,任务使用最大的时间片是50ms;当 TIMESHARING设置为0时,系统就不会进行自动任务切换了,这时需要用os_switch_task函数进行任务切换。
这部分功能是RTX51 Tiny 2.0中新增加的。
2 关于os_wait延时的问题os_wait 是RTX51 Tiny中的基本函数之一。
它的功能是将当前任务挂起来,等待一个启动信号(K_SIG)或超时信号(K_TMO)或周期信号(K_IVL)或者是它们之间的组合。
目录总览 (2)实时程序 (5)操作原理 (7)配置RTX51 Tiny (11)使用RTX51 Tiny (14)实例 (17)函数参考 (18)总览RTX51 Tiny是一个实时系统,它允许你创建可同时执行多个功能或任务的应用程序。
在嵌入式应用中这往往是必须的。
虽然可以创建无RTOS实时程序(通过执行一个或多个任务循环),但诸如调度,维护和时序问题,像RTX51 Tiny这样的RTOS可以解决。
一个实时的操作系统可以灵活的调度系统资源,像CPU、内存和任务之间的通信。
RTX51 Tiny是一个功能强大且简单易用的RTOS,适用于所有8051衍生产品。
在Keil C51编译器中RTX51 Tiny是用标准C(ANSI C)编写的。
C语言允许你轻松的定义任务功能而不必进行复杂的栈和变量设置。
RTX51程序需要包含一个特殊的头文件且链接RTX51库到程序中。
1.新特性RTX51 Tiny第二版包含了许多新特性使实时软件开发更容易,如下代码分段RTX51 Tiny现在支持代码分段(需配置文件L51_BANK.A51文件)。
明确任务切换新功能(OS_SWITCH_TASK)可以是一个任务处于就绪状态并立即切换至另一个任务。
任务就绪标志新的RTX51 Tiny库允许给任务设置就绪状态标志,使任务处于就绪状态,在一个时间间隔、超时或接受到信号后恢复运行。
CPU空闲模式RTX51 Tiny允许CPU处于空闲模式定时器中断的用户代码支持开发者可以添加自己的代码到RTX51 Tiny定时器中断中,也可以为自己的例程设置和RTX51 Tiny相同的例程(需配置CONF_TNY.A51)。
支持间隔时间设置OS_REST+INTERVAL允许开发者在混合的时间间隔和信号中调用OS_WAIT来调整超时时间。
此外,RTX51 Tiny已被重新组合以具备灵活性、加速性以及对代码和数据空间要求更小。
RTX51 Tiny第二版在显著减小代码量并具有可扩展性。
RTX51 Tiny介绍μVision是德国K eil公司开发的单片机IDE软件,最初主要用于8051系列单片机,RTX51是其自带的运行于8051系列单片机上的小型多任务实时操作系统,可用来设计具有实时性要求的多任务软件。
RTx51有2个版本:RTX51 Tiny和RTX51 Full。
RTX51 Tiny是RTX51 Full的子集。
RTX51 Tiny 自身仅占用900字节左右的程序存储空间,可以很容易地运行在没有外部扩展存储器的8051单片机系统上。
它完全集成在Keil C5l编译器中,具有运行速度快、对硬件要求不高、使用方便灵活等优点,因此越来越广泛地应用到单片机的软件开发中。
它可以在单个CPU上管理几个作业(任务),同时可以在没有扩展外部存储器的单片机系统上运行。
目前在8051系列单片机上使用多任务实时操作系统,RTX51 Tiny也就成为了首选。
////////////////////////////////////////////////////////////////////////////////////////////////////////////////// \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ RTX51 TINY允许同时“准并行”地执行多个任务:各个任务并非持续运行,而是在预先设定的时间片(time slice)内执行。
CPU执行时间被划分为若干时间片,RTX51 TINY为每个任务分配一个时间片,在一个时间片内允许执行某个任务,然后RTX51 TINY切换到另一个就绪的任务并允许它在其规定的时间片内执行。
由于各个时间片非常短,通常只有几ms,因此各个任务看起来似乎就是被同时执行了。
Round-robin 任务切换RTX51 Tiny可以配置成使用round-robin多任务。
Round-robinp容许quasi-parallel执行多任务。
任务并不是连续执行的,而是分时间片执行的(可用的CPU时间被分成时间片,RTX51 Tiny把时间片分配给各个任务)。
时间片的时间很短(以毫秒为单位),所以任务看起来像连续执行一样任务在分配给他的时间片内执行(除非放弃)。
然后切换到下一个就绪的任务。
这个时间片在RTX51 Tiny Configuration.配置文件中定义.下面的例子是一个使用round-robin多任务的RTX51 Tiny的程序。
这个程序中的两个任务都是循环计数器。
RTX51 Tiny执行称为job0的任务0。
这个函数创建了另一个任务job1。
Job0执行完它的时间片后,RTX51 Tiny开始执行job1。
Job1执行完它的时间片后,RTX51 Tiny又返回到job0开始执行。
然后再切换到job1,如此循环。
#includeint 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 job1 (void) _task_ 1 {while (1) { /* loop forever */counter1++; /* update the counter */}}注意:除了一个任务的时片到时,也可以使用函数os_wait 或函数os_switch_task通知RTX51 Tiny可以切换到另一个任务。
函数os_wait挂起当前任务直到特定的事件发生。
在这期间任何其他的任务都可以执行。
Cooperative 任务切换如果你禁止了round-robin多任务,你必须设计并执行你的任务从而让他你们以cooperativ方式工作。
Alienware X51 R2Owner’s ManualRegulatory model: D05SRegulatory type: D05S002Notes, Cautions, and WarningsNOTE: A NOTE indicates important information that helps you make better use of your computer.CAUTION: A CAUTION indicates potential damage to hardware or loss of data if instructions are not followed.WARNING: A WARNING indicates a potential for property damage, personal injury, or death.____________________Information in this document is subject to change without notice.© 2013 Dell Inc. All rights reserved.Reproduction of these materials in any manner whatsoever without the written permission of Dell Inc. is strictly forbidden.Trademarks used in this text: Dell™ and the DELL logo are trademarks of Dell Inc.;Alienware® is a trademark or registered trademark of Alienware Corporation; Microsoft®, Windows®, and the Windows start button logo are either trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries; Bluetooth® is a registered trademark owned by Bluetooth SIG, Inc. and is used by Dell under license.Other trademarks and trade names may be used in this document to refer to either the entities claiming the marks and names or their products. Dell Inc. disclaims any proprietary interest in trademarks and trade names other than its own.2013 - 10 Rev. A01ContentsAbout Your Computer (5)Front View (5)Back View (6)Specifications (6)Before You Begin (7)Turn Off Your Computer and Connected Devices (7)Safety Instructions (8)Working Inside Your Computer (9)System Setup (10)Overview (10)Entering System Setup (10)Boot Sequence (15)Flashing the BIOS (17)Contacting Alienware (18)Websites (18)Contents | 34 | ContentsAbout Your Computer |5About Your ComputerFront ViewNOTE: Your Alienware X51 R2 computer supports dual orientation. You can place your computer vertically or horizontally. The rotatable AlienHead allows you to change the direction of the AlienHead depending on the orientation of your computer.1power button 2optical-drive eject button 3optical drive 4rotatable AlienHead 5microphone port 6headphone port7USB 3.0 ports (2)12345676 | About Your ComputerBack ViewSpecificationsFor detailed information regarding the configuration of your computer, see Specifications at /support .1optical S/PDIF port 2USB 3.0 ports (2)3USB 2.0 ports (2)4rear L/R surround port 5side L/R surround port 6microphone port 7hard-drive activity light 8label tab 9power adapter port 10HDMI port 11discrete graphics card 12line-out port13line-in port 14center/subwoofer LFE port 15security-cable slot16USB 3.0 ports (2)17network port and network lights18coaxial S/PDIF port121779181284631551416131110Before YouBegin | 7Before You BeginTurn Off Your Computer and Connected DevicesCAUTION: To avoid losing data, save and close all open files and exit all open programs before you turn off your computer.1Save and close all open files and exit all open programs.2Access the Settings charm in the Charms sidebar. Tap or click Power and then choose Shut Down .Microsoft Windows shuts down and then the computer turns off.NOTE: If you are using a different operating system, see the documentation of your operating system for shut-down instructions.3Disconnect your computer and all attached devices from their electrical outlets.4Disconnect all telephone cables, network cables, and attached devices from your computer.5Press and hold the power button while the computer is unplugged to ground the system board.8 | Before You BeginSafety InstructionsUse the following safety guidelines to help protect your computer from potential damage and to help ensure your personal safety.WARNING: Before you begin, read the safety information that shipped with your computer. For more safety best practices information, see the Regulatory Compliance Homepage at /regulatory_compliance.WARNING: Only a certified service technician is authorized to remove the computer cover and access any of the components inside.CAUTION: To avoid damaging the computer, ensure that the work surface is flat and clean.CAUTION: When you disconnect a cable, pull on its connector or on its pull-tab, not on the cable itself. Some cables have connectors with locking tabs or thumb-screws that you must disengage before disconnecting the cable. When disconnecting cables, keep them evenly aligned to avoid bending any connector pins. When connecting cables, ensure that the connectors and ports are correctly oriented and aligned.CAUTION: To disconnect a network cable, first unplug the cable from your computer and then unplug the cable from the network device. NOTE: Ensure that you remove the security cable from the security-cable slot, if applicable.Working Inside Your Computer |9Working Inside Your ComputerWARNING: Only a certified service technician is authorized toremove the computer cover and access any of the components inside the computer.For information on removing and replacing the internal component of your computer, contact Alienware. See "Contacting Alienware" on page 18.10 | System SetupSystem SetupOverviewUse the system setup to:•get information about the hardware installed in your computer, such as the amount of RAM, the size of the hard drive, and so on •change the system configuration information•set or change a user-selectable option, such as user password, type of hard drive installed, enabling or disabling base devices, and so onCAUTION: Unless you are an expert computer user, do not change the settings for this program. Certain changes can make your computer work incorrectly.NOTE: Before you change system setup, it is recommended that you note the system-setup screen information for future reference.Entering System Setup1Turn on (or restart) your computer.2During POST, when the Alienware logo is displayed, watch for the F2 prompt to appear and then press <F2> immediately.NOTE: The F2 prompt indicates that the keyboard has initialized. This prompt can appear very quickly, so you must watch for it, and then press <F2>. If you press <F2> before the F2 prompt, this keystroke is lost. If you wait too long and the operating system logo appears, continue to wait until you see the Microsoft Windows desktop. Then, turn off your computer and try again. See "Turn Off Your Computer and Connected Devices" on page 7.System Setup ScreensThe system setup screen displays current or changeable configuration information for your computer. Information on the screen is divided into three areas: the Setup Item , active Help Screen , and Key Functions .SystemSetup | 11System Setup OptionsNOTE: Depending on your computer and installed devices, the items listed in this section may or may not appear exactly as listed.Setup Item — This field appears on theleft side of the system setup window.The field is a scrollable list containingfeatures that define the configuration ofyour computer, including installedhardware, power conservation, andsecurity features.Scroll up and down the list using themouse or with the up- and down-arrowkeys. As an option is highlighted, theHelp Screen displays moreinformation about that option andavailable settings.Help Screen — This field appears on the right side of the system setup window and contains information about each option listed in the Setup Item . In this field you can view information about your computer and make changes to your current e the mouse or press the up-arrow and down-arrow keys to highlight an option. Double-click or press <Enter> to make that selection active and return to the Setup Item .NOTE: Not all settings listed in the SetupItem are changeable.Key Functions — This field appears below the Help Screen and lists keys and their functions within the active system setup field.MainSystem DateDisplays the current date in mm/dd/yyy format.System TimeDisplays the current time in hh:mm:ss format.BIOS InformationBIOS VersionDisplays the BIOS version number.Build DateDisplays the BIOS release date.Product InformationProduct NameDisplays the product name.Set Service TagAllows you to enter the service tag of your computer.Asset Tag Displays the asset tag of your computer.ME InformationME Firmware Version Displays the version of the Management Engine (ME) Firmware.MemoryInformationTotal Memory Displays the total computer memory.Memory Available Displays the amount of memory available on the computer.Memory Technology Displays the type of memory technology used.Memory Speed Displays the memory speed.CPU InformationProcessor ID Displays the processor identification code.CPU Speed Displays the processor speed.Cache L2Displays the processor L2 cache size.Cache L3Displays the processor L3 cache size.Device InformationSATA Port1Displays the device connected to SATA Port1.SATA Port2Displays the device connected to SATA Port2.SATA Port3Displays the device connected to SATA Port3.mSATA Device Displays the mSATA device.Advanced — Advanced BIOS FeaturesOptionRom Display Screen Allows you to display or hide the RAID option ROM screen during POST.Advanced — CPUConfigurationXD Bit Capability Allows you to enable or disable XD Bit Capability.NOTE: If enabled, the processor distinguishes betweenthe bits of code that can and cannot be executed.Intel(R) SpeedStep Technology Allows you to enable or disable Intel (R) Speedstep Technology.NOTE: If enabled, the processor clock speed and core voltage are adjusted dynamically based on the processor load.CPU C States Allows you to enable or disable CPU C states.12 | System SetupAdvanced — Integrated DevicesUSB Controller Allows you to enable or disable the integrated USBcontroller.HD Audio Allows you to enable or disable the integrated audiocontroller.Onboard LANControllerAllows you to enable or disable the onboard LAN controller.Primary Display Allows you to select which of the Integrated/Discretegraphics device should be the Primary Display.PXE OptionUEFI PXE Driver Allows you to enable to disable boot option for UEFI (UnifiedExtensible Firmware Interface) Network Devices.PCIE Gen3Allows you to enable or disable PCIE Gen3 capability. Advanced — Power Management SetupAC Recovery Sets what action the computer takes when power isrestored.SecuritySupervisor Password:Displays the Supervisor Password status.User Password:Displays the User Password status.Set SupervisorPasswordAllows you to set or change a supervisor password.Set User Password Allows you to set or change a user password.NOTE: This item is only displayed when the supervisorpassword is already set.Boot Menu Security Allows you to enable to disable Boot Menu Security.NOTE: This item is only displayed when the supervisorpassword is already set.BootBoot ConfigurationBootup NumLock State Allows you to enable or disable the keyboard NumLockstate.Wait For ’F1’ If Error If enabled, the system HALT during boot to display system errors.Secure Boot Control Allows you to enable or disable secured booting.Load Legacy OPROM Allows you to enable or disable the Legacy Option ROM.System Setup | 13Set Boot PriorityBoot Mode Allows you to select Legacy or UEFI boot mode.NOTE: Legacy boot mode if selected, enables booting todevices that support Legacy BIOS. UEFI boot mode ifselected, enables UEFI drivers.CAUTION: Changing boot modes require thatyour boot storage device be partitioned tomatch the boot mode compatibility. Changingboot modes could result in an incompatible bootstorage device, which may prevent the originalOS boot. Restoring the boot mode may resolvean incompatible boot storage device failure andrecover the original OS boot.Usb Boot Support Allows you to enable or disable booting from USB massstorage devices such as hard drive, optical drive, USB flashdrives, and so on.1st Boot Displays the first boot device.Default: UEFI:Windows Boot Manager.2nd Boot Displays the second boot device.Default: USB Hard Disk.3rd Boot Displays the third boot device.Default: CD/DVD.4th Boot Displays the fourth boot device.Default: Floppy.5th Boot Displays the fifth boot device.Default: Network.Hard Disk Drive BBS Priorities Sets the hard drive boot priority. The items displayed are dynamically updated according to the hard drives detected.ExitProvides options to Save Changes and Reset, Discard Changes and Reset, and Restore Defaults.14 | System SetupSystem Setup |15Boot SequenceThis feature allows you to change the boot sequence for devices.Boot Options•Floppy — The computer attempts to boot from the floppy disk drive. If no operating system is on the drive, the computer generates an error message.•Hard Drive — The computer attempts to boot from the primary hard drive. If no operating system is on the drive, the computer generates an error message.•CD/DVD/CD-RW Drive — The computer attempts to boot from the optical drive. Ifno disc is in the drive, or if the disc is not bootable, the computer generates an error message.•USB Storage Device — Insert the memory device into a USB connector andrestart the computer. When F12 Boot Options appear in the lower-right corner of the screen, press <F12>. The BIOS detects the device and adds the USB flash option to the boot menu.NOTE: To boot to a USB device, the device must be bootable. To ensure thatyour device is bootable, check the device documentation.•Network — The computer attempts to boot from the network. If no operatingsystem is found on the network, the computer generates an error message.Changing Boot Sequence for the Current BootYou can use this feature to change the current boot sequence, for example, to boot from the optical drive to run Dell Diagnostics from the Drivers and Utilities disc. The previous boot sequence is restored at the next boot.1If you are booting from a USB device, connect the USB device to a USB connector.2Turn on (or restart) your computer.3When F2 Setup, F12 Boot Options appear in the lower-right corner of thescreen, press <F12>.NOTE: If you wait too long and the operating system logo appears, continue to wait until you see the Microsoft Windows desktop. Then, shut down yourcomputer and try again.The Boot Options appears, listing all available boot devices.4On the Boot Options choose the device you want to boot from.For example, if you are booting to a USB hard disk, highlight USB Hard Disk and press <Enter>.16 | System SetupChanging Boot Sequence for Future Boots1Enter system setup. See "Entering System Setup" on page 10.2Scroll using the mouse or use the arrow keys to highlight the Boot menu option andpress <Enter> to access the menu.NOTE: Write down your current boot sequence in case you want to restore it.3Navigate to Set Boot Priority to change the devices assigned to the following:–1st Boot –2nd Boot –3rd Boot –4th Boot –5th Boot 4Double-click or use the arrow keys to highlight the boot priority and press <Enter> to display the different devices. 5Select the device and press <Enter> or double-click to set the boot priority.Flashing the BIOSThe BIOS may require flashing when an update is available or when replacing the system board. To flash the BIOS:1Turn on the computer.2Go to /support/downloads.3Under the category Support for Home Users, click Drivers & Downloads Home.4Locate the Service Tag of your computer. The Service Tag for your computer is on a label at the back of your computer. For more information, see the Quick Start Guide that shipped with your computer.If you have your computer’s Service Tag or Express Service Code:a Click Enter Service Tag.b Enter your computer’s Service Tag or Express Service Code in the Service Tagor Express Service Code: field, click Submit, and proceed to step 5.If you do not have your computer’s Service Tag,a Select one of the following options:–Automatically detect my Service Tag for me–Choose from My Products and Services List–Choose from a list of all Dell productsb Click Continue and follow the instructions on the screen.5Select the Operating System installed in your computer.6 A list of results appears on the screen. Click BIOS.7Click Download File to download the latest BIOS file.8In the Choose Download Method window, click Single-file download, and then click Continue.9In the Save As window, select an appropriate location to download the file on your computer.10If the Download Complete window appears, click Close.11Navigate to the folder where you downloaded the BIOS update file. The file icon appears in the folder and is titled the same as the downloaded BIOS update file.12Double-click the BIOS update file icon and follow the instructions on the screen.Flashing the BIOS | 1718 | Contacting Alienware Contacting AlienwareNOTE: Dell provides online and telephone-based support and service options for your Alienware computer. These services may vary by country and product and may not be available in your area.To contact Dell for sales, technical support, or customer service issues:1Go to /contactdell .2Select the appropriate service or support link based on your need.3Choose the method of contacting Dell that is convenient for you.If you are in the United States, call 1-800-ALIENWARE for help on your Alienware computer.WebsitesFor the latest information, FAQs, and solutions to most common issues,see /Alienware .。
RTX51应用笔记mcs 51 2008-09-01 08:33:48 阅读31 评论0 字号:大中小RTX51是KEILC公司专为51系列单片机而出的嵌入式系统,目前有两个版本可供选择:RTX51 tiny和RTX51 full 两个版本。
由于使用的人不是很多,相关的资料也十分的少。
因此本人在调试时走了一点点弯路,由于之前自学了点UC/OS II嵌入式操作系统。
学习RTX51时感到十分的轻松。
此次上传一点关于RTX51软件安装包和一点中文使用手册(想学好的话必须得看英文手册,安装好软件包后,英文手册在HLP目前下可找到)。
本此讲解的为RTX51 TINY版,因为它适合于没有外展存储器的51芯片,其本身也就900个字节左右,非常的小巧,当然了功能方面也就相应缩水了!。
但是,使用RTX51 Tiny 的程序可以访问外部存储器。
RTX51 Tiny允许循环任务切换,并且支持信号传递,还能并行的利用中断功能。
RTX51 Tiny 的os_wait函数可以等待以下事件:时间到、时间间隔、来自任务或者中断的信号。
压缩包中的中文手册讲解的非常的详细,也此就不再赘说了。
下面举两个小例子:事前准备:下载附件,解压。
安装RTX 51软件包,(注KEIL C 版本必须是7.02版本以上)实例1:(最好的例子是安装后程序处带的examples,我就是认真看了交通灯那个例子后才调通了下面的LED流水灯程序的)#include#includeconst unsigned char table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x00};/*时间到空间的转换,如果table是:const unsigned char table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};则算法和代码会多出一倍来。
RTX51 Tiny 中文手册RTX51 Tiny第二版(版本)是RTX51 Tiny 的升级版本,他完全集成在keil的集成开发环境中。
RTX51 Tiny是一款可以运行在大多数8051兼容的器件及其派生器件上的实时操作系统(准实时),相对与传统的开发方式而言,用实时操作系统进行开发是一种效率更高的方式。
作为实时操作系统,R TX51 Tiny虽然比较简陋,但它还是具备了一些实时操作系统的基本要素,完全可以充当我们进入实时操作系统(RTOS)世界的领路者,更为重要的是,它是免费的。
:-)从本节起,我会陆续将keil帮助文件中的RTX51 Tiny第二版的使用手册翻译为中文,并发布给大家,供大家参考。
RTX51 Tiny 中文手册 part1RTX51 Tiny第2版用户手册第一章概述RTX51 Tiny是一种实时操作系统(RTOS),可以用它来建立多个任务(函数)同时执行的应用。
嵌入式应用系统经常有这种需求。
RTOS可以提供调度、维护、同步等功能。
实时操作系统能灵活的调度系统资源,像CPU和存储器,并且提供任务间的通信。
RTX 51 Tiny是一个功能强大的RTOS,且易于使用,它用于8051系列的微控制器。
RTX51 Tiny的程序用标准的C语言构造,由Keil C51 C编译器编译。
用户可以很容易的定义任务函数,而不需要进行复杂的栈和变量结构配置,只需包含一个指定的头文件。
一、What’s NewRTX51 Tiny第二版增加了许多新特性,使得实时软件的开发更加简单,如:支持Code Banking该选项必须在配置文件中允许,还要在文件中定义Code Banking硬件配置。
直接任务切换新增加的函数(os_swich_task)允许一个任务立即切换到另一个处于就绪态的任务。
任务就绪标志新的库函数isr_set_ready和os_set_ready允许用户给一个任务设置就绪标志。
就绪标志可以用于将一个正在等待时间间隔、超时或信号(参见os_wait)的任务置为就绪态,该任务在下一个运行时机恢复。
CPU空闲模式支持支持用户在定时器中断的代码现在可以在定时器滴答中断中加入自己的代码。
该选项必须在中被允许支持时间间隔调整当在os_wait中混合使用时间间隔和信号时,可用os_reset_interval函数调整时间间隔超时值。
此外,RTX51 Tiny 进行了完全重构,以增加灵活性,加快执行速度,减少代码和数据空间需求。
当满足以下条件时,RTX51 Tiny第二版在代码大小上的缩小尤为显著。
1、禁止任务的时间轮转2、尽量少的RTX51 Tiny系统函数调用3、禁止栈检查禁止任务时间轮转同时也降低了数据空间的需求。
二、已解决的问题以下是在版中已知的问题,已在第二版中得到了修正.1、在RTX51 中当在os_wait期间产生一个中断时,isr_send_signal数可能会破坏就绪状态,导致任务挂起,等待从中断发来的信号,该问题在RTX Tiny2中已解决。
2、在RTX51 中,由于信号产生时时间间隔定时器的值不能被调整,因而K_IVL和K_SIG事件不能在os_wait中合并为一个调用。
在RTX Tiny2中,提供的os_reset_interval函数允许调整间隔定时器。
3、在RTX51 中,TIMESHARING不能被设为1,如果设为1,并且在时间片轮转前产生了中断,时间轮转周期可能被破坏,成为延迟256个滴答数,而不是1个。
该问题在第2版中解决。
4、在RTX51 中,当用户中断执行的时间比系统时钟滴答时间长时,RTX51 Tiny系统时钟定时器就会递归调用,这导致SAVEPSW和SAVEACC的覆盖,引起系统崩溃。
该问题在RTX51 T iny第2版中解决。
如果在应用中包含一个执行时间大于RTX51 Tiny系统时钟定时间隔的中断程序,可以将LONG_USR_INTR设为1。
如果应用程序在高优先级中断程序中消耗大量时间,很可能会用到这个选项。
三、产品规约(产品规格说明)四、工具需求以下为使用RTX51 Tiny需要的应用软件:C51编译器A51宏汇编器BL51连接器或LX51连接器和库文件必须保存于库路径下,通常,该路径是"KEIL"C51"LIB文件夹。
必须保存在包含路径下,通常是"KEIL"C51"INC文件夹。
五、目标需求RTX51 Tiny运行于大多数8051兼容的器件及其变种上。
RTX51 Tiny应用程序可以访问外部数据存储器,但内核无此需求。
RTX51 Tiny支持Keil C51编译器全部的存储模式。
存储模式的选择只影响应用程序对象的位置,RTX51 Tiny系统变量和应用程序栈空间总是位于8051的内部存储区(DATA或I DATA区),一般情况下,应用程序应使用小(SMALL)模式。
RTX51 Tiny执行协作式任务切换(每个任务调用一个操作系统例程)和时间片轮转任务切换(每个任务在操作系统切换到下一个任务前运行一个固定的时间段),不支持抢先式任务切换以及任务优先级。
RTX51 Full支持抢先式任务切换。
1、中断RTX51 Tiny与中断函数并行运作,中断服务程序可以通过发送信号(用isr_send_sig nal函数)或设置任务的就序标志(用isr_set_redy函数)与RTX51 Tiny的任务进行通信。
如同在一个标准的,没有RTX51 Tiny的应用中一样,中断例程必须在RTX51Tiny应用中实现并允许,RTX51 Tinyim 没有中断服务程序的管理。
RTX51 Tiny使用定时器0、定时器0中断,和寄存器组1。
如果在程序中使用了定时器0,则RTX51 Tiny将不能正常运转。
你可以在RTX51 Tiny定时器0的中断服务程序后追加自己的定时器0中断服务程序代码(参见硬件定时器)。
RTX51 Tiny假设总中断总是允许(EA=1)。
RTX51 Tiny库例程在需要时改变中断系统(EA)的状态,以确保RTX51 Tiny的内部结构不被中断破坏。
当允许或禁止总中断时,RT X51 Tiny只是简单的改变EA的状态,不保存并重装EA,EA只是简单的被置位或清除。
因此,如果你的程序在调用RTX51例程前某止了中断,RTX51可能会失去响应。
在程序的临界区,可能需要在短时间内禁止中断。
但是,在中断禁止后,不能调用任何RTX51 Tiny的例程。
如果程序确实需要禁止中断,应该持续很短的时间。
2、再入函数C51编译器提供对再入函数的支持,再入函数在再入堆栈中存储参数和局部变量,从而保护递归调用或并行调用。
RTX51 Tiny不支持对C51再入栈的任何管理。
因此,如果在程序中使用再入函数,必须确保这此函数不调用任何RTX51 Tiny系统函数,且不被循环任务切掉所打断。
仅用寄存器传递参数和保存自动变量的C函数具有内在的再入性,可以无限制的调用R TX51 Tiny。
非可再入C函数不能被超过一个以上的任务或中断过程调用。
非再入C51函数在静态存储区段保存参数和自动变量(局部数据),该区域在函数被多个任务同时调用或递归调用时可能会被修改。
如果确定多个任务不会递归(或同时)调用,则多个任务可以调用非再入函数。
通常,这意味着必须禁止循环任务调度,且该非再入函数不能调用任何RTX51 Tiny系统函数。
附注:如果希望在多个任务或中断中调用再入或非再入函数,应当禁止循环任务调度。
3、C库例程可再入C51库函数可在任何任务中无限制的使用。
对于非再入的C51库函数,同样有非可再入C函数的限制。
4、多数据指针Keil C51编译器允许使用多数据指针(存在于许多8051的派生芯片中), RTX51 Tiny 不提供对它们的支持.因此,在RTX51 Tiny的应用程序中应小心使用多数据指针。
从本质上说,必须确保循环任务切换不会在执行改变数据指针选择器的代码时发生。
附注:如果要使用多数据指针,应该禁止循环任务切换。
5、运算单元Keil C51编译器允许使用运算单元(存在于许多8051的派生芯片中)。
RTX51 Tiny 不提供对它们的支持。
因此,在RTX51 Tiny的应用程序中须小心使用运算单元。
从本质上说,必须确保循环任务切换不会在执行用运算单元的代码时发生。
附注:如果希望使用运算单元,应禁止循环任务切换。
6、寄存器组RTX51 Tiny分配所有的任务到寄存器0,因此,所有的函数必须用C51的默认设置进行编译,REGISTERBANK(0)。
中断函数可以使用剩余的寄存器组。
然而,RTX51 Tiny需要寄存器组区域中的6个永久性的字节,用于这些字节的寄存器组在配置文件中指定。
RTX51 Tiny 中文手册 part2第二章实时程序实时程序必须对实时发生的事件快速响应。
事件很少的程序不用实时操作系统也很容易实现。
随着事件的增加,编程的复杂程度和难度也随之增大,这正是RTOS的用武之地。
一、单任务程序嵌入式程序和标准C程序都是从main函数开始执行的,在嵌入式应用中,main通常是一个无限循环,可以认为是一个持续执行的单个任务,例如:void main (void)﹛while(1) /*永远重复*/﹛do_something(); /*执行 do_something“任务”*/﹜﹜在这个例子里,do_something函数可以认为是一个单任务,由于仅有一个任务在执行,所以没有必要进行多任务处理或使用多任务操作系统。
二、多任务程序许多C程序通过在一个循环里调用服务函数(或任务)来实现伪多任务调度。
如:void main(void)﹛int counter="0";while(1) /*一直重复执行*/﹛check_serial_io(); /*检查串行输入*/process_serial_cmds() ; /*处理串行输入*/check_kbd_io(); /*检查键盘输入*/process_kbd_cmds(); /*处理键盘输入*/adjust|ctrlr_parms(); /*调整控制器*/counter++; /*增加计数器*/﹜﹜该例中,每个函数执行一个单独的操作或任务,函数(或任务)按次序依次执行。
当任务越来越多,调度问题就被自然而然的提出来了。
例如,如果process_kbd_cmds 函数执行时间较长,主循环就可能需要较长的时间才能返回来执行check_sericd_io函数,导致串行数据可能被丢失。
当然,可以在主循环中更频繁的调用check_serial_io函数以纠正这个问题,但最终这个方法还是会失效三、RTX51 Tiny 程序当使用Rtx51Tiny时,为每个任务建立独立的任务函数,例如:void check_serial_io_task(void) _task_ 1﹛/*该任务检测串行I/0*/﹜void process_serial_cmds_task(void) _task_ 2﹛/*该任务处理串行命令*/﹜void check_kbd_io_task(void) _task_ 3﹛/*该任务检测键盘I/O*/﹜void process_kbd_cmds_task(void) _task_ 4﹛/*处理键盘命令*/﹜void startup-_task(void) _task_ 0﹛os_create_task(1); /*建立串行I /O任务*/os_create_task(2); /*建立串行命令任务*/os_create_task(3);/*建立键盘I/O 任务*/os_create_task(4); /*建立键盘命令任务*/os_delete_task(0); /*删除启动任务*/﹜该例中,每个函数定义为一个RTX51 Tiny任务。