Embedded Coder - Sequence of commands
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Fangjun Jiang
2011년 10월 25일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Timers and Scheduling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!