Solved! Go to Solution.
Hello 642142357@qq.com,
To set the priority for a block, you should right-click it, then go to Properties -> Priority.
Keep in mind that the lower the priority number you input, the higher the priority (low numbers will generate code first).
Hope this helps!
Razvan.
Hello 642142357@qq.com,
To set the priority for a block, you should right-click it, then go to Properties -> Priority.
Keep in mind that the lower the priority number you input, the higher the priority (low numbers will generate code first).
Hope this helps!
Razvan.
the higher or low the priority only means that model generate code order????what refer to set the priority ??? what relation about priority and program execute order ???
Hello 642142357@qq.com,
So there are 2 types of priorities we can think of when talking about our MBD toolboxes and Simulink. I'm going into details for both of them as I can not understand what you want to know.
To answer your other question - as for the relationship between code generation order and execution order, they will be tightly coupled, while in the same place. So if we have 2 blocks that generate initialization code, they will be placed in the same Init() function. The order in which the code is generated will ultimately give you the order in which the blocks will be executed.
Please let me know if you have further issues, or give me an example of what you are trying to accomplish and I will make an example for you, highlighting the priority management.
Kind regards,
Razvan.
on the same simulink level model, how to decide the c code (generation by simulink models based on s32ktoolbox)execute order ???show picture below,thks.
want to A generate c code executed prior to B generate c code executed ,how to do ?
Hello 642142357@qq.com,
Can you send me the model? I'm having a hard time trying to see the order Simulink has set up. You can strip out any proprietary code and just leave out the empty subsystems if you'd like.
Kind regards,
Razvan.
Hello 642142357@qq.com,
So if you want the whole subsystem A to be generated first, and then the whole subsystem B, you have to right click on subsystem A, go to Properties, then write a number in the Priority edit box (e.g.: 5). Then go to subsystem B, do the same (right click -> Properties), and enter a higher number (lower priority) than what you've inserted in subsystem A (e.g.: 10). Now, if you build the model, you'll see that code generated for subsystem A is before code generated for subsystem B. You can check Simulink's order by pressing CTRL+D on your keyboard, while in the model. This will force an update to the model, which, among other things, will update the priorities (you can see them in the corner of every block, denoted with 2 numbers - e.g.: 5:21).
Following the same approach, you can set priorities for each and every block in Simulink (be it from Standard Simulink block set, our toolbox or any other toolbox).
Hope this helps,
Razvan.
aim to how to decided by me c code (generated by A ) executed prior to c code(generated by B ), that is to say , c code execute order.not " code generated by A or B order " you said.Or rather, you means,c code execute order = c code generated by simulink order ???
Hello 642142357@qq.com,
As I stated before, there are more parts where code can be generated. This parts can be:
If the code for block A and code B is generated for same part (e.g.: both blocks generate loop code), the order given in Simulink = order of execution (C code running on target).
I can't make a general rule that Simulink order = execution order on target. I will give you a simple example to make my point more clear: you have block A that generates initialization code; you also have block B that generates loop code. In this example, regardless of the priorities, the code executed on the target will always be in the following order: initialization code, then loop code.
But as a rule of thumb, you can expect that code executed on target should be (in most cases) = priority in Simulink.
Kind regards,
Razvan.
Helloconstantinrazvan.chivu
could u give me a sample simulink project based on toolbox with s32k144 to describe that you said.not a sample of " block A that generates initialization code; block B that generates loop code. ".thks.
Kind regards.
Hello 642142357@qq.com,
Every peripheral configuration block generates code that goes into the initialization function. You can take as an example one of the following: SPI Config, CAN Config, ADC Config, etc.
Most peripheral action blocks generate code that goes into the loop code (step function). You can take as an example one of the following: SPI Transfer, CAN Send, etc.
Kind regards,
Razvan.