Writing interruptible code on C6xxx DSPs
Taken from document SPRA534.pdf by Texas Instruments: Writing Interruptible Looped Code for the TMS320C6x DSP
1 compiler option –min
The C6x code generation tools provide a high degree of flexibility for interruptibility. The compiler option –min specifies an optional interrupt threshold value, n. The threshold value specifies the maximum number of clock cycles that the compiler can disable interrupts. When using the –min option, the compiler and assembly optimizer analyze both the loop structure and the number of times the loop will be iterated to determine the maximum number of cycles it will take to execute the loop. If the tools can determine that the maximum number of cycles is less than the threshold value, the compiler/assembly optimizer will create non-interruptible code. Otherwise, the tools generate interruptible looped code that will, in most cases, not degrade the performance of that loop. The compiler command line option –min can be used for an entire module.
2 pragma FUNC_INTERRUPT_THRESHOLD
In addition, a pragma can be used to specify the threshold on a function-by-function basis. This pragma is of the form:
#pragma FUNC_INTERRUPT_THRESHOLD(func, threshold);
or for c++:
The #pragma overrides the –min command line option. If a threshold of less than 0 is specified, it is assumed that the function will never be interrupted.
Compiler option -mi50 means, all loops in the current module must be interruptible after 50 cycles.
The following examples demonstrate the use of different thresholds:
- The function foo() must be interruptible at least every 2,000 cycles:
- The function foo() must always be interruptible.
- The function foo() is never interrupted.
4 Additional Tags