Blockset described on this wiki is deprecated since 2012.

For Model Based Design (MBD), use the free MPLAB Device Blocks for Simulink, tool from Microchip.
Updated Rapid Control Prototyping (RCP) custom projects are published at:

DsPIC Block/C Function Call

From - Simulink device driver Blockset for dsPIC / PIC24 / PIC32 Microcontrollers --[[User:LubinKerhuel|LubinKerhuel]] 12:40, 3 September 2009 (UTC)
Jump to navigation Jump to search
Block C Function Call

Call user defined C function

The C Function Call block allows to include your custom C written functions (that could contain assembly language) into the schematic. It Interfaces your functions with the MathWorks Simulink diagram. The .c file containing the code of the function should be placed in the same directory as the .mdl file. If the c file is in another directory, it must be manually added in the "Configuration Parameters > Code Generation > Custom Code > include list of additional: Source files ; Include directories ; Libraries..."

Dialog Box Parameters

C Function Call Dialog

Function Name

Enter your C function name between single quotes 'zzz'. Do not provide the prototype.

Global input size

Specify if the variables of the inputs are scalar (1) or vector ( >1 : array with one dimension). All different input data have the same size. they must all be either scalars nor vectors of equal dimension.

Input 1 2 3

Set the input type for the first three input. Set unused input as -- (all to -- if no input)

Output Size

Size of the output variable. It can be either a scalar (1) ; neither a vector ( >1 : array with one dimension)

Output type

data type of the output data.

Sample time

-1 means inherited

Function declaration

This is the declaration of your function in the generated Matlab/Simulink C files. Your C function declaration must be compatible with this prorotype.

Function call

This is the call of your function in the Matlab/Simulink C files. Your function must comply with this call.

  • %y represent blocks output
  • %u represent blocks input

<comments \>