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.
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How to identify the quality of wireless monitoring equipment?
- EEWORLD University ----TI sports camera and handheld stabilizer solutions
- EEWORLD University Hall----TI System-Level Power Design Seminar
- Quartus II USB-Blaster driver installation problems, three special solutions
- About the sending problem of single chip microcomputer serial port mode 3
- imx6ull transplant alsa
- Recommend a fast source code style conversion tool AStyle
- Talk about the future of Wi-Fi 6 and predict who will lead the wireless connection
- This circuit doesn't seem to work!
- TI Texas Instruments CCD