色哟哟视频在线观看-色哟哟视频在线-色哟哟欧美15最新在线-色哟哟免费在线观看-国产l精品国产亚洲区在线观看-国产l精品国产亚洲区久久

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何將單片機(jī)操作系統(tǒng)RTX51移植到單片機(jī)實(shí)驗(yàn)平臺(tái)

Wildesbeast ? 來源:?jiǎn)纹瑱C(jī)教程網(wǎng) ? 作者:?jiǎn)纹瑱C(jī)教程網(wǎng) ? 2020-09-26 11:07 ? 次閱讀

RTX51原理注釋:由于英文原文會(huì)比較好,所以我沒有翻譯過來(不過也寫了部分的翻譯),直接提取出來一些英文,總結(jié)在一起。

1. 進(jìn)程管理( Task Management )

1) 進(jìn)程類型( Classes of Tasks )

RTX-51 recognizes two classes of tasks:

1. Fast tasks

n Contain especially short responses and interrupt disable times.

n Contain a separate register bank and a separate stack area (register banks 1, 2 and 3)。(Figure 1)

n Contain the highest task priority (priority 3) and can therefore interrupt standard tasks.

n All contain the same priority and can therefore not be mutually interrupted.

n Can be interrupted by c51 interrupt functions.

n A maximum of three fast tasks can be active in the system.

2. Standard tasks

n Require somewhat more time for the task switching compared to fast tasks.

n Share a common register bank and a common stack area (register bank 0)。

n The current contents of registers and stack are stored in the external (XDATA) memory during a task change.

n Can be interrupted by fast tasks.

n Can interrupt themselves mutually.

n Can be interrupt by c51 interrupt functions.

n A maximum 16 standard tasks can be active in the system.

每一個(gè)標(biāo)準(zhǔn)進(jìn)程都包含一個(gè)設(shè)備上下文在擴(kuò)展內(nèi)存(XDATA)中。在標(biāo)準(zhǔn)進(jìn)程執(zhí)行進(jìn)程切換的時(shí)候,會(huì)把它自己的Register和Stack存儲(chǔ)到對(duì)應(yīng)的設(shè)備上下文中(在擴(kuò)展內(nèi)存中的一個(gè)區(qū)域)。之后,Register和Statck又從設(shè)備上下文中重新載入,繼續(xù)執(zhí)行。(交換技術(shù))

相比而言,快速進(jìn)程則不用這么麻煩,因?yàn)樗鼈冇懈髯元?dú)立的Register和Stack,所以只要激活對(duì)應(yīng)的Register(修改PSW)和指向Stack的指針(Mov SP,#XX)即可。

2) 進(jìn)程狀態(tài)(Task states)

RTX-51 recognizes four task states:

1. READY All tasks which can run are READY. One of these tasks is the RUNNING (ACTIVE)task.

2. RUNNING (ACTIVE) Task which is currently being executed bythe processor. Only one task (maximum) can be in this state at a time.

3. BLOCKED (WAITING) Task waits for an event.

4. SLEEPING All tasks which were not started or which have terminated themselves are in this state.

3) 進(jìn)程調(diào)度(Task switch)

The RTX-51 system section which the processors assigns to the individual tasks is referred to as the scheduler (also dispatcher)。

The RTX_51 scheduler works according to the following rules:

1. The task with the highest priority of all tasks in the READY state is executed.

2. If several tasks of the same priority are in the READY state,the task that has been ready the longest will be the next to execute.

3. Task switchings are only executed if the first rule would have been otherwise violated (exception: round-robin scheduling)。

Time-slice task change (round-robin scheduling) are executed if the following conditions are satisfied:

1. Round-robin scheduling must be enabled (see configuration)。

2. The RUNNING task has the priority of 0 and is currently not executing a floating-point operation (see section “Floating-Point Operations”, page 28)。

3. At least one task with the priority zero must be in the READY state.

4. The last task change must have occurred after the selected system time interval (see system function “os_set_slice”)。 The system time interval can be changed dynamically during program execution.

4) 進(jìn)程通信和同步(Task Communication and Synchronisation)

There three two mechanisms:

1. Signal

Signals represent the simplest and fastest form of task communication. These can always be used when a pure task synchronisation is required without data exchange.

Each active task contains its own signal flag with which the following operations can be executed:

l Wait for a signal

l Send signal

l Clear signal

The task number (see section section “Task Declaration”) of the receiver task is used for identifying the signals for the individual operations.

2. Message(via MailBoxes(FIFO))

n By means of the mailbox concept, messages can be exchanged free of conflicts between the individual tasks.

n RTX-51 provides a fixed number of eight mailboxes. Messages can be exchanged in words (2 bytes) via these mailboxes. In this case, a message can represent the actual data to be transferred or the identification of a data buffer(defined by the user)。 In comparison to the signals, mailboxes are not assigned a fixed task, but can be freely used by all tasks and interrupt functions. These are identified with a mailbox number.

Mailboxes allow the following operations:

l Send a message

l Read a message

Each mailbox is internally consists of three wait lists.(Figure 2)

Figure 2

1. Message list

List of the messages written in the mailbox. These comprise a maximum of eight messages.

2. Write wait list

Wait list for tasks which want to write a message in the message list of the mailbox (maximum 16 tasks)。

3. Read wait list

Wait list for tasks which want to read a message from the message list of the mailbox (maximum 16 tasks)。

3. Semaphore

n By means of the semaphore concept, resources can be shared free of conflicts between the individual tasks.

n A semaphore contains a token that your code acquires to continue execution. If the resource is already in use, the requesting task is blocked until the token is returned to the semaphore by its current owner.

n There are two types of semaphores: binary semaphores and counting semaphores. As its name implies, a binary semaphore can only take two values: zero or one (token is in or out)。 A counting semaphore, however, allows values between zero and 65535.

RTX-51 provides a fixed number of eight semaphores of the binary type.

Semaphores allow the following operations:

l Wait for token

l Return (send) token

2. 中斷管理

RTX-51 performs task synchronisation for external events by means of the interrupt system.

Two types of interrupt processing are basically supported in this case:

1. 單片機(jī)c語言 Interrupt Functions (Interrupt are processed by c51 interrupt funcions)

l Very sudden, periodically occurring interrupts without large coupling with the rest of the system (only infrequent communication with RTX-51 tasks, etc.)。

l Very important interrupts which must be served immediately independent of the current system state.

2. Task Interrupts(Interrupt are processed by fast or standard tasks of RTX-51

l Fast Task Interrupts

Important or periodic interrupts which must heavily communicate with the rest of the system when they occur.

l Standard Task Interrupts

Only seldom occurring interrupts which must not be served immediately.

RTX-51 shows considerable different response times for fast and standard tasks.

u The INTERRUPT ENABLE registers of the 8051 are managed by RTX-51 and must not be directly manipulated by the user!

u The Interrupt Priority registers of the 8051 (not to be confused with the softwaretask priorities) are not influenced by RTX-51.

3. 動(dòng)態(tài)內(nèi)存管理

RTX-51 uses a simple and effective algorithm, which functions with memory blocks of a fixed size. All memory blocks of the same size are managed in a socalled memory pool. A maximum of 16 memory pools each a different block size can be defined. A maximum of 255 memory blocks can be managed in each pool.

n Generate Memory Pool

The application can generate a maximum of 16 memory pools with various block sizes. The application must provide an XDATA area for this purpose. The pool is stored and managed by RTX-51 in this area (see system function “os_create_pool”)。

n Request Memory Block from Pool

As soon as a pool has been generated, the application can request memory

blocks. The individual pools are identified by their block size in this case.

If an additional block is still free in the pool, RTX-51 supplies the start address

of this block to the application. If no block is free, a null pointer is returned (see

system function “os_get_block”)。

n Return Memory Block to Pool

If the application no longer needs a requested memory block, it can be returned

to the pool for additional use (see system function “os_free_block”)。

4. 時(shí)間管理

RTX-51 maintains an internal time counter, which measures the relative time passed since system start. The physical source of this time base is a hardware timer that generates an interrupt periodically. The time passed between these interrupts is called a system time slice or a system tick.

This time base is used to support time dependent services, such as pause or timeout on a task wait.

Three time-related functions are supported:

n Set system time slice

The period between the interrupts of the system timer sets the “granularity” of the time base. The length of this period, also called a time slice, can be set by the application in a wide range (see system function “os_set_slice”)。

n Delay a task

A task may be delayed for a selectable number of time slices. Upon calling this system function the task will be blocked (sleep) until the specified number of system ticks has passed (see system function “os_wait”)。

n Cyclic task activation

For many real-time applications it is a requirement to do something on a regular basis. A periodic task activation can be achieved by the RTX interval wait function (see system function “os_wait”)。 The amount of time spent between two execution periods of the same task is controlled, using os_wait, and is measured in number of system ticks and may be set by the application.

5. RTX(FULL)函數(shù)縱覽(Functions Overview)

Initialize and Start the System:

os_start_system (task_number)

Task Management:

os_create_task (task_number)

os_delete_task (task_number)

os_ running_task_id ()

Interrupt Management:

os_attach_interrupt (interrupt)

os_detach_interrupt (interrupt)

os_enable_isr (interrupt)

os_disable_isr (interrupt)

os_wait (event_selector, timeout, 0)

oi_set_int_masks (ien0, ien1, ien2)

oi_reset_int_masks (ien0, ien1, ien2)

Signal Functions:

os_send_signal (task_number)

os_wait (event_selector, timeout, 0)

os_clear_signal (task_number)

isr_send_signal (task_number)

Message Functions:

os_send_message (mailbox, message, timeout)

os_wait (event_selector, timeout, *message)

isr_send_message (mailbox, message)

isr_recv_message (mailbox, *message)

Semaphore Functions:

os_send_token (semaphore)

os_wait (event_selector, timeout, 0)

Dynamic Memory Management:

os_create_pool (block_size, *memory, mem_size)

os_get_block (block_size)

os_free_block (block_size, *block)

Functions with the System Clock:

os_set_slice (timeslice)

os_wait (event_selector, timeout, 0)

Debug Functions:

os_check_tasks (*table)

os_check_task (task_number, *table)

os_check_mailboxes (*table)

os_check_mailbox (mailbox, *table)

os_check_semaphores (*table)

os_check_semaphore (semaphore, *table)

os_check_pool (block_size, *table)

三.RTX51移植

本試驗(yàn)是用的RTX的Tiny版本。也就是說沒有優(yōu)先級(jí)之分,沒有郵箱機(jī)制,沒有動(dòng)態(tài)內(nèi)存的管理。移植它很簡(jiǎn)單,就是配置一下它帶的配置文件,然后和寫好的程序一起編譯連接,連接的時(shí)候加一個(gè)rtxtny參數(shù),意思是說當(dāng)我連接的時(shí)候,我把RTXtiny的庫文件連接上,也就等于是程序和操作系統(tǒng)編譯在一起了。該配置文件能在安裝目的rtxtiny2底下找到。文件名稱為Conf_tny.A51,例如,在我的電腦中,路徑為:D:\Keil\單片機(jī)c語言\RtxTiny2\SourceCode\ Conf_tny.A51。如下圖所示:

由于試驗(yàn)箱里面的芯片是AT89C51,所以要配置Conf_tny.A51的RAMTOP EQU 07F,目的是說配置內(nèi)部RAM為128字節(jié)。

四.源程序代碼

源程序代碼如下,說明請(qǐng)看代碼里面的注釋。

/*

** RTX-51的移植

** 移植到AT89S52

** 此程序是循環(huán)花樣顯示LED燈

** 有三個(gè)顯示樣式,分別對(duì)應(yīng)下面的三個(gè)進(jìn)程

** 下面的算法中用到了“時(shí)間到空間”的轉(zhuǎn)換,使得算法簡(jiǎn)化不少

** 此程序我已在最小系統(tǒng)板上試驗(yàn)通過。

*/

#include 《reg51.h》

#include 《rtx51tny.h》

const unsigned char table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80

,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x00};

/*時(shí)間到空間的轉(zhuǎn)換,如果table是:

const unsigned char table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

則算法和代碼會(huì)多出一倍來。table數(shù)組雖然增加了一倍,算法也隨之減少了一半,

好處當(dāng)然不止在這里體現(xiàn),下面的進(jìn)程2也減少了一半*/

//進(jìn)程0 左-》右-》左

void LED0 (void) _task_ 0

{

int i;

os_create_task(1);//創(chuàng)建進(jìn)程1

os_create_task(2);//創(chuàng)建進(jìn)程2

while(1)

{

for (i = 0; i 《 15; i++)

{

P1 = table[i];

os_wait(K_TMO,30,0);//等待30*10000微妙 = 0.3秒

}

os_send_signal(1); //發(fā)送Signal信號(hào),激活進(jìn)程1

os_wait(K_SIG,0,0); //等待信號(hào)

}

}

//進(jìn)程1 全亮-》全滅-》全亮

void LED1 (void) _task_ 1

{

int i;

while(1)

{

os_wait(K_SIG,0,0);

for (i = 0; i 《 3; i++)

{

P1 = table[15]; //全亮

os_wait(K_TMO,30,0);

P1 = table[16]; //全滅

os_wait(K_TMO,30,0);

}

os_send_signal(2);

}

}

//進(jìn)程2 兩邊-》中間中間-》兩邊

void LED2 (void) _task_ 2

{

int i;

while(1)

{

os_wait(K_SIG,0,0);

for (i = 0; i 《 8; i++)

{

P1 = table[i] | table[i+7]; //由于table長(zhǎng)度多一倍,省去了一個(gè)循環(huán),而且算法也簡(jiǎn)化了。

os_wait(K_TMO,30,0);

}

os_send_signal(0);

}

}

五.總結(jié):

本試驗(yàn)用的RTX 的Tiny 版本。許多比較高級(jí)的功能沒有去實(shí)現(xiàn)。目的主要是理解RTX的原理,然后移植它到某個(gè)單片機(jī)上面,編寫個(gè)小程序來測(cè)試一下。通過閱讀RTX附帶的英文文檔,我對(duì)此操作系統(tǒng)有了深刻的認(rèn)識(shí),感到此操作系統(tǒng)有很多優(yōu)點(diǎn),也有很多不足的地方。比如支持的任務(wù)較少,不過由于是單片機(jī),“承受”能力也有限,也能理解。總的來說,對(duì)于單片機(jī)來說是個(gè)不錯(cuò)的操作系統(tǒng)。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 單片機(jī)
    +關(guān)注

    關(guān)注

    6042

    文章

    44617

    瀏覽量

    637583
  • RAM
    RAM
    +關(guān)注

    關(guān)注

    8

    文章

    1369

    瀏覽量

    114890
  • 內(nèi)存
    +關(guān)注

    關(guān)注

    8

    文章

    3052

    瀏覽量

    74217
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    多任務(wù)實(shí)時(shí)操作系統(tǒng)RTX51 Tiny的概念和應(yīng)用問題探究

    多任務(wù)實(shí)時(shí)操作系統(tǒng),可用來設(shè)計(jì)具有實(shí)時(shí)性要求的多任務(wù)軟件。 RTx51有2個(gè)版本:RTX51 Tiny和RTX51 Full。RTX51 T
    的頭像 發(fā)表于 09-03 17:48 ?5569次閱讀
    多任務(wù)實(shí)時(shí)<b class='flag-5'>操作系統(tǒng)</b><b class='flag-5'>RTX51</b> Tiny的概念和應(yīng)用問題探究

    基于RTX51的多功能電子鐘

    基于51單片機(jī)的實(shí)時(shí)操作系統(tǒng)RTX51編寫的多功能電子鐘,有電子鐘、時(shí)間可調(diào)、溫度測(cè)量、串口通信、方波發(fā)生器(頻率可調(diào))等功能。內(nèi)含完整Keil工程代碼和proteus仿真文件。實(shí)物本
    發(fā)表于 07-25 12:47

    RTX51 Tiny內(nèi)核應(yīng)用中有什么常見問題?

    多任務(wù)實(shí)時(shí)操作系統(tǒng),可用來設(shè)計(jì)具有實(shí)時(shí)性要求的多任務(wù)軟件。RTx51有2個(gè)版本:RTX51 Tiny和RTX51 Full。RTX51 Ti
    發(fā)表于 09-20 08:17

    如何將FreeRTOS實(shí)時(shí)操作系統(tǒng)移植STM32單片機(jī)

    前言本文主要講解如何將FreeRTOS實(shí)時(shí)操作系統(tǒng)移植STM32單片機(jī)中,在本文之前已經(jīng)基于MDK集成開發(fā)環(huán)境
    發(fā)表于 01-11 08:15

    基于RTX51單片機(jī)軟件設(shè)計(jì)

    隨著單片機(jī)應(yīng)用的日益廣泛,對(duì)它的軟件開發(fā)效率要求越來越高,從匯編到C 語言,然后過渡到了操作系統(tǒng)。MCS51 作為單片機(jī)世界的長(zhǎng)生不衰的主力軍,應(yīng)用于其上的
    發(fā)表于 04-16 11:02 ?122次下載

    基于RTX51單片機(jī)軟件設(shè)計(jì)

    隨著單片機(jī)應(yīng)用的日益廣泛,對(duì)它的軟件開發(fā)效率要求越來越高,從匯編到C 語言,然后過渡到了操作系統(tǒng)。MCS51 作為單片機(jī)世界的長(zhǎng)生不衰的主力軍,應(yīng)用于其上的
    發(fā)表于 05-14 16:01 ?41次下載

    RTX-51實(shí)時(shí)操作系統(tǒng)

    RTX-51 實(shí)時(shí)操作系統(tǒng),最基本的單片機(jī)系統(tǒng)資料
    發(fā)表于 01-13 11:48 ?38次下載

    51單片機(jī)多任務(wù)操作系統(tǒng)的原理與實(shí)現(xiàn)

    51單片機(jī)多任務(wù)操作系統(tǒng)的原理與實(shí)現(xiàn),在51單片機(jī)上模擬操作系統(tǒng)
    發(fā)表于 02-28 15:09 ?16次下載

    怎么樣把51單片機(jī)的程序移植AVR單片機(jī)

    講解如何把51單片機(jī)的程序移植AVR單片機(jī)
    的頭像 發(fā)表于 07-10 04:18 ?6958次閱讀
    怎么樣把<b class='flag-5'>51</b><b class='flag-5'>單片機(jī)</b>的程序<b class='flag-5'>移植</b><b class='flag-5'>到</b>AVR<b class='flag-5'>單片機(jī)</b>中

    使用RTX51進(jìn)行單片機(jī)軟件設(shè)計(jì)的資料說明

    很多單片機(jī)的應(yīng)用中都需要同時(shí)執(zhí)行很多任務(wù)。對(duì)于這樣的應(yīng)用,我們可以利用實(shí)時(shí)操作系統(tǒng)來靈活地安排系統(tǒng)資源。RTX51 是德國 Keil公司開發(fā)的一種應(yīng)用于MCS
    發(fā)表于 09-03 17:28 ?5次下載
    使用<b class='flag-5'>RTX51</b>進(jìn)行<b class='flag-5'>單片機(jī)</b>軟件設(shè)計(jì)的資料說明

    使用C51單片機(jī)和Proteus仿真進(jìn)行的RTX51操作系統(tǒng)應(yīng)用實(shí)例資料說明

    本文檔的主要內(nèi)容詳細(xì)介紹的是使用C51單片機(jī)和Proteus仿真進(jìn)行的RTX51操作系統(tǒng)應(yīng)用實(shí)例資料說明。
    發(fā)表于 05-20 08:00 ?8次下載
    使用C<b class='flag-5'>51</b><b class='flag-5'>單片機(jī)</b>和Proteus仿真進(jìn)行的<b class='flag-5'>RTX51</b><b class='flag-5'>操作系統(tǒng)</b>應(yīng)用實(shí)例資料說明

    51單片機(jī)多線程神器:Tiny-51操作系統(tǒng)

    給STC89C52RC單片機(jī)移植RTX-Tiny操作系統(tǒng),簡(jiǎn)單爆,B格拉滿了,好吧?
    發(fā)表于 11-11 20:51 ?59次下載
    <b class='flag-5'>51</b><b class='flag-5'>單片機(jī)</b>多線程神器:Tiny-<b class='flag-5'>51</b><b class='flag-5'>操作系統(tǒng)</b>

    華大單片機(jī)移植RTThread操作系統(tǒng)

    華大單片機(jī)移植RTThread-國產(chǎn)操作系統(tǒng)文章目錄華大單片機(jī)移植RTThread-國產(chǎn)操作系統(tǒng)
    發(fā)表于 11-17 17:21 ?53次下載
    華大<b class='flag-5'>單片機(jī)</b><b class='flag-5'>移植</b>RTThread<b class='flag-5'>操作系統(tǒng)</b>

    C51單片機(jī)與實(shí)時(shí)系統(tǒng)RTX51(Tiny / Full)

    C51單片機(jī)與實(shí)時(shí)系統(tǒng)RTX51(Tiny / Full)
    發(fā)表于 11-18 14:51 ?50次下載
    C<b class='flag-5'>51</b><b class='flag-5'>單片機(jī)</b>與實(shí)時(shí)<b class='flag-5'>系統(tǒng)</b><b class='flag-5'>RTX51</b>(Tiny / Full)

    如何將FreeRTOS移植STM32單片機(jī)

    本文詳細(xì)介紹如何移植FreeRTOSSTM32單片機(jī)上。移植操作系統(tǒng)是嵌入式開發(fā)的入門基礎(chǔ),單片機(jī)
    的頭像 發(fā)表于 01-20 17:36 ?3481次閱讀
    <b class='flag-5'>如何將</b>FreeRTOS<b class='flag-5'>移植</b><b class='flag-5'>到</b>STM32<b class='flag-5'>單片機(jī)</b>上
    主站蜘蛛池模板: 久草在线一免费新视频 | 国产人妻久久久精品麻豆 | 伊人yinren6综合网色狠狠 | 精品国产乱码久久久久久夜深人妻 | 蜜桃色欲AV久久无码精品 | 欧美大jiji| 18岁男人女人插孔 | 国产曰批试看免费视频播放免费 | 亚洲欧美日韩高清中文在线 | 考好老师让你做一次H | 精品无码久久久久久动漫 | 国产学生无码中文视频一区 | 小小水蜜桃3视频在线观看 小向美奈子厨房magnet | 伊人久久影院 | 国产亚洲精品免费视频 | 国产99久9在线 | 精品久久久久久久国产潘金莲 | nu77亚洲综合日韩精品 | 亚洲成熟人网站 | 日本少妇无码精品12P | xiao77唯美清纯 | 精品少妇爆AV无码专区 | 国产精品白浆精子流水合集 | 四库影院永久国产精品 | 亚洲精品久久久久一区二区三 | 国产99九九久久无码熟妇 | 99热.com| 国产成人啪精视频精东传媒网站 | 国产精品AV无码免费播放 | 久久精品天天爽夜夜爽 | 国内精品视频在线播放一区 | 专干老肥熟女视频网站300部 | 秋霞最新高清无码鲁丝片 | 波多野结衣 无码片 | 久久se视频精品视频在线 | 色精品极品国产在线视频 | 星空无限传媒视频在线观看视频 | 跳蛋按摩棒玉势PLAY高H | 中国女人逼 | 神马老子影院午夜伦 | 毛片基地看看成人免费 |