Share this

Building an Embedded System Development Environment under RTW

2026-04-06 07:46:02 · · #1
The development of microcontroller application systems generally follows a bottom-up process, which involves selecting appropriate components based on application requirements to design, manufacture, debug, and implement software functions. During system design, developers must first have a deep understanding of the specific hardware and then summarize usable solutions. The biggest drawback of this development process is its strong dependence on hardware; software design is limited by specific hardware platforms. However, using MATLAB/SIMULINK/RTW, a model-based top-down development process can be achieved. This process first builds a model of the entire system, allowing direct algorithm design and simulation in SIMULINK. Once the simulation structure meets design requirements, RTW automatically generates C code, which is then used by embedded cross-compilation tools to generate an application program that runs on the target machine. This shortens the product development cycle and reduces development costs. 1. MATLAB/RTW Code Generation Principle RTW (Real-Time Workshop) is an automatic code generation tool provided by MathWorks. It enables SIMULINK models to automatically generate code for different targets. MATLAB 7. MATLAB/RTW can generate ANSI C, ISO C, and GNU source code. It also provides an open interface for third parties or users to automatically generate code in other languages. MATLAB/RTW can generate code that runs on PCs, ARM processors, DSPs, and other devices, as well as executable files for Windows, Unix, Linux, VxWorks, and other systems. The RTW code generation process is shown in Figure 1. As shown in Figure 1, the user creates a SIMULINK model, MATLAB/RTW generates an rtw file from this model, provides it to the target language compiler TLC, and the system then compiles and links the various modules into the model's C source program using the specified target compilation tool. If the compile-and-download function is selected, RTW then calls the make function to compile the source program into an executable file that can run on the target machine, allowing the user to port this file to the target machine for execution. 2. SIMULINK Model Code Generation and Porting on ARM There are several solutions for developing programs on ARM using MATLAB/RTW. The most direct solution is to use hardware and software systems supported by RTW. This allows for code generation and download without requiring any changes to the compilation environment. Secondly, an embedded operating system can be ported to an ARM system, and the application module can be generated by RTW and then downloaded remotely via FTP. This solution requires installing a cross-compilation tool that can generate code for the target system when generating code with RTW. The third solution involves modifying the RTW's target compilation scheme, adding hardware drivers, and then using a dedicated ARM development download tool, ADS, to compile and download the target C source code after RTW generates it. This section introduces the third solution. The RTW code generation process consists of four steps: ① analyzing the model and compiling the model description file; ② generating code from the model using TLC; ③ generating a custom makefile; ④ generating an executable program. During model analysis, the corresponding simulation and module parameters, sampling time, and working vector size are first calculated to determine the execution order of each module in the model. At the end of the model analysis, an intermediate description file, model.rtw, is generated, and then TLC generates the C source code. This stage, based on model.rtw, compiles and executes the commands in the target file to generate C source code. The third stage generates a custom binder file, model.mk, which guides the binder to compile and link from the source code, main program, library files, or user-defined modules. Finally, a cross-compilation tool generates an executable file that can run on the target machine. During code generation, files related to the target system include system.tle, system.tmf, and system_main.c, which reside in the matlab7/rtw/c folder. Each target machine has one system.tle, one system_main.c, and several system.tmf files. Creating a custom target compilation environment requires creating these three files. For example, LPC2200.tmf and LPC2200_main.c are used. To simplify the setup process, first create an LPC2200 folder in matlab7/rtw/c. Copy grt.tlc, grt_lcc.tmf, and grt_main.c from the general real-time target grt to this folder and rename them to LPC2200.tlc, LPC2200.tmf, and LPC2200_main.c, respectively. Modify the template binding file specified in LPC2200.tlc: Add a target startup function in LPC2200_main.c, including the file and interface driver. This builds the development environment for the custom target. An additional LPC2200.tlc file appears in the target compiler parameters of MATLAB/RTW, as shown in Figure 2. After selecting the LPC2200 target, LPC2200.tmf appears in the Template makefile parameters of the RTW main interface, as shown in Figure 3. With the parameters set correctly, click the Build button, and RTW will automatically generate C source code suitable for running on LPC2200. Add the generated source code to the ADS project, compile and download it, and the porting of the SIMULINK model to the LPC2200 is complete. Conclusion The method described in this paper has been implemented in corresponding application systems on ARM and 51 microcontrollers. By quickly generating code prototypes, the complexity of manual code writing for designers is reduced, and the design process is accelerated. For a fixed target hardware system, as long as the compilation environment is designed once, the porting of the SIMULINK model to ARM can be achieved, i.e., hardware-in-the-loop simulation. The drawback of this design is that an operating system was not loaded on the target ARM system; therefore, every time the model is changed, all the code must be downloaded again, making it unsuitable for remote program downloading.
Read next

CATDOLL 123CM Milana TPE

Height: 123cm Weight: 23kg Shoulder Width: 32cm Bust/Waist/Hip: 61/54/70cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22