S-Function builder

Hi to all,
Im using Matlab in linux system. Im building a simulink model and have a S-Function Builder on it that needs the texas instruments fiel "DSP28x_Project.h". In the library pane I have to include a file, reading the matlab help about S-Function Builder, I try to add the SRC_PATH to this file that in my case is in this route /home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x, then bellow this line I put the DSP28x_Project.h (Not seen in the picture bellow) and tried to build the model. The build throws error "can't find directory or file".
How is the correct way to include the path to this file?
Thanks for your help

1 Comment

Well I solve this problem by put INC_PATH instead of SRC_PATH. But I have another problems now, this errors came up:
En el fichero incluido desde /home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/DSP28x_Project.h:49,
desde /home/gaston/f28027_gpio_wrapper.c:17:
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/headers/include/F2802x_Device.h:85:17: error: expected ;before ‘volatile’
85 | extern cregister volatile unsigned int IFR;
| ^~~~~~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/headers/include/F2802x_Device.h:86:17: error: expected ;before ‘volatile’
86 | extern cregister volatile unsigned int IER;
| ^~~~~~~~~
| ;
En el fichero incluido desde /home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/headers/include/F2802x_Device.h:187,
desde /home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/DSP28x_Project.h:49,
desde /home/gaston/f28027_gpio_wrapper.c:17:
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/headers/include/F2802x_PieVect.h:57:18: error: expected ;before ‘void’
57 | typedef interrupt void(*PINT)(void);
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/headers/include/F2802x_PieVect.h:68:5: error: expected specifier-qualifier-list before ‘PINT’
68 | PINT PIE1_RESERVED;
| ^~~~
En el fichero incluido desde /home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_examples.h:205,
desde /home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/DSP28x_Project.h:50,
desde /home/gaston/f28027_gpio_wrapper.c:17:
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:70:10: error: expected ;before ‘void’
70 | interrupt void INT13_ISR(void); // INT13 or CPU-Timer 1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:71:10: error: expected ;before ‘void’
71 | interrupt void INT14_ISR(void); // INT14 or CPU-Timer 2
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:72:10: error: expected ;before ‘void’
72 | interrupt void DATALOG_ISR(void); // Datalogging interrupt
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:73:10: error: expected ;before ‘void’
73 | interrupt void RTOSINT_ISR(void); // RTOS interrupt
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:74:10: error: expected ;before ‘void’
74 | interrupt void EMUINT_ISR(void); // Emulation interrupt
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:75:10: error: expected ;before ‘void’
75 | interrupt void NMI_ISR(void); // Non-maskable interrupt
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:76:10: error: expected ;before ‘void’
76 | interrupt void ILLEGAL_ISR(void); // Illegal operation TRAP
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:77:10: error: expected ;before ‘void’
77 | interrupt void USER1_ISR(void); // User Defined trap 1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:78:10: error: expected ;before ‘void’
78 | interrupt void USER2_ISR(void); // User Defined trap 2
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:79:10: error: expected ;before ‘void’
79 | interrupt void USER3_ISR(void); // User Defined trap 3
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:80:10: error: expected ;before ‘void’
80 | interrupt void USER4_ISR(void); // User Defined trap 4
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:81:10: error: expected ;before ‘void’
81 | interrupt void USER5_ISR(void); // User Defined trap 5
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:82:10: error: expected ;before ‘void’
82 | interrupt void USER6_ISR(void); // User Defined trap 6
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:83:10: error: expected ;before ‘void’
83 | interrupt void USER7_ISR(void); // User Defined trap 7
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:84:10: error: expected ;before ‘void’
84 | interrupt void USER8_ISR(void); // User Defined trap 8
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:85:10: error: expected ;before ‘void’
85 | interrupt void USER9_ISR(void); // User Defined trap 9
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:86:10: error: expected ;before ‘void’
86 | interrupt void USER10_ISR(void); // User Defined trap 10
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:87:10: error: expected ;before ‘void’
87 | interrupt void USER11_ISR(void); // User Defined trap 11
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:88:10: error: expected ;before ‘void’
88 | interrupt void USER12_ISR(void); // User Defined trap 12
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:93:10: error: expected ;before ‘void’
93 | interrupt void ADCINT1_ISR(void); // ADC INT1 ISR - 1.1 OR 10.1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:94:10: error: expected ;before ‘void’
94 | interrupt void ADCINT2_ISR(void); // ADC INT2 ISR - 1.2 OR 10.2
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:95:10: error: expected ;before ‘void’
95 | interrupt void XINT1_ISR(void); // External interrupt 1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:96:10: error: expected ;before ‘void’
96 | interrupt void XINT2_ISR(void); // External interrupt 2
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:97:10: error: expected ;before ‘void’
97 | interrupt void ADCINT9_ISR(void); // ADC INT9 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:98:10: error: expected ;before ‘void’
98 | interrupt void TINT0_ISR(void); // Timer 0
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:99:10: error: expected ;before ‘void’
99 | interrupt void WAKEINT_ISR(void); // WD
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:104:10: error: expected ;before ‘void’
104 | interrupt void EPWM1_TZINT_ISR(void); // EPWM-1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:105:10: error: expected ;before ‘void’
105 | interrupt void EPWM2_TZINT_ISR(void); // EPWM-2
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:106:10: error: expected ;before ‘void’
106 | interrupt void EPWM3_TZINT_ISR(void); // EPWM-3
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:107:10: error: expected ;before ‘void’
107 | interrupt void EPWM4_TZINT_ISR(void); // EPWM-4
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:112:10: error: expected ;before ‘void’
112 | interrupt void EPWM1_INT_ISR(void); // EPWM-1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:113:10: error: expected ;before ‘void’
113 | interrupt void EPWM2_INT_ISR(void); // EPWM-2
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:114:10: error: expected ;before ‘void’
114 | interrupt void EPWM3_INT_ISR(void); // EPWM-3
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:115:10: error: expected ;before ‘void’
115 | interrupt void EPWM4_INT_ISR(void); // EPWM-4
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:120:10: error: expected ;before ‘void’
120 | interrupt void ECAP1_INT_ISR(void); // ECAP-1
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:129:10: error: expected ;before ‘void’
129 | interrupt void SPIRXINTA_ISR(void); // SPI-A
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:130:10: error: expected ;before ‘void’
130 | interrupt void SPITXINTA_ISR(void); // SPI-A
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:139:10: error: expected ;before ‘void’
139 | interrupt void I2CINT1A_ISR(void); // I2C-A
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:140:10: error: expected ;before ‘void’
140 | interrupt void I2CINT2A_ISR(void); // I2C-A
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:145:10: error: expected ;before ‘void’
145 | interrupt void SCIRXINTA_ISR(void); // SCI-A
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:146:10: error: expected ;before ‘void’
146 | interrupt void SCITXINTA_ISR(void); // SCI-A
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:159:10: error: expected ;before ‘void’
159 | interrupt void ADCINT3_ISR(void); // ADC INT3 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:160:10: error: expected ;before ‘void’
160 | interrupt void ADCINT4_ISR(void); // ADC INT4 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:161:10: error: expected ;before ‘void’
161 | interrupt void ADCINT5_ISR(void); // ADC INT5 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:162:10: error: expected ;before ‘void’
162 | interrupt void ADCINT6_ISR(void); // ADC INT6 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:163:10: error: expected ;before ‘void’
163 | interrupt void ADCINT7_ISR(void); // ADC INT7 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:164:10: error: expected ;before ‘void’
164 | interrupt void ADCINT8_ISR(void); // ADC INT8 ISR
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:173:10: error: expected ;before ‘void’
173 | interrupt void XINT3_ISR (void); // External interrupt 3
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:178:10: error: expected ;before ‘void’
178 | interrupt void PIE_RESERVED(void); // Reserved for test
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:179:10: error: expected ;before ‘void’
179 | interrupt void rsvd_ISR(void); // for test
| ^~~~~
| ;
/home/gaston/ti/c2000/C2000Ware_3_01_00_00/device_support/f2802x/common/include/f2802x_defaultisr.h:180:10: error: expected ;before ‘void’
180 | interrupt void INT_NOTUSED_ISR(void); // for unused interrupts

Sign in to comment.

Answers (1)

Nivedita
Nivedita 15 minutes ago
Hi Gaston,
The errors that you are observing are probably because target-specific C2000 code is being compiled during the simulation/MEX build. During normal Simulink simulation, the S-Function Builder creates a MEX file for the host machine. On Linux, that usually means the code is compiled using the host compiler, for example GCC. That compiler does not understand TI C2000-specific keywords and declarations such as "cregister", "interrupt", "IFR", and "IER". Those are intended to be compiled only by the TI C2000 compiler during code generation/build for the target.
You can avoid this by separating simulation code from target code. A few possible approaches are:
  1. Variant approach: You can use separate simulation and code-generation paths. Refer to the example: Field-Oriented Control of PMSM with Hall Sensor Using C2000 Processors - MATLAB & Simulink. Within this example, the relevant model is "mcb_pmsm_foc_hall_f28035.slx". Under the model, refer to the 'Sensor Driver Blocks', found under 'mcb_pmsm_foc_hall_f28035' -> 'Embedded Processor' -> 'Sensor Driver Blocks'. The subsystem is handled separately for Simulation vs Code Generation.
  2. MATLAB Function block: You can also use a MATLAB Function block and call external C functions using coder.ceval. In that case, use a code-generation check such as isequal(coder.target,'rtw') to differentiate between simulation and codegen. this will let you avoid compiling target-specific Ccode during simulation. For a related workflow, refer to this example: Buffer Logic for Data Transmission - MATLAB & Simulink.
  3. Custom Code approach: If the code is only needed for target code generation, include the TI libraries and source files through model configuration settings rather than forcing them into the simulation MEX build. Check the ‘Custom Code’ approach for including TI libraries under the model. The setting is found under 'Configuration Parameters' -> 'Code Generation' -> 'Custom Code' -> 'Libraries'. The TI C2000 headers/ libraries should be used in the target build configuration, not unconditioanlly during host simulation. For more information on the same, refer to the following doc page: Model Configuration Set Customization - MATLAB & Simulink
  4. Preprocessor guard for MEX vs target build: Since MATLAB defines `MATLAB_MEX_FILE` when compiling code for a MEX file, you can use this macro to exclude C2000-specific headers and code from the simulation build:
#ifndef MATLAB_MEX_FILE
#include "DSP28x_Project.h"
#endif
This prevents the host compiler from seeing DSP28x_Project.h, while still allowing the TI compiler to compile that code during target code generation.
Thanks,
Nivedita.

Products

Asked:

on 12 May 2020

Answered:

about 13 hours ago

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!