Hi Guys,
I used the simulink/stateflow call external *.c and *.h files,and generated the Test_1_initialize(void) as below,
but,i wanna put the int_xx() function of the ad.c file in Test_1_initialize(void),shown as yellow mark.
I put stateflow in the Initialize Function,simulink shows that it is not supported,so i don't know how to do!
The attachment is the model built by myself.
Who can help me?Thanks very much!
Original Attachment has been moved to: Model.zip
Solved! Go to Solution.
It is not a direct call of your function but functionally is the same outcome.
The Matlab S-function will call your custom function via a wrapper:
That in turns calls the user code:
All you have to do is:
#1: place the S-function in the Initialize Function Block
#2: customize the S-function Builder to reference the code you want to call
#3: follow the tip#3 to copy all custom files in the final generation code folder: https://community.nxp.com/thread/449904
Attached is and example with Matlab/Simulink + copy file(that needs to customized for each PC)
Hope this helps!
Best regards,
Daniel
Hi Eden Li,
The Simulink error you are getting is normal and is listed as a Mathworks limitation: Initialize, Reset, and Terminate Function Limitations - MATLAB & Simulink - MathWorks Deutschland
Charts are not supported by the block you want to use in your model.
Nonetheless, we may offer you and alternative:
Just recently another member of the community had a similar request: please see this topic:MCToolbox can't find my hand written code. Does it support S-Function?
We've also created a tip for it: MBD Toolbox - Tip of the Day Tip #3: MBD Toolbox - Add custom code to your Simulink model
Let us know if you managed to implement your functionality this way.
Hope it helps!
Daniel
Hi daniel,
I haven't realize this function ,The link you had sent to seams not realize my goal that mentaioned abve(the yellow mark) .
It is not a direct call of your function but functionally is the same outcome.
The Matlab S-function will call your custom function via a wrapper:
That in turns calls the user code:
All you have to do is:
#1: place the S-function in the Initialize Function Block
#2: customize the S-function Builder to reference the code you want to call
#3: follow the tip#3 to copy all custom files in the final generation code folder: https://community.nxp.com/thread/449904
Attached is and example with Matlab/Simulink + copy file(that needs to customized for each PC)
Hope this helps!
Best regards,
Daniel