MATLAB Answers

0

Use persistan variable in Matlab Function with C2000 CLA

Asked by Alexander Voit on 29 May 2018
Latest activity Answered by Fazel Farahmand on 26 Feb 2019
Hello,
i am working with Embedded Coder Support Package for TI C2000. When using the CLA data Handling has to be done carefully regarding things like CPU_to_CLA or CLA_to_CPU.
What i already figured out is that if i use an integrator inside a CLA Task is have to place the State attributes in CLA Data Ram to get it to work.
Now i use a Matlab Funktion inside the CLA an Need a variable that also keeps ist state. For the normal CPU this can be done by using "persistent" in the declaration. For the CLA this is not working because the Variable has to be in the CLA Data Ram.
Can somebody please tell me how to declare this in the Maltlab Function Block?
The Signal Object Class i want to use is tic2000demospkg.signal and the code Generation storage class is Cla1DataRam.

  0 Comments

Sign in to comment.

2 Answers

Answer by Sumith Sekharan on 1 Jun 2018

Hi Alexander,
You can use global data using data store memory in MATLAB Function blocks. use below links for more details.
https://www.mathworks.com/help/releases/R2018a/simulink/ug/_bqlblru.html
https://www.mathworks.com/help/simulink/ug/using-global-data-with-the-matlab-function-block.html#bsdud7d-1
On the data store memory you can select the storage class and datatype.
Hope this helps.
Thanks, Sumith

  0 Comments

Sign in to comment.


Answer by Fazel Farahmand on 26 Feb 2019

I have had same problem. So as a work around the problem I replaced all persistent variables with an input to the function. Also in Block Parameters of your function, you need to uncheck Treat as atomic unit. I did and my function is now working with CLA. I hope that answers your question. If you have found a different way to solve the problem, I'll appreciate to share.
Sincerely yours
Fazel

  0 Comments

Sign in to comment.