This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

C Caller

Integrate C code in Simulink

  • Library:
  • Simulink / User-Defined Functions

Description

The C Caller block integrates your external C code into Simulink®. This block imports and lists the functions in your external C code, and allows you to select your resolved C functions to integrate in your Simulink models. The C Caller block standalone supports code generation. For more complex models, code generation depends on the capabilities of your Simulink model.

To use C Caller block, define your source code and any supporting files using Simulation Target under Configuration Parameters. Then, bring a C Caller block to Simulink canvas, using Library Browser > Simulink > User Defined Functions. To change the defined source code file and its dependencies, go to Simulation Target tab in Configuration Parameters by clicking the from the block dialog. After changing your source code or any of its dependencies, refresh the list of functions by clicking the on the block dialog. To browse and modify the list of functions in your source code, use the icon to easily access to your header files.

Ports

Input

expand all

Input argument to the C Caller block.

Number of input arguments and their names are inferred through the selected function in your externaI C code. To receive data to your block, connect an input signal to the input ports.

Input label has the same name as your input argument unless changed by editing the Label column under Port Specification from the Block Dialog. If you rename the label to an input port, the C Caller block changes the name of the port.

For input variables, you can change the input scope to parameters or constants using the Scope column.

Data types supported in MATLAB®, but not supported in Simulink cannot be passed between C Caller and other MATLAB blocks.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Output

expand all

Output argument from the C Caller block.

Number of output arguments and their names are inferred through the selected function in your externaI C code. To send data from your C Caller block, connect a block to the output port of your C Caller block.

Output port label has the same name as your output argument unless you change it by editing the Label column under Port Specification from the Block Dialog. If you rename the label to an input port, the C Caller block changes the name of the port.

Data types supported in MATLAB, but not supported in Simulink cannot be passed between C Caller and other MATLAB blocks.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | enumerated | bus

Parameters

expand all

The C Caller block in your model imports all functions in your external source code, and shows the names of functions under Function name in block dialog. To select and use a function in your block, confirm that their names appear at the Function name. In case you are missing one of the functions, reload the source code by clicking on the block dialog box. To change the name of your functions, modify your source code and click the refresh button to reload your functions.

Port specification table indicates the attributes of each input and output element for the selected block. These properties include Argument name, scope, input/output label, type and size of the input/output variables. Argument name, scope, type, and size are inferred from your source code. If the type of scope is an input, you can modify this variable to a parameter or a constant.

Arg name — Demonstrates the variable name inferred from your source code.

Scope — Indicates the role of the variables from your source code. If the variable is an input argument in the C Caller block source code, you can change the scope type to a constant or a parameter. If the variable is an output argument in the source code, you cannot change the scope type.

Label — Labels the input or output variable for the Simulink model. You can change the labels using this table. If the scope is a parameter, enter the parameter name in this field. If the scope is a constant, enter the constant value.

Type — Indicates the data type coming from the ports.

Size — Indicates the size of the input and output data.

Block Characteristics

Data Types

double[a] | single[a] | Boolean[a] | base integer[a] | fixed point[a] | enumerated[a] | bus[a]

Direct Feedthrough

No

Multidimensional Signals

Yes[a]

Variable-Size Signals

No

Zero-Crossing Detection

No

[a] 

Actual data type or capability support depends on block implementation.

Extended Capabilities

Introduced in R2018b