Use persistan variable in Matlab Function with C2000 CLA

1 次查看(过去 30 天)
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.

回答(2 个)

Sumith Sekharan
Sumith Sekharan 2018-6-1
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

Fazel Farahmand
Fazel Farahmand 2019-2-26
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

Community Treasure Hunt

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

Start Hunting!

Translated by