Reusable function error with Matlab 2020a and MBDT v4.2

cancel
Showing results for 
Search instead for 
Did you mean: 

Reusable function error with Matlab 2020a and MBDT v4.2

95 Views
jimfreudenberg
Contributor I

Hi, All -- We are trying to generate multitasking code for the S32K144 using Matlab 2020a and MBDT v 4.2. This is for the purpose of teaching an embedded control class, which enrolls over 200 students/year at the University of Michigan and ETH Zurich

We want the multitasking code in separate functions --- but when we check "Reusable Function", we get error messages. This feature works fine without the Toolbox -- it is only when the MBD Toolbox is used that we get errors. And it seems to be specific to version 4.2 -- we believe it also worked with version 4.1.

yesterday we discovered that the problems arise when we are receiving input from the FlexTimer quadrature decode blocks. When we replace these blocks with inputs from ADCs everything is OK again.

I have attached here a zip directory with the models that worked, the ones that did not work, and the error messages. Also, I have pasted below the message from the teaching assistant, Paul Young, who did this work. his email is plyoung@umich.edu.

from Paul:

I looked into this a bit more during my open lab hours today. It appears there is a problem with the quadrature decode block being used in conjunction with "reusable function" subsystems. A quick walkthrough of my methodology is below:


Took the solution code two_virtual_wheel.slx model from gitlab and changed both triggered subsystems to "reusable functions".
Attempted to build code and got an error message that I saved to a text file.
Created a duplicate model that is exactly the same, except instead of using the quadrature decode block to create the angle input, it uses an ADC block.
Successfully built code with the modified model (two_virtual_wheel_adc.slx) and saved the diagnostics viewer output to a text file.
Zipped up the entire matlab workspace including both models, the auto-generated code, and the two diagnostics logs.

 

Thanks!

 

Jim

0 Kudos
1 Reply

48 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @jimfreudenberg 

I am sorry for my delayed answer, I might have missed this community post. 

You are right, the issue comes from the quadrature decoder block. For some of our blocks, like FTM we generate dedicated C source files and headers for declaring the configuration structures for peripherals. The issue comes from including the model_private.h header in some of them. 

For this particular case, I have removed the include line from the generated code and on my machine, the model which is using qd builds successfully. I have attached a tlc file that must be replaced in our toolbox ( please backup it first). 

To do so, please type the following command in Matlab: winopen(fullfile(mbd_find_s32k_root, 'mbdtbx_s32k\blocks\ftm')) This will open the exact file location of where the attached tlc must be replaced. Please give it a try.

For now, I've only added the qd file but most likely we might have to change all FlexTimer blocks with this fix. 

Hope this helps,

Marius

0 Kudos