RTX51 Tiny的使用

     有时候进行单片机程序开发的时候我们需要用到多任务,这时就必须涉及到操作系统了,因为没有操作系统的话很难达到多任务协调调度的目的...以前我阅读过uCOS-II的源码,也曾将其移植到51系列单片机上,但是由于其需要很大的内存,单片机需另扩展RAM才能跑起来,所以此次电梯模拟的程序我决定使用KEIL的RTX51 Tiny.这可是为51系列单片机量身定做的超小操作系统.能实现基本的任务调度,任务通信等基本功能.
    RTX51 Tiny使用了定时器0为它提供时钟.所以应用程序中应避免使用定时器0.

    RTX51 Tiny中任务有以下五种状态(摘自keil的帮助文档):

    

StateDescription
RUNNINGThe task that is currently running is in the RUNNING State. Only one task at a time may be in this state. The os_running_task_id returns the task number of the currently executing task.
READYTasks which are ready to run are in the READY State. Once the Running task has completed processing, RTX51 Tiny selects and starts the next Ready task. A task may be made ready immediately (even if the task is waiting for a timeout or signal) by setting its ready flag using the os_set_ready or isr_set_ready functions.
WAITINGTasks which are waiting for an event are in the WAITING State. Once the event occurs, the task is switched to the READY State. The os_wait function is used to place a task in the WAITING State.
DELETEDTasks which have not been started or tasks which have been deleted are in the DELETED State. The os_delete_task routine places a task that has been started (with os_create_task) into the DELETED State
TIME-OUTTasks which were interrupted by a Round-Robin Time-Out are in the TIME-OUT State. This state is equivalent to the READY State for Round-Robin programs.

    RTX51 Tiny也可以配置成分时的操作系统,可以在配置文件中配置.

    RTX51 Tiny有一个IDLE task 在应用程序所有的任务不运行时,系统运行这个任务.这个任务很简单:SJMP $

    RTX51 Tiny的配置文件是/KEIL/C51/RTXTINY2/  下的CONF_TNY.A51, 可以参考帮助文档修改.

    使用RTX51 Tiny:

        1.包含头文件 RTX51TNY.H

        2.创建任务(至少一个,不需要main,因为操作系统有自己的main)

        3.任务0是第一个运行的

        4.至少使用一个操作系统的函数,使它连接库文件

        5.在Target里的Operation System中选择RTX-51 Tiny

    任务的定义方法:void func (void) _task_ task_id

    一共可以使用16个任务._task_是KEIL扩展关键字.

    调试时可以使用Peripherals菜单中的RTX51 Tiny Tasklist 查看任务列表与状态.

    以上是我今晚上看KEIL帮助总结的,顺便记录一下,为以后复习使用时方便.呵呵

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值