Filter löschen
Filter löschen

Embedded Coder - Sequence of commands

2 Ansichten (letzte 30 Tage)
Tobias Gemaßmer
Tobias Gemaßmer am 25 Okt. 2011
We use the Simulink Embedded Coder to generate C-Code for our DSP-System. For the input-signals the Real-Time Interrupt Service Routine needs to read out several signals from a Bus, which is made with self-programmed interface-blocks in the Simulink model. During code generation, the blocks, which finally produce few lines of C-code, are placed in the file model_step.c, which is called from the ert_main.c The order of appearance of the read-out commands depends on the model, i.e. at what time the signals are needed during execution. For example, a value from an analog-digital-converter might be read out right at the beginning of the ISR. This can cause a problem, since the analog-digital-converter needs a short time after the interrupt to update its values. So, is there any possibility to influence the placement of these commands within the ISR? Thank you for your help!

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 25 Okt. 2011
The execution order of a Simulink block diagram is data flow driven. It is unlike the C code, which is procedural. For blocks that are not dependent on data flow, it follows the left-to-right, top-to-bottom order to decide which block executes first, which next. So, technically, you can sometimes move the blocks around and it will change the order of execution. But these change is not supposed to affect the outcome result.
You can view and specify the execution order. Click Format>Block Displays>Sorted Order. It will show the order of the block execution of every block in the whole model. You need to read the related document to understand what those numbers mean.
You can also change the execution order by specifying the "priority" of the block by right clicking the block and selecting "block properties...". However, this approach is problematic. Many times it cause conflict and it is hard to resolve those conflicts manually.
The most effective way to change the execution order is probably using the function-call generator. You can put your block or blocks inside an atomic subsystem and then use function-call to trig them. This is like manually and forcefully specifying the order of execution.
  1 Kommentar
Tobias Gemaßmer
Tobias Gemaßmer am 25 Okt. 2011
Thank you for your answer. In the meantime, I detected the possibility to set priorities for the Blocks. I think this will suit my needs best.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by