Writing interruptible code on C6xxx DSPs

From DSignT Support Database
Jump to: navigation, search

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.


Arr u.png    back to top

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++:

#pragma FUNC_INTERRUPT_THRESHOLD(threshold);


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.


Arr u.png    back to top

3 Examples

3.1 –min

Compiler option -mi50 means, all loops in the current module must be interruptible after 50 cycles.


3.2 FUNC_INTERRUPT_THRESHOLD

The following examples demonstrate the use of different thresholds:

  • The function foo() must be interruptible at least every 2,000 cycles:
#pragma FUNC_INTERRUPT_THRESHOLD(foo,2000)


  • The function foo() must always be interruptible.
#pragma FUNC_INTERRUPT_THRESHOLD(foo,1)


  • The function foo() is never interrupted.
#pragma FUNC_INTERRUPT_THRESHOLD(foo,-1)


Arr u.png    back to top

4 Additional Tags

spru187o.pdf, spru425a.pdf



Contact Post.png Support Tool.png