Skip to Main Content Skip to Search
Product Documentation

Model Setup for Embedded Targets

Block Selection

You can create models for targeting the same way you create other Simulink models—by combining standard blocks and C-MEX S-functions.

You can use blocks from the following sources:

Avoid using blocks that do not generate code, including the following blocks.

Block Name/Category

Library

Description

Scope

Simulink, DSP System Toolbox software

Provides oscilloscope view of your output. Do not use the Save data to workspace option on the Data history pane in the Scope Parameters dialog box.

To Workspace

Simulink

Return data to your MATLAB workspace.

From Workspace

Simulink

Send data to your model from your MATLAB workspace.

Spectrum Scope

DSP System Toolbox

Compute and display the short-time FFT of a signal. It has internal buffering that can slow your process without adding value.

To File

Simulink

Send data to a file on your host machine.

From File

Simulink

Get data from a file on your host machine.

Triggered to Workspace

DSP System Toolbox

Send data to your MATLAB workspace.

Signal To Workspace

DSP System Toolbox

Send a signal to your MATLAB workspace.

Signal From Workspace

DSP System Toolbox

Get a signal from your MATLAB workspace.

Triggered Signal From Workspace

DSP System Toolbox

Get a signal from your MATLAB workspace.

To Wave device

DSP System Toolbox

Send data to a .wav device.

From Wave device

DSP System Toolbox

Get data from a .wav device.

Target Preferences

This topic contains the following subtopics:

Supported IDEs

This Target Preferences section applies to the following IDEs:

What is a Target Preferences Block?

If you are preparing to generate code for a target processor, add a Target Preferences block to the model. You can use the Target Preferences block to specify information such as the processor, board, hardware settings, operating system, memory map, and code generation features. Simulink Coder, Embedded Coder, and Simulink products use this information to generate code from your model.

For detailed information about the Target Preference block parameters and options, consult the Target Preferences block reference topic.

Adding a Target Preferences Block to Your Model

To generate code, with few exceptions, your model must contain only one Target Preferences block.

To add a Target Preferences block to your model:

  1. Open the Simulink library browser.

  2. Copy the Target Preferences block from the Embedded Coder > Embedded Targets library to your model

  3. The software displays the Initialize Configuration Parameters dialog box. For example.

    Set the following parameters, and click Yes:

    • IDE/Tool Chain

    • Board

    • Processor

    When you click Yes, the software automatically sets the model Configuration Parameters for the IDE/Tool Chain, Board, and Processor you selected. You have completed the process of adding a Target Preferences block to your model.

    If you click No, the software leaves the values of the Configuration Parameters unchanged. The model cannot simulate or generate valid code unless you configure the Configuration Parameters with the right values. Setting these values manually can be difficult.

      Note   The following actions update the appropriate model Configuration Parameters with new values:

      • Adding a Target Preferences block to your model and clicking Yes in the Initialize Configuration Parameters dialog box.

      • Opening the Target Preferences block in your model and selecting a new IDE/Tool Chain.

      • Opening the Target Preferences block in your model and applying changes to the Board and Processor parameters.

      Note   The Initialize Configuration Parameters dialog box uses your previous selections for IDE/Tool Chain, Board, and Processor as default values the next time you copy a Target Preference block to a model.

Creating a Library of Customized Target Preferences Blocks

If you work regularly with a variety of IDEs, tool chains, boards and processors, you can save time by creating a library of customized Target Preferences blocks. Later, you reuse these preconfigured Target Preferences blocks instead repeating the customization process on a new Target Preferences block.

To create a library of customized Target Preferences blocks:

  1. In Simulink, select File > New > Library. This action creates a new untitled library.

  2. Save the library to a folder included in your MATLAB search paths.

      Note   Click File > Set Path to see a list of MATLAB search paths and add new ones.

  3. Copy or drag configured Target Preferences blocks from your models to the library.

  4. Edit the label of each block to describe that block's configuration.

  5. After the new blocks are added and labeled, save the library.

To copy a Target Preferences block from your library to a model, type the library name at the MATLAB command line. When the library appears, copy the block to your model.

Configuration Parameters

What are Configuration Parameters?

To see the model Configuration Parameters, open the Configuration Parameters dialog box. You can do this in the model editor by selecting Simulation > Configuration Parameters , or by pressing Ctrl+E on your keyboard.

The Configuration Parameters dialog box specifies the values for a model's active configuration set. These parameters determine the type of solver used, the import and export settings, and other values that determine how the model runs.

To set the Configuration Parameters to the right values for you to generate code from your model, add a Target Preferences block to your model. This action initializes the model Configuration Parameters to the right default values for you to generate code. You can then use the Configuration Parameters dialog box to make further modifications to the values.

For more information, see Configuration Parameters Dialog Box and Managing Model Configurations.

Setting Model Configuration Parameters

To apply the right default values in Configuration Parameters, add a Target Preferences block to your model and select the Initialize Configuration Parameters, as described in Adding a Target Preferences Block to Your Model. You can generate buildable code using these default values.

To make further changes, select Simulation > Configuration Parameters in the Model Editor, or press Ctrl+E. This action opens the Configuration Parameters dialog box.

The following subsections provide a quick overview of the panes and parameters with which you are most likely to interact.

Code Generation Pane.  When you set System target file to idelink_ert.tlc or idelink_grt.tlc, the dialog box adds an IDE Link pane to the list of panes under Code Generation.

Leave Language set to C. The idelink_ert.tlc and idelink_grt.tlc system target files do not support C++ code generation.

For more information, see Code Generation Pane: General

IDE Link Pane Parameters.  

The IDE Link entry provides options in these areas:

For more information, see Code Generation Pane: IDE Link.

Build format.  

Select Project to create an IDE project, or select Makefile to create a makefile build script.

Build action.  

Your selection for Build action determines what happens when you click Build or press Ctrl+B. Your selection tells Simulink Coder software when to stop the code generation and build process.

To run your model on the processor, select Build_and_execute. This selection is the default build action.

The actions are cumulative—each action performs an additional step relative to the preceding action on the list.

If you set Build format to Project, select one of the following options:

If you set Build format to Makefile, select one of the following options:

Overrun notification.  

To enable the overrun indicator, choose one of three ways for the target to respond to an overrun condition in your model:

Function name.  

When you select Call_custom_function from the Overrun notification list, you enable this option. Enter the name of the function the target should use to notify you that an overrun condition occurred. The function must exist in your code on the target processor.

Configuration.  

The Configuration parameter defines sets of build options that apply to all of the files generated from your model.

The Release and Debug option apply build settings that are defined by your compiler. For more information, refer to your compiler documentation.

Custom has the same default values as Release, but:

Compiler options string.  

To determine the degree of optimization provided by the optimizing compiler, enter the optimization level to apply to files in your project. For details about the compiler options, refer to your IDE documentation. When you create new projects, the coder product does not set any optimization flags.

With Texas Instruments Code Composer Studio 3.3 and Analog Devices™ VisualDSP++, the user interface displays Get From IDE and Reset buttons next to this parameter. If you have an active project open in the IDE, you can click Get From IDE to import the compiler option setting from the current project in the IDE. To reset the compiler option to the default value, click Reset.

Linker options string.  

To specify the options provided by the linker during link time, you enter the linker options as a string. For details about the linker options, refer to your IDE documentation. When you create new projects, the coder product does not set any linker options.

With Texas Instruments Code Composer Studio 3.3 and Analog Devices VisualDSP++, the user interface displays Get From IDE and Reset buttons next to this parameter. If you have an active project open in the IDE, you can click Get From IDE to import the linker options string from the current project in the IDE. To reset the linker options to the default value of no options, click Reset.

System stack size (MAUs).  

Enter the amount of memory that is available for allocating stack data, measured in minimum addressable units (MAU). Block output buffers are placed on the stack until the stack memory is fully allocated. After that, the output buffers go in global memory. An MAU is typically 1 byte, but its size can vary by target processor.

This parameter is used in all targets to allocate the stack size for the generated application. For example, with embedded processors that are not running an operating system, this parameter determines the total stack space that can be used for the application. For operating systems such as Linux or WindowsVxWorks, this value specifies the stack space allocated per thread.

This parameter also affects the Maximum stack size (bytes) parameter, located in the Optimization > Signals and Parameters pane.

System heap size (MAUs).  

Set the default heap size that the target processor reserves for dynamic memory allocation.

The target processor uses this heap for functions like printf() and system services code.

The following IDEs use this parameter:

Profile real-time execution.  

To enable the real-time execution profile capability, select Profile real-time execution. With this selected, the build process instruments your code to provide performance profiling at the task level or for atomic subsystems. When you run your code, the executed code reports the profiling information in an HTML report.

Link Automation.  

When you build a model for a target, the coder product automatically creates or uses an existing IDE handle object (named IDE_Obj, by default) to connect to your IDE.

Although IDE_Obj is a handle for a specific instance of the IDE, it also contains information about the IDE instance to which it refers, such as the target the IDE accesses. In this pane, the Export IDE link handle to base workspace option lets you instruct the coder product to export the object to your MATLAB workspace, giving it the name you assign in IDE link handle name.

You can also use the IDE handle object to interact with the IDE using IDE Automation Interface commands.

Maximum time allowed to build project (s).  

Specifies how long the software waits for the IDE to build the software.

Maximum time allowed to complete IDE operation (s).  

Specifies how long the software waits for IDE functions, such as read or write, to return completion messages. If you do not specify a timeout, the default value is 10 seconds.

Export IDE link handle to base workspace.  

Directs the software to export the IDE_Obj object to your MATLAB workspace.

IDE link handle name.  

Specifies the name of the IDE_Obj object that the build process creates.

Source file replacement.  

Selects the diagnostic action to take if the software detects conflicts when you replace source code with custom code. The diagnostic message responds to both source file replacement in the Configuration Parameters under Code Generation > IDE link parameters and under Code Generation > Custom Code.

The following settings define the messages you see and how the code generation process responds:

The build operation continues if you select warning and the software detects custom code replacement problems. You see warning messages as the build progresses.

Select error the first time you build your project after you specify custom code to use. The error messages can help you diagnose problems with your custom code replacement files. Use none when the replacement process is accurate and you do not want to see multiple messages during your build.

Model Reference

The idelink_ert.tlc and idelink_grt.tlc system target files provide support for generating code from models that use Model Reference. A referenced model will generate an archive library.

To enable Model Reference builds:

  1. Open your referenced model.

  2. Select Simulation > Configuration Parameters from the model menus.

  3. From the list of panes under Code Generation, choose IDE Link.

  4. In the right pane, under Run-Time, select Archive_library from the Build action list.

If your top-model uses a reference model that does not have the Build action set to Archive_library, the build process automatically changes the Build action to Archive_library and issues a warning about the change.

Target Preferences Blocks in Reference Models

Include a configured Target Preferences block in each referenced model and the top-model . Configure all of the Target Preferences blocks for the same processor so that the software tool chain and build process is consistent across the model hierarchy.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS