Embedded Coder - Sequence of commands
1 view (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Fangjun Jiang
on 25 Oct 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.
More Answers (0)
See Also
Categories
Find more on Timers and Scheduling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!