How to Synchronize CPU and CLA execution on C2000 MCU

I am designing a control algorithm with a strict 50-microsecond execution budget, triggered by ePWM+ADC. To meet this budget, I am offloading a portion of the computation to the CLA to run in parallel with the CPU.
Workflow:
  • The main CPU task starts the CLA task once the input data is ready.
  • The CPU continues with its own computations while the CLA runs in parallel.
  • The CPU must then wait for the CLA task to finish to use its results.
Constraint: The CLA's end-of-task interrupt cannot be handled inside the 50 µs fast loop. It must be implemented as a top-level interrupt.
Question: What are the recommended synchronization methods in Simulink for the CPU to wait for a completion flag from the CLA's top-level interrupt? I need a mechanism that functions like a semaphore, allowing the CPU to efficiently wait for the CLA to complete before proceeding.
Thanks.

 Accepted Answer

Umar
Umar on 2 Sep 2026
Edited: Umar on 2 Sep 2026
Hi @Valeriy,
Since your CLA end of task interrupt has to be handled as a top level interrupt and can't touch your fast loop, a true blocking wait call, like the CLA Task block's Wait until completion of task option, or the Software Trigger CPU to CLA block's TrigAndWait mode, won't work for you, because those halt the CPU right where you call them and don't involve the interrupt at all, so they're out. What you want instead is the pattern MathWorks' own CLA data integrity example uses: let the CLA's completion interrupt fire as a low priority background task, using a C28x Hardware Interrupt block configured for the CLA end of task source, driving a small function call subsystem, and have that interrupt routine do nothing but flip a shared flag, either a Data Store Memory variable, or a variable placed in the CLA to CPU message RAM section if you're on the model reference or multiprocessor workflow, read back through an Interprocess Data Read block. Your fast task never services the interrupt itself, it just reads that flag at the point where it needs the CLA's result, which gives you the semaphore like behavior you're after without blocking or adding interrupt overhead inside your budget. Set the priority and preemption settings on that background interrupt task so it can't preempt your fast loop, and make sure the shared flag and data live in the correct CPU to CLA message RAM section so the access stays safe. That combination, interrupt sets a flag in the background, fast loop polls it, is exactly the double buffer and read write index technique shown in the Using the Control Law Accelerator example in the C2000 Microcontroller Blockset documentation, and it is the recommended way to synchronize CPU and CLA execution under a hard timing constraint like yours.

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Asked:

on 28 Aug 2026

Edited:

on 2 Sep 2026

Community Treasure Hunt

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

Start Hunting!