MCToolbox can't find my hand written code. Does it support S-Function?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCToolbox can't find my hand written code. Does it support S-Function?

Jump to solution
1,940 Views
fangfq
Contributor III

Hi,

I am working on a Simulink model with normal Simulink blocks and C code (S-Function Builder) combined together. The S-Function Builder itself is super simple (output = input * 2) for testing. It generated a "testMult.c" and "testMult_wrapper.c" automatically. I tested the S-Function with Simulink scope and it is working as expected.

However, when I build the model to generate the ".mot" file to download to the hardware, I always get the following error:

...

Building file sine_wave_library.o...
Building file siu_init.o...
Building file sys_init.o...
Building file sysclk_init.o...

Building file testMult_wrapper.o...

### CW for MPC55xx and MPC56xx 2.10/PowerPC_EABI_Tools/Command_Line_Tools/mwcceppc Usage Error:
# Specified file 'testMult_wrapper.c' not found
Errors caused tool to abort.
gmake: *** [testMult_wrapper.o] Error 1
### Creating HTML report file PWM_test_codegen_rpt.html
### Build procedure for model: 'PWM_test' aborted due to an error.

Looks like the compiler can't find the "testMult_wrapper.c". Not sure if it found the "testMult.c" or not. Those two C files are in the same folder where the Simulink model is.

I tried to remove the S-Function Builder and then the ".mot" file can be generated successfully.

Does anyone experience this error before? Thanks!

EDIT:

Also tried with Legacy Code Tool, still has a similar error.

Building assembly file crt0.o...
Building assembly file sw_handlers.o...
Building assembly file excep_handler.o...
Building file untitled3.o...
Building file CTU_564xL_library.o...
Building file FlexPWM_564xL_library.o...
Building file adc0_EOC_isr.o...
Building file adc0_config.o...
Building file adc_564xl_library.o...
Building file adc_init.o...
Building file adc_trigger_init.o...
Building file doubleValue.o...
### CW for MPC55xx and MPC56xx 2.10/PowerPC_EABI_Tools/Command_Line_Tools/mwcceppc Usage Error:
# Specified file 'doubleValue.c' not found
Errors caused tool to abort.
gmake: *** [doubleValue.o] Error 1
### Creating HTML report file untitled3_codegen_rpt.html
### Build procedure for model: 'untitled3' aborted due to an error.

Where doubleValue.c is my code.

1 Solution
1,495 Views
fangfq
Contributor III

Hi, I found the Motor_Control_Toolbox_Manual.pdf. And in 7.3, 

7.3 User-Specific Files Needed for Build
There may be instances where variables are used from code that is not part of the model but are instead hand coded. In these instances, user specific files will need to be included in the build directory created by toolbox. The user can specify which files to include in the build directory by creating/modifying a file called rappid_564xl_user_copy_required_files.m and locate it somewhere in one of the Matlab paths. There is an example of this file located in the ‘mscripts’ directory that demonstrates how to include user specific files.

And during the build process, the MCToolBox will call this .m file automatically. The hand written .c files will be copied to the destination folder.

So problem solved.

View solution in original post

3 Replies
1,495 Views
dumitru-daniel_
NXP Employee
NXP Employee

At first glance ... it seems that the S-function builder generates the code into the folder where the mdl/slx exists while the NXP toolbox generates the code into a separate folder (one level down).

I'm searching for potential workarrounds...

Best regards,

Daniel

0 Kudos
1,496 Views
fangfq
Contributor III

Hi, I found the Motor_Control_Toolbox_Manual.pdf. And in 7.3, 

7.3 User-Specific Files Needed for Build
There may be instances where variables are used from code that is not part of the model but are instead hand coded. In these instances, user specific files will need to be included in the build directory created by toolbox. The user can specify which files to include in the build directory by creating/modifying a file called rappid_564xl_user_copy_required_files.m and locate it somewhere in one of the Matlab paths. There is an example of this file located in the ‘mscripts’ directory that demonstrates how to include user specific files.

And during the build process, the MCToolBox will call this .m file automatically. The hand written .c files will be copied to the destination folder.

So problem solved.

1,495 Views
fangfq
Contributor III

Thank you for the reply.

Yes. You are right. The S-function builder generate the code in the same folder where the mdl/slx exists.

And I also tried to use Legacy Code Tool to generate code in one level down. But the my .c/.h file get deleted when I start the Simulink build. So still not working.

In general, I am trying to find a solution to integrate my C code into the Simulink model to generate ".mot" file. So not really care about to specifically use S-Function builder or Legacy Code Tool or other tools. 

 

0 Kudos