22102936ee_134| Application Note

22102936ee_134 PDF

22102936ee_134| Application Note


Engineer To Engineer Note

EE-134

Phone: (800) ANALOG-D, FAX: (781) 461-3010, EMAIL: dsp.support@analog.com, FTP: ftp.analog.com, WEB: www.analog.com/dsp
Copyright 2001, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of customers' products or for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property of their respective holders. Information furnished by Analog Devices Applications and Development Tools Engineers is believed to be accurate and reliable, however no responsibility is assumed by Analog Devices regarding the technical accuracy of the content provided in all Analog Devices' Engineer-to-Engineer Notes.

Technical Notes on using Analog Devices' DSP components and development tools

Name

Writing C Compatible Assembly Code Interrupt Handlers for the SHARC Family
Kevin C. Kreitzer last modified 05/10/2001

Regular Fast Super fast

Cycle Count 128 60 30

C library function interrupt() interruptf() interrupts()

Introduction Very often, DSP programs will consist of a mix of C code and assembly code. The assembly code is typically used for time critical routines. Interrupt Service Routines (ISRs) can be some of the most time critical elements of the program and, as such, often need to be coded in assembly. This EE-note describes how to write C-compatible assembly code interrupt handlers for the SHARC family. C Interrupt Handlers C provides its own set of interrupt handlers via the interrupt() and signal() functions. Visual DSP has extended the interrupt() function with interruptf() and interrupts() versions. These are summarized for the ADSP-2106x family in Figure 1. Interrupts are enabled at runtime using these library functions as shown in Figure 2. The function interrupt() unmasks the appropriate interrupt in the IMASK register, enables global interrupts in MODE1 register, and maps the specified function as the interrupt service routine. Signal() will enable only one instance of the interrupt.

What is saved? Saves and restores everything. Saves the scratch registers only. Alternate register set is used. Nothing is saved. Interrupt nesting is disabled.

Figure 1. C interrupt handler table. interrupt (SIG_TMZI, Timer_ISR); Figure 2. C interrupt handler example.

Assembly Interrupt Handlers While not inherently inefficient themselves, C interrupt handlers, even if the interrupt service routine is written in assembly, are general purpose and must account for all possible conditions. Writing your own custom assembly interrupt handlers is simple and will greatly speed execution. The interrupt handler consists of three parts the initialization, the interrupt vector, and the interrupt service routine. Initialization performs the tasks previously associated with the C interrupt() function assigning the interrupt service routine to an interrupt vector (dynamic ISR vectors only), unmasking the interrupt, and enabling global interrupts. The interrupt vector routes execution to the appropriate interrupt service routine.

a


22102936ee_134 Application Note analog Download PDF

Add this permalink to your bookmarks for future download of 22102936ee_134 ApplicationNote

Permalink: http://application.emcelettronica.com/analog/22102936ee_134

PDF 22102936ee_134 APPLICATION NOTE