This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-F28379D: Endat library in Simulink

Part Number: LAUNCHXL-F28379D


Tool/software: Code Composer Studio

Hello all,

I am trying to configure the endat2.2 library in Simulink model which is available here: 

https://de.mathworks.com/help/supportpkg/texasinstrumentsc2000/examples/permanent-magnet-synchronous-motor-field-oriented-control.html

Basically in TI, there is library made for this endat already available in ccs project: https://www.mouser.com.gt/datasheet/2/405/tidude3a-1386818.pdf

Now I want to incorporate this library into the simulink  model. Is it good Idea to include this c files in the simulink model and compile together? I am trying to include the header and source code

via C Coder block of Simulink but could not get funtion in the list. If anyone has an idea to incorporate this library of Endat in simulink, it would be great help.

Regards

Sanjaya

  • Hi Sanjaya,

    A MathWorks expert has been notified of your post and will reply back to you as soon as they can.

    Best Regards,

    Marlyn

  • Hi Sanjaya,

    You can do this using the custom code option. Attached is the picture for the same.

    Here is a link where is the user tried to use this feature for one of his use case.

    https://www.mathworks.com/matlabcentral/answers/480196-implementation-of-functions-not-supported-by-mathworks

  • Hello Venkatesh,

    thank you for your reply. I did the same and i am able to compile. But the problem is that I need to call these functions in the main file of the after all the code is generated. When I use c caller i cannot call them. Could you please tell me how can I call these functions?

    //----------------------------------------------------------------------------------
    //	FILE:			endat.c
    //
    //	Description:	Contains all the initialization, data declarations and setup
    //					for EnDat encoder interface. This file serves are a template for
    //					using PM_endat22 Library to interface and incorporates all the encoder
    //					and library specific initializations and other important aspects of usage.
    //
    //	Version: 		1.0
    //
    //  Target:  		TMS320F28377D,
    //
    //----------------------------------------------------------------------------------
    //  Copyright Texas Instruments � 2004-2015
    //----------------------------------------------------------------------------------
    //  Revision History:
    //----------------------------------------------------------------------------------
    //  Date	  | Description / Status
    //----------------------------------------------------------------------------------
    // Sep 2017  - Example project for PM EnDat22 Library TIDM-1008
    //----------------------------------------------------------------------------------
    
    #include "F28x_Project.h"     // Device Headerfile and Examples Include File
    #include "endat.h"
    
    uint16_t endat22CRCtable[SIZEOF_ENDAT_CRCTABLE];	// Declare CRC table for EnDat CRC calculations
    
    ENDAT_DATA_STRUCT endat22Data;		//PM EnDat22 data structure
    
    uint16_t crc5_result;	//variable for calculated crc result checking
    uint16_t retval1;		//used for function return val storage and checks
    
    
    // Function to initialize EnDat operation
    void EnDat_Init(void) {
    
    	EALLOW;
    //Enable clocks to PWM1/2/3/4
    	CpuSysRegs.PCLKCR2.bit.EPWM1 = 1;
    	CpuSysRegs.PCLKCR2.bit.EPWM2 = 1;
    	CpuSysRegs.PCLKCR2.bit.EPWM3 = 1;
    	CpuSysRegs.PCLKCR2.bit.EPWM4 = 1;
    	EDIS;
    
    //Configure EPWM4 to drive default values on GPIO6 and GPIO7
    	EPWM4_Config();
    
    // Generate table for EnDat Polynomial defied as POLY1
     	PM_endat22_generateCRCTable(NBITS_POLY1, POLY1, endat22CRCtable);
    //GPIO configuration for ENDat operation
     	Endat_setup_GPIO();
    //XBAR configuration for ENDat operation
    	Endat_config_XBAR();
    
    	endat22Data.spi = &SpibRegs;
    	PM_endat22_setupPeriph();
    
    	EALLOW;
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
    	PieVectTable.SPIB_RX_INT = &spiRxFifoIsr;
    	PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
    	PieCtrlRegs.PIEIER6.bit.INTx3 = 1;     // Enable PIE Group 6, INT 9
    	IER |= 0x20;                            // Enable CPU INT6
    	EINT;
    	EDIS;
    
    	// Power up EnDat 5v supply through GPIO139
    	GpioDataRegs.GPEDAT.bit.GPIO139 = 1;
    	DELAY_US(10000L); 	//Delay 10us
    	//EncCLK high for 100ms
    	EALLOW;
    	GpioCtrlRegs.GPADIR.bit.GPIO6 = 1;  //set as GPIO output
    	GpioDataRegs.GPASET.bit.GPIO6 = 1; //set GPIO output to be high once GPIO6 is turned to be a GPIO
    	GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0;
    	DELAY_US(100000L);
    	//EncCLK low for ~200ns (>125ns)
    	GpioDataRegs.GPADAT.bit.GPIO6 = 0;
    	//EncCLK high for 425ms (>381ms)
    	GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1;
    	DELAY_US(425000L);
    
    	//Ensure that EncData is now low
    	if (GpioDataRegs.GPBDAT.bit.GPIO63 == 1) {
    		    ESTOP0;
    	}
    
    	PM_endat22_setFreq(ENDAT_INIT_FREQ_DIVIDER);
    
    //Encoder Receive Reset - Command ERR
    	retval1 = PM_endat22_setupCommand (ENCODER_RECEIVE_RESET, 0xAA, 0x2222, 0); //data1=any; data2=any
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_RECEIVE_RESET, 0);
    	DELAY_US(1000000L); 	//Delay 1s
    
    	retval1 = PM_endat22_setupCommand (ENCODER_RECEIVE_RESET, 0xAA, 0x2222, 0); //data1=any; data2=any
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_RECEIVE_RESET, 0);
    
    	DELAY_US(2000L);
    
    //Select memory area to read out encoder manufacturer parameters.
    //MRS Code A1 - Select Parameters of Encoder Manufacturer
    	 retval1 = PM_endat22_setupCommand (SELECTION_OF_MEMORY_AREA, 0xA1, 0x5555, 0);  //data1=MRS; data2=any
    	 PM_endat22_startOperation();
    	 while (endat22Data.dataReady != 1) {}
    	 //CHECK CRC!
    	 retval1 = PM_endat22_receiveData(SELECTION_OF_MEMORY_AREA, 0);
    	 crc5_result =  PM_endat22_getCrcNorm(endat22Data.address, endat22Data.data, endat22CRCtable);
    	 if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    		     ESTOP0;
    	 }
    
    	 DELAY_US(200L); 	//Delay 200us
    
    //Request Encoder to send the number of clock pulses needed to shift out Encoder Position Values
    //Reading Address 0xD Returns no.of clock pulses needed to shift out position data
    	 retval1 = PM_endat22_setupCommand (ENCODER_SEND_PARAMETER, 0xD, 0xAAAA, 0);	//data1=address; data2=any
    	 PM_endat22_startOperation();
    	 while (endat22Data.dataReady != 1) {}
    	 //CHECK CRC!
    	 retval1 = PM_endat22_receiveData(ENCODER_SEND_PARAMETER, 0);
    	 crc5_result =  PM_endat22_getCrcNorm(endat22Data.address, endat22Data.data, endat22CRCtable);
    
    	 if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    		     ESTOP0;
    	 }
    
    // No.of clocks for position data needs to be set before attempting any position data access
    	 endat22Data.position_clocks = endat22Data.data & 0xFF;
    
    	 DELAY_US(200L);
    }
    
    void Endat_setup_GPIO(void) {
    
    	EALLOW;
    	GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1; // Configure GPIO6 as EnDat Clk master
    	GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1; // Configure GPIO7 as SPI Clk slave
    
    	GpioCtrlRegs.GPBGMUX2.bit.GPIO63 = 3;
    	GpioCtrlRegs.GPCGMUX1.bit.GPIO64 = 3;
    	GpioCtrlRegs.GPCGMUX1.bit.GPIO65 = 3;
    	GpioCtrlRegs.GPCGMUX1.bit.GPIO66 = 3;
    
    	GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 3; // Configure GPIO24 as SPISIMOB
    	GpioCtrlRegs.GPCMUX1.bit.GPIO64 = 3; // Configure GPIO25 as SPISOMIB
    	GpioCtrlRegs.GPCMUX1.bit.GPIO65 = 3; // Configure GPIO26 as SPICLKB
    	GpioCtrlRegs.GPCMUX1.bit.GPIO66 = 3; // Configure GPIO27 as SPISTEB
    
    	GpioCtrlRegs.GPBQSEL2.bit.GPIO63 = 3; // Asynch input GPIO24 (SPISIMOB)
    	GpioCtrlRegs.GPCQSEL1.bit.GPIO64 = 3; // Asynch input GPIO25 (SPISOMIB)
    	GpioCtrlRegs.GPCQSEL1.bit.GPIO65 = 3; // Asynch input GPIO26 (SPICLKB)
    	GpioCtrlRegs.GPCQSEL1.bit.GPIO66 = 3; // Asynch input GPIO27 (SPISTEB)
    
    
    	GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3; // Configure GPIO9 as EnDat TxEN
    
    	GpioCtrlRegs.GPEDIR.bit.GPIO139 = 1; // Configure GPIO139 as EnDat Pwr Ctl
    
    	EDIS;
    }
    
    void Endat_config_XBAR(void)
    {
    	EALLOW;
    
    	//Choose SPISIMO GPIO as InputXbar Input1 - SPISIMO (B) on GPIO63 in this case
    		InputXbarRegs.INPUT1SELECT = 63;	// GPTRIP XBAR TRIP1 -> GPIO63
    		EDIS;
    }
    
    //Template for performing delay compensation
    //This function should only be called while operating at low frequencies (~200KHz) only.
    void EnDat_initDelayComp(void) {
    	uint16_t delay1, delay2;
    
    //Transmit Send position values command to the encoder
    //Delay is internally measured during this command operation
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES, 0, 0, 0);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES, 0);
    
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT21, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	{
    		    ESTOP0;
    	}
    	 DELAY_US(200L); 	//Delay 200us
    //Delay is internally measured during the above operation
    //Read the measured delay and store in a variable - n * 2 * SYSCLKs
    	delay1 = PM_endat22_getDelayCompVal();
    
    //Redo the same procedure again
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES, 0, 0, 0);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES, 0);
    
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT21, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	     ESTOP0;
    	 }
    	 DELAY_US(200L); 	//Delay 200us
    
     //Delay is internally measured during the above operation
     //Read the measured delay and store in a variable - n * 2 * SYSCLKs
    	 delay2 = PM_endat22_getDelayCompVal();
    
    //Average value of the measured delays has to be updated into endat22Data.delay_comp
    // for delay compensation to take effect
    	endat22Data.delay_comp = (delay1+delay2) >> 1;
    }
    
    
    void error(void) {
    	asm("     ESTOP0");
    	//Test failed!! Stop!
    	for (;;);
    }
    
    interrupt void spiRxFifoIsr(void)
    {
    	uint16_t i;
        for (i=0;i<=endat22Data.fifo_level;i++){endat22Data.rdata[i]= endat22Data.spi->SPIRXBUF;}
    	endat22Data.spi->SPIFFRX.bit.RXFFOVFCLR=1;  // Clear Overflow flag
        endat22Data.spi->SPIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x20;       // Issue PIE ack
        endat22Data.dataReady=1;
    }
    
    
    void EPWM4_Config(void) {
    // Set the PWMA and B high as default values of ENDAT clk.
    	EALLOW;
    	EPwm4Regs.TZCTL.bit.TZA = 1;
    	EPwm4Regs.TZCTL.bit.TZB = 1;
    	EPwm4Regs.TZFRC.bit.OST = 1;
    	EDIS;
    }
    
    uint16_t CheckCRC (uint16_t expectcrc5, uint16_t receivecrc5) {
    	if (expectcrc5 == receivecrc5) {
    		return 1;
    	}
    	else {
    		return 0;
    	}
    }
    
    
    
    void endat22_setupAddlData(void)
    {
    // EnDat22 Command reading position values and performing selection of memory area
    // 0xA1 MRS code for selection of encoder manufacturer parameters
    // Additional data enabled at this time is 0
    
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0xA1, 0, 0);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0);
    
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	 ESTOP0;
    	 }
    
    	 DELAY_US(200L); 	//Delay 200us
    
    // EnDat22 Command reading position values and sending a parameter to encoder
    // Send 0xD parameter address - will select no. of clock pulses to shift out position value
    // Additional data enabled at this time is 0
    
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_AND_SEND_PARAMETER, 0xD, 0, 0);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_AND_SEND_PARAMETER, 0);
    
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	 ESTOP0;
    	 }
    
    	 DELAY_US(200L); 	//Delay 200us
    
    // Enable Additional data 1 - to read out no. of  clock pulses to shift out position value
    // MRS code 0x45	- Acknowledge memory content LSB
    
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0x45, 0, 0);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0);
    
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	 ESTOP0;
    	 }
    
    	 DELAY_US(200L); 	//Delay 200us
    
     // Enable Additional data 2 - to read out Operating status and error sources
     // MRS code 0x59	- operating status on additional data 2
     // Additional data enabled before this command is 1, after this command 2
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0x59, 0, 1);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 1);
    
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	 ESTOP0;
    	 }
    
    	 DELAY_US(2000L); 	//Delay 200us
    
    }
    
    void endat22_readPositionWithAddlData(void)
    {
    // Read out position value with 2 additional data previously enabled
    // Additional data enabled at this time is 2
    
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0, 0, 2);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 2);
    
    // CRC check for Position Data
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	 ESTOP0;
    	 }
    
    // CRC check for Additional Data 1
    	crc5_result =  PM_endat22_getCrcNorm((endat22Data.additional_data1 >> 16), endat22Data.additional_data1, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.additional_data1_crc))
    	 {
    	 ESTOP0;
    	 }
    
    // CRC check for Additional Data 2
    	crc5_result =  PM_endat22_getCrcNorm((endat22Data.additional_data2 >> 16), endat22Data.additional_data2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.additional_data2_crc))
    	 {
    	 ESTOP0;
    	 }
    
    	 DELAY_US(200L); 	//Delay 200us
    }
    
    void endat21_readPosition(void)
    {
    // Read position value in EnDat21 mode - no additional data
    	retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES, 0, 0, 0);
    	PM_endat22_startOperation();
    	while (endat22Data.dataReady != 1) {}
    	retval1 = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES, 0);
    
    // CRC check for Position Data
    	crc5_result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT21, endat22Data.position_lo,
    					endat22Data.position_hi, endat22Data.error1, endat22Data.error2, endat22CRCtable);
    
    	if (!CheckCRC(crc5_result,endat22Data.data_crc))
    	 {
    	     ESTOP0;
    	 }
    	 DELAY_US(200L); 	//Delay 200us
    }
    //***************************************************************************
    // End of file
    // **************************************************************************
    

    Regards

    Sanjaya

    InitSysCtrl();
    
    DINT;
    
    
    InitPieCtrl();
    
    IER = 0x0000;
    IFR = 0x0000;
    
    
    InitPieVectTable();
    EnDat_Init();
    endat21_runCommandSet();
    if (ENCODER_TYPE == 22)
    {
    //A template for running all the EnDat22 commands
    //This is optional in real applications.
    //Function defined in endat_commands.c
    
    	endat22_runCommandSet();
    }
    endat22_setupAddlData();
    EnDat_initDelayComp();
    PM_endat22_setFreq(ENDAT_RUNTIME_FREQ_DIVIDER);
    DELAY_US(800L); 	//Delay 800us
    
    while(1)
    {
    	if (ENCODER_TYPE == 22)
    	{
    		endat22_readPositionWithAddlData();
    	}
    	else
    	{
    //Read position data in EnDat21 mode. Function defined in endat.c
    		endat21_readPosition();
    	}
    }
    
    
    
    
    
    
    

  • Hello Venkatesh,

    thank you again for your reply. I tried to add the code and generate the complete code but the tool directly start compiling the functions first without making the ccs project at first.Is there anyway to compile all source code and make project  and then calling these functions?

    I added the code here in zip file. I did the initialization of the endat block with the signal just for test.

    Regards

    Sanjaya8304.Test.zip

  • Test 
      Build 
      2
    Clear
    12:08 AM Elapsed: 15 sec
    ### Starting build procedure for model: Test ### Generating code and artifacts to 'Model specific' folder structure
      Code Generation 
      1
    Elapsed: 15 sec
    ### Generating code into build folder: D:\masters\Thesis\F28379D\Test_ert_rtw
    Making simulation target "Test_sfun", ... "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -c -DMATLAB_MEX_FILE -I"D:\masters\Thesis\F28379D" -I"D:\masters\Thesis\F28379D\source" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2018b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src" CFLAGS="$CFLAGS " Test_sfun.c Building with 'MinGW64 Compiler (C)'. MEX completed successfully. "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -c -DMATLAB_MEX_FILE -I"D:\masters\Thesis\F28379D" -I"D:\masters\Thesis\F28379D\source" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2018b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src" CFLAGS="$CFLAGS " Test_sfun_registry.c Building with 'MinGW64 Compiler (C)'. MEX completed successfully. "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -c -DMATLAB_MEX_FILE -I"D:\masters\Thesis\F28379D" -I"D:\masters\Thesis\F28379D\source" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2018b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src" CFLAGS="$CFLAGS " c1_Test.c Building with 'MinGW64 Compiler (C)'. D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c1_Test.c: In function 'sf_gateway_c1_Test': D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c1_Test.c:173:3: warning: implicit declaration of function 'endat21_runCommandSet' [-Wimplicit-function-declaration] endat21_runCommandSet(); ^~~~~~~~~~~~~~~~~~~~~ MEX completed successfully. "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -c -DMATLAB_MEX_FILE -I"D:\masters\Thesis\F28379D" -I"D:\masters\Thesis\F28379D\source" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2018b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src" CFLAGS="$CFLAGS " c2_Test.c Building with 'MinGW64 Compiler (C)'. D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c2_Test.c: In function 'sf_gateway_c2_Test': D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c2_Test.c:173:3: warning: implicit declaration of function 'EnDat_Init' [-Wimplicit-function-declaration] EnDat_Init(); ^~~~~~~~~~ MEX completed successfully. "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -c -DMATLAB_MEX_FILE -I"D:\masters\Thesis\F28379D" -I"D:\masters\Thesis\F28379D\source" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2018b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src" CFLAGS="$CFLAGS " c3_Test.c Building with 'MinGW64 Compiler (C)'. D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c3_Test.c: In function 'sf_gateway_c3_Test': D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c3_Test.c:173:3: warning: implicit declaration of function 'endat22_runCommandSet' [-Wimplicit-function-declaration] endat22_runCommandSet(); ^~~~~~~~~~~~~~~~~~~~~ MEX completed successfully. "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -c -DMATLAB_MEX_FILE -I"D:\masters\Thesis\F28379D" -I"D:\masters\Thesis\F28379D\source" -I"C:\Program Files\MATLAB\R2018b\extern\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include" -I"C:\Program Files\MATLAB\R2018b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2018b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2018b\rtw\c\src" -I"D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src" CFLAGS="$CFLAGS " c4_Test.c Building with 'MinGW64 Compiler (C)'. D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c4_Test.c: In function 'sf_gateway_c4_Test': D:\masters\Thesis\F28379D\slprj\_sfprj\Test\_self\sfun\src\c4_Test.c:173:3: warning: implicit declaration of function 'endat22_setupAddlData' [-Wimplicit-function-declaration] endat22_setupAddlData(); ^~~~~~~~~~~~~~~~~~~~~ MEX completed successfully. ### Linking ... "C:\Program Files\MATLAB\R2018b\bin\win64\mex.exe" -largeArrayDims -silent LDFLAGS="$LDFLAGS " -output Test_sfun.mexw64 @Test_sfun.mol c1_Test.obj:c1_Test.c:(.text+0x342): undefined reference to `endat21_runCommandSet' c2_Test.obj:c2_Test.c:(.text+0x342): undefined reference to `EnDat_Init' c3_Test.obj:c3_Test.c:(.text+0x342): undefined reference to `endat22_runCommandSet' c4_Test.obj:c4_Test.c:(.text+0x342): undefined reference to `endat22_setupAddlData' collect2.exe: error: ld returned 1 exit status gmake: *** [Test_sfun.mexw64] Error -1
    Component:Make | Category:Make error
    ### Build procedure for model: 'Test' aborted due to an error.
    Unable to create mex function 'Test_sfun.mexw64' required for simulation.
    Component:Simulink | Category:Block diagram error
  • Hi Sanjaya,

    Please connect to us at:

    And we should be able to guide you further on this topic.