Transplantation of μCOS-Ⅱ on ARM Series MCU S3C44B0x

Publisher:ularof不加糖Latest update time:2011-10-18 Keywords:μCOS-Ⅱ  S3C44B0x Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction
At present, embedded systems have been more and more widely used in various fields such as industrial control, household appliances, mobile communications, PDAs, etc. As users have higher and higher requirements for the performance of embedded products, program design has become more and more complicated, which requires a general embedded real-time operating system to manage and control them. Designing and developing embedded systems with transplanted operating systems can greatly reduce the burden on programmers, and the system design can be completed in the same steps for different applications.
μC/OS-Ⅱ is a simple, efficient, and open source embedded real-time operating system with good scalability and portability, and is widely used in various embedded processors. The μCOS-Ⅱ operating system has a real-time kernel that can be solidified, tailored, and deprived, and can manage 64 system tasks at the same time. Using embedded microprocessors transplanted with the μCOS-Ⅱ operating system to design and develop products is of great significance to improving product performance, reducing product development cycles, and reducing development costs. This paper analyzes and introduces the transplantation process of the embedded real-time operating system μCOS-Ⅱ on the ARM series microcontroller S3C44B0x in detail.

1 Overview of μCOS-
ⅡμCOS-Ⅱ is an embedded real-time operating system with open source code, compact structure and a deprivable real-time kernel. μCOS-Ⅱ is written in ANSI C language and contains a small part of assembly language code, which can be used by microprocessors of different architectures. So far, from 8-bit to 64-bit, μCOS-Ⅱ has been running on more than 40 microprocessors of different architectures. μCOS-Ⅱ is specially designed for embedded applications. It includes basic functions such as task scheduling, task management, time management, memory management, and communication and synchronization between tasks. μCOS-Ⅱ has a portable, curable and tailorable real-time kernel. It has the characteristics of high execution efficiency, small space occupation, excellent real-time performance and strong scalability. It has been widely transplanted and applied to various embedded microprocessors.

2 S3C44B0 Processor Overview
The S3C44B0x microprocessor uses the high-performance, low-power 32-bit RISC core ARM7TDMI. At the same time, based on the ARM7TDMI core, S3C44B0x has expanded a series of peripheral devices to reduce the system cost and the number of peripheral devices to a minimum. These functional components are divided into CPU unit, system clock management unit, storage unit and system function interface unit. The main functions integrated on the chip are as follows:
8 KB of CACHE is added on the basis of ARM7TDMI; external expansion memory controller; LCD controller, and with 1 LCD dedicated DMA channel; 2 general DMA channels, 2 DMA with external request pins; 2 UARTs with handshake protocol, 1 SIO; 1 I2C bus controller; 5 PWM timers and 1 internal timer; 1 watchdog timer; 71 general programmable I/O ports, 8 external interrupt sources; power control modes: normal, low, sleep and stop; 8-way 10-bit ADC; RTC with calendar function; PLL clock generator, etc.

3. Porting of embedded operating system μCOS-Ⅱ
3.1. Conditions for porting μCOS-Ⅱ
Porting means enabling a real-time kernel to run on other microprocessors or microcontrollers. To facilitate porting, most of the μCOS-Ⅱ code is written in C language, but it is still necessary to write code related to processor hardware in C language and assembly language. This is because μCOS-Ⅱ can only use assembly language to read/write processor registers. To make μCOS-Ⅱ run normally, the processor must meet the following requirements:
(1) The processor's C compiler can generate reproducible code;
(2) The processor supports interrupts and can generate timer interrupts (usually 10 to 100 Hz); (3) Interrupts can be turned on/off using C language; (4) The processor can support a certain number of data storage hardware stacks; (5) The processor has instructions to read the contents of the stack pointer and other CPU registers and store them in the stack or memory. The ARM series microcontroller S3C44B0x
meets the above conditions. Therefore, μCOS-Ⅱ can be ported and applied to S3C44B0x. 3.2 Building the transplantation environment This transplantation was completed in the following environment: (1) The compiler tool uses ARM's ADS 1.2. ADS stands for ARM Developer Suite, which is a new generation of ARM integrated development tools launched by ARM. The latest version of ADS is 1.2, which replaces the earlier ADS 1.0 and ADS 1.1. ADS 1.2 consists of command line development tools, ARM real-time libraries, GUI development environment, utilities and support software. With these components, users can easily write and debug their own applications for ARM series processors. (2) The target board uses the S3C44B0x development board produced by Hangzhou Liyutai Company. The host connects to the target board through JTAG to establish a cross-development and debugging environment. 3.3 Transplantation of μCOS-Ⅱ The hardware/software architecture of μCOS-Ⅱ is shown in Figure 1. The transplantation of μCOS-Ⅱ is actually to rewrite or modify the code related to the processor.








As shown in Figure 1, porting μCOS-Ⅱ is actually to rewrite or modify the three files OSCPU.H, OS_CPU_A.ASM and OS_CPU_C.C. Since μCOS-Ⅱ is ported to the ARM series microcontroller S3CA4B0x in this porting, the main work done in this porting process will be introduced in detail in combination with the characteristics of the S3CA4B0x microprocessor.
(1) Porting OS_CPU.H file
The OS CPU.H file includes the definitions of processor-related constants and types defined by #define, which are consistent with the variable types defined by μCOS-Ⅱ; defines the macros OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() for turning on/off interrupts to protect the critical section code from interference from multitasking or interrupt service routines; defines the growth direction of the stack. In this porting, the growth direction of the stack is defined to grow from top to bottom, and the value of OS_STK_GROWTH is defined as 1. When porting this file, the code that needs to be written and modified is as follows:
① Set the data type related to the compiler


③Set the stack growth direction
The stack of most microprocessors and controllers grows from top to bottom, but some processors and controllers grow from bottom to top. μCOS-Ⅱ is designed to handle both cases, as long as the stack growth method is specified in the structure constant OS_STK_GROWTH. In this transplantation, the stack growth direction is set to grow from top to bottom.


(2) Port OS_CPU_C.C file
In this file, you need to write 10 simple C functions, which are:

The only function that must be written among these functions is OSTaskStkInit(). The other 9 functions must be declared but do not have to contain any code. OSTaskCreate() and OSTaskCreateExt() initialize the task stack structure by calling the OSTaskStkInit() function. Therefore, the stack looks like an interrupt has just occurred and all registers are saved to the stack. The program code of OSTaskStkInit() is as follows:



(3) Porting OS_CPU_A. ASM file
When porting OS_CPU_A. ASM file, users are required to write four simple assembly language functions, namely: OS-StartHighRdy(), OSCtxSw(), OSIntCtxSw(), OS-TickISR().
① OSStartHighRdy(): Run the highest priority ready task. This function is only executed once when multi-tasking is started, and is used to start the first (highest priority) task. Its program code is as follows:


②OSCtxSw(): Task-level task switching function. It implements the switching between tasks during normal operation of the CPU, completes the saving of the current task stack and the popping of the highest priority task stack, so that the highest priority task can be run.
③OSIntCtxSw(): Interrupt-level task switching function. After the interrupt service program is executed, if the interrupt makes the higher priority task ready, this function implements the task switching: save the execution scene of the task before the interrupt occurs. Restore the execution scene of the higher priority task that is already in the ready state, so that the higher priority task can be run, thereby completing the task switching.
④OSTickISR(): It is the interrupt service function of the system clock. The main function of this function is to check whether there is a task that has been suspended due to delay and has been turned into a ready state. If so, call the OSIntCtxSw() function to switch tasks, so that the task that is already in the ready state and has the highest priority can be run.

4 Test the transplant code
After transplanting μC/OS-Ⅱ to S3C44B0x, the next task is to verify whether the transplanted μC/OS-Ⅱ can work properly. Here, we use the method of testing the transplanted μC/OS-Ⅱ without adding any application code. This has two advantages: it makes the work of testing the transplant code easier; if some μC/OS-II codes cannot work properly, it can be understood that it is a problem with the transplanted code itself, not a problem caused by the application code. The test of the transplant code is completed through four steps: ensure that the C compiler, assembly compiler and linker work properly; verify OSTaskStkInit() and OSStartHighRdy() functions; verify OSCtxSw() function; verify OSIntCtxSw() and OSTick-ISR() functions. After testing, the above four test processes can all pass normally, indicating that the μC/OS-Ⅱ operating system transplanted to the ARM series microcontroller S3C44B0x can work properly.

5 Conclusion
μC/OS-II is a configurable and customizable embedded real-time operating system, which has been widely transplanted and applied to various processors. Here, μC/OS-Ⅱ is successfully transplanted to the ARM series microcontroller S3C44B0x. After testing, the transplanted μC/OS-Ⅱ code can run stably in the S3C44B0x processor.

Keywords:μCOS-Ⅱ  S3C44B0x Reference address:Transplantation of μCOS-Ⅱ on ARM Series MCU S3C44B0x

Previous article:Design of Inverter Power Supply Based on ARM7 and DSP
Next article:Development of serial port application program based on S3C2410 single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 15:19

Design of USB interface for embedded ECG and blood pressure monitor
  USB interface circuit design for monitor   The main control chip of the system adopts 32-bit high-performance embedded ARM microprocessor S3C44B0X, and the USB dedicated control chip is USBN9603. USBN9603 has 7 built-in FIFO ports, including 1 bidirectional control port, 3 sending ports and 3 receiving ports, each w
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号