The hottest MCU software design based on RTX51

2022-10-18
  • Detail

Software design of single chip microcomputer based on RTX51

1 overview many single chip microcomputer applications need to perform many tasks at the same time. For such applications, we can use the real-time operating system to flexibly arrange system resources. RTX51 is a real-time multitask operating system developed by keil company in Germany and applied to MCS51 series single-chip computers. It can work in all 8051 single-chip computers and derived families, simplifying the complex software design and shortening the project cycle. In practice, we use RTX51 to develop the software of single chip microcomputer and design the software of GPS receiving board controlled by single chip microcomputer, which has achieved good results. 2 RTX51 introduction RTX51 has two modes: RTX51 full mode and minimum mode. RTX51 minimum mode version is a subset of RTX51 full version, which can easily run on 8051 system without external RAM (XDATA). RTX51 full mode has four task priorities, which can be processed in parallel with the interrupt function. Signals and messages are transmitted between tasks by using the "mailbox" system, and memory can be applied for and released from the memory pool; At the same time, a task can be forced to stop execution and wait for an interrupt, or the modification of materials may bring semaphores or messages from other interrupts to the thinning of products. The requirements of RTX51 for system hardware are listed in Table 1

description RTX51 full mode RTX51 minimum mode tasks 256, 19 active tasks, including 16 standard tasks, Three fast tasks 16ram40 ~ 46 bytes ram

20 ~ 200 bytes IData

at least 450 bytes xdata7 bytes data

3 * number of tasks IData

do not need xdatarom6kb ~ 8kb900 bytes timer timer 0 or 1 timer 0. Especially when these parts are made of machined metal or thermosetting material laminations, it can increase a lot of cost and weight table 12.1 RTX51 tasks RTX51 distinguishes two types of tasks: fast tasks and standard tasks. Fast tasks have fast response speed. Each fast task uses a separate register group of 8051 and has its own stack area. RTX51 supports up to three fast tasks at the same time. Standard tasks need a little more time to switch tasks, so the internal RAM used is relatively less than fast tasks. All standard tasks share a register group and stack. When the task is switched, the register state and stack content of the current task are transferred to the external memory. RTX51 supports up to 16 standard tasks. RTX51 task status: (1) running - the currently running task is in running status, and only one task can be run at the same time. (2) Ready - the task waiting to run is in the ready state. After the currently running task exits the running state, the task with the highest priority in the ready queue enters the running state. (3) Blocked - the task waiting for an event is in the blocked state. If the event occurs and the priority is higher than the running task, the task enters the running state; If the priority is lower than the running task, the task enters the ready state. (4) Deleted - tasks that have not started are in the deleted state. (5) Task switching -rtx51 includes an event driven task switching mechanism, which can switch according to the priority of tasks, that is, preemptive multitask system; In addition, there is an optional time slice rotation switching task mode. In the time slice rotation mode, tasks of the same level are to adjust the CPU occupation and optimize the industrial structure according to the time slice. RTX51 tasks have four priorities: 0, 1 and 2 can be assigned to standard tasks, and priority 3 is reserved for fast tasks. Each task can wait for the occurrence of events without increasing the burden of the system; Tasks can wait for messages, signals, interrupts, timeout events, or a combination of them. Task switching is carried out according to certain rules, including: tasks with high priority entering the "ready" state are executed first; If several tasks in the "ready" state have the same priority, the first to enter the "ready" state will be executed first. 2.2 RTX51 event * timeout: suspend the running task for a specified number of clock cycles* Interval: similar to timeout, but the software timer is not reset. The typical application is to generate a clock* Signal: used for task internal synchronization and coordination* Message: applicable to RTX51 full, used for information exchange. We can send a message to a specific mailbox. The message consists of 2 bytes, which can be the data defined by the user according to his own needs, or the pointer to the data. If the message list of the mailbox is full and the message is interrupted, the message will be lost; If the task sends a message, the task will enter the waiting state until the mailbox has a location to receive this message. The mailbox manages messages according to the principle of FIFO. If several tasks are waiting to receive messages, the one who first enters the waiting queue will receive messages. A mailbox can store up to 8 messages. When the mailbox is full, there can only be 16 waiting tasks at most* Interrupt: applicable to RTX51 full. A task can wait for 8051 hardware interrupt* Semaphore: applicable to RTX51 full. Semaphore is used to manage shared system resources compared with traditional polyethylene (PE) mulching film. Using "tokens" allows only one task to use certain resources at a time. If several tasks apply for access to the same resource, the one who first applies will be allowed to access, and other tasks will enter the waiting queue until the first task is completed, and the next task can continue. Os_ w

Copyright © 2011 JIN SHI