Assembler commands in C-code for S-Functions

4 views (last 30 days)
Hello! I have a question concerning assembler commands in custom C-code that I want to integrate in an simulink s-function block for code generation by Real Time Workshop afterwards. Speaking more detailed: I wanted to implement an own SCI-Protocol, specified by my University department, in a Simulink block, so I can easily use it in a model for transforming it into C-Code that will run on my TI 2808 DSP. For the SCI and GPIO initialization, I will need assembler commands like "EALLOW" etc. to be able to write certain registers. The problem is, that the lcc compiler does not accept the command "asm(...)", resulting in an error that the symbol asm is undefined. Does anyone have an answer that would solve my problem or lead me closer to the goal? Any help is appreciated! Thanks so far!

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 11 May 2011
Where are you writing the asm(...) commands? Note that your MEX S-function is used for simulation on the host machine (where MATLAB is installed) - so these assembly commands are not appropriate for the host platform (and therefore LCC, Visual Studio or other PC compilers won't recognize them). Since these commands should only be used in the generated code, what you need to do is provide a TLC file for your S-function. See Inlining C MEX S-Functions for more information about this.
In other words, you can have two separate implementations of the block - the MEX S-function to run on the host machine, and the TLC file to represent the block in generated code. When you put your assembler commands in the TLC, they are produced in the code generated for your model, which must be compiled using Code Composer Studio (or the corresponding target compiler).
  1 Comment
David
David on 11 May 2011
Thanks! Of course, I am aware that the simulink blocks are used just for simulation on the host. But so far, I did not know how to separate the code for simulation and code generation. I will have a look at the link you provided!

Sign in to comment.

More Answers (0)

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!