m-file programme to embed in DSP

I try to programme the TMS28335 DSP with simulink blocks (ADC,SCI transmit, receive)using the serial cable communications. I have m-file programmes and I need to convert and embed to DSP. ıs there any block for using the m-file codes in DSP? I tried the embedded matlab function block, but it gives a lot of problems for my programme. Please help about my study. Thank you.

 Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 23 Oct 2012

1 vote

If you have MATLAB code that you need to use in a Simulink model that you intend to generate code from, the correct way is indeed to use an (Embedded) MATLAB Function block. However, only a subset of the MATLAB language is eligible for code-generation. Please be sure that you conform to these requirements - if you run into specific error, please post them with your code and the exact error message(s).

7 commentaires

Cigdem
Cigdem le 23 Oct 2012
Dear Kaustubha, You said to use matlab coder. I haven't use that, Does it convert my m-file or c-code eligible for my DSP, doesn't it? I can download the converted code like all other processor blocks? İf so, I will try and notify you if there is an error, thank you.
Cigdem
Cigdem le 23 Oct 2012
Dear Kaustubha, I looked over matlab coder toolbox.I think, I couldn't tell my problem. I use "target support package" toolbox to build the F28335 DSP. I use ADC block (texas iinstruments C2000) for the inputs and SCI transmit for sending the process done with inputs. I receive the result from DSP with SCI receive block. So, I have a artificial neural network algorithm written in m-file (also C-code), I want to implement that in DSP. I will set the ADC block and the ANN code and convert to DSP all of them from simulink with serial communication.it will work dynamically and want to scope the results again in simulink with SCI receive. Concequently, I need a tool for converting the ANN code written in m-file or C-code. I am looking forward for your suggestion. Thank you.
Kaustubha Govind
Kaustubha Govind le 23 Oct 2012
Unfortunately, the Neural Network Toolbox is currently not supported for code-generation, so you might need to manually convert your MATLAB code to C code.
Cigdem
Cigdem le 23 Oct 2012
I know that the NN toolbox is not supported, already I have code of the ANN algorithm written in m-file also C code. I use the simulink because it is easier for DSP programming. The problem is; I need a block which I can use the m-file code at simulink.
Kaustubha Govind
Kaustubha Govind le 24 Oct 2012
In that case, it might be better to write a MATLAB S-function to run your MATLAB code, and an accompanying TLC file that produces the C code which you've already written. In this way, the MATLAB code is used for simulation within the Simulink environment, but your manually written C code will stand in during code generation.
Cigdem
Cigdem le 25 Oct 2012
Kaustubha, what is the difference between embedded matlab function block and matlab S-function? Also, what is the difference between level 1 m-file s function and level 2 m-file s function? I tried the embedded matlab function, firstly it was working, but I prolonged the code (programme), it gave an error when I tried to save that. so, ıt didn't saved. There are for loops in my programme, if I use the s-function, Can it be converted with code generation, also same question with for embedded matlab function? thank you for your replies.
Kaustubha Govind
Kaustubha Govind le 25 Oct 2012
Please see the various differences between the two blocks in the rows corresponding to them in the tables on this page. Level-1 MATLAB S-functions have long been deprecated - Level-2 MATLAB S-functions are the modern way of writing MATLAB S-functions and have better capabilities. Like I mentioned, you need to write the TLC file for code-generation with MATLAB S-function.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by