Forums

#pragma interrupt

Started by Roger Flor September 20, 2002
Hello!

I have a question on #pragma interrupt In the Isr_led example for the DSP56F805, all the #pragma interrupt
directives (#pragma interrupt, pragma interrupt called, #pragma interrupt
saveall) were written outside of functions (just before the function
declaration) but the manual Targeting DSP56800 (pp DSP 139 to DSP 144,
chapter 6) says that "You must use the saveall argument only within the
scope of function body". Which is correct?



We have only used "#pragma interrupt" by itself, without any arguments, as shown
by the following code example. This code is for a "Super Fast" ISR, which we
use for Timer channels used for Frequency or Period measurement. Note that the
assembler interface routine for the Super Fast ISR is automatically generated
from a file containing macro definitions.

We use "#pragma interrupt" without any arguments because the CodeWarrior on-line
manual says that this will save and restore only the registers that are used by
the ISR. This will work OK if you use "#pragma interrupt" for the ISR itself
and also for all functions called by the ISR. Again, this is only for "Super
Fast" interrupts. For all other ISRs we use the SDK Interrupt Dispatcher and
"Normal" interrupts.

If you are using the SDK Interrupt Dispatcher, you should only need to use
"#pragma interrupt" for Super Fast interrupts. This is because the SDK
Interrupt Dispatcher saves and restores either all registers (for a "Normal"
interrupt) or most registers (for a "Fast" interrupt). You can see this in the
SDK on-line documentation, start it as follows:
Start
Programs
Motorola
Embedded SDK 2.5
Help and Documentation

In "Contents", go to:
Motorola Embedded SDK
Core Documentation
SDK Programmer's Guide
7 Interrupts

Section 7.2.1 explains the differences between the 3 types of ISRs. Section
7.2.6 describes the SDK Interrupt Dispatcher. Section 7.2.8.3 describes using
"#pragma interrupt" with the SDK Interrupt Dispatcher. Also look at Section
7.5.1 "Using Pragma Interrupt".

I hope this helps, please let me know if you have any more questions.

Regards,

Art Johnson
Senior Systems Analyst
PMC Prime Mover Controls Inc.
3600 Gilmore Way
Burnaby, B.C., Canada
V5G 4R8
Phone: 604 433-4644
FAX: 604 433-5570
Email:
http://www.pmc-controls.com
=========== From the file "freqindef.dat":

/****************************************************************************
*
* Frequency Input Definition Structure data definitions
*
* The macro freqindeffun() is defined to either extract the enumeration name
* for each structure (the first data on each line), or the data for the
* DSPTMR_FP_IN_SCALE_T and DSPTMR_FP_IN_CFG_T structures as described below.
*
*
* DSPTMR_FP_IN_SCALE_T structure:
* SLWORD pulses_per_rev; Pulses per revolution (must be >=1)
* SWORD level_select; Input level select data
* WORD ch_units; Units (Hz or RPM) for freq. inputs
*
*
* DSPTMR_FP_IN_CFG_T structure:
* SWORD ad_idx; Index into the ANA_DATA array
* SWORD ad_in_idx; Index into the ANA_INPUT_DATA array
* WORD count_init_val; CTRL register init. value for counting
pulses
* WORD period_init_val; CTRL register init. value for period
measurement
* DSP_TIMER_T *p_dsp_timer; Pointer to the DSP chip Timer structure
* DSPTMR_FP_DATA_T *p_dsp_fp_data; Pointer to the Frequency/period input data
structure
*
*
* NOTE - The pulses_per_rev value is a "signed engineering units" value,
* where the upper 16 bits are the integer part, and the lower 16
* bits are the fractional part of the number. This gives a resolution
* of 1/65536 of an engineering unit.
*
* NOTE - Set the ad_in_idx value to -1 if the input does not use the
* ANA_INPUT_DATA array for scaling the input.
*
****************************************************************************/

// TMRB0 = Engine RPM
freqindeffun( TMRB0_FREQ_IN_ENUM,
( 1UL << 16 ),
FP_IN_LEVEL_SENS_HIGH,
FP_INP_UNITS_HZ,
ENGINE_RPM,
ENGINE_RPM_FILT_ENUM,
DSPTMR_0_CTRL_FREQ_COUNT_IN_INIT_VAL,
DSPTMR_0_CTRL_FREQ_PERIOD_IN_INIT_VAL,
ArchIO.TimerB.Channel0,
g_dsp_tmrb0_data,
TimerB0_Interrupt ) =========== From the "io_func.c" file:

// Automatically create the functions for the Timer Interrupt
// Service Routines (ISRs) for the Frequency/Period inputs
#undef freqindeffun
#define freqindeffun(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11) \
void v11( void ) { \
asm (lea (sp)+ ); \
asm (move y0,x:(sp)+ ); \
asm (move r2,x:(sp)+ ); \
asm (move r3,x:(sp) ); \
asm (move # ## v9,r2 ); \
asm (move # ## v10,r3 ); \
asm (move x:(r2 + DSPTMR_SCR_OFFSET),y0 ); \
asm (jsr Freq_Period_Input_ISR ); \
asm (pop r3 ); \
asm (pop r2 ); \
asm (pop y0 ); \
asm (rti ); \
}

#include "freqindef.dat"

#undef freqindeffun

/*******************************************************************************\
*******************************
*
* Freq_Period_Input_ISR() Procedure - Global
*
* Purpose: Function that processes the data for the
* Frequency/Period input Interrupt
* Service Routine (ISR)
* Setup: None
* Call: void Freq_Period_Input_ISR(
* WORD status,
* DSP_TIMER_T *p_dsp_timer,
* DSPTMR_FP_DATA_T *p_dsp_fp_data
* )
* Return: None
*
********************************************************************************\
******************************/

#pragma interrupt
void Freq_Period_Input_ISR(
WORD status, // Status read from the DSP Timer
DSP_TIMER_T *p_dsp_timer, // Pointer to the DSP Timer
DSPTMR_FP_DATA_T *p_dsp_fp_data // Pointer to the input data structure
)
{
#pragma interrupt
LWORD period_value; // Period value
LWORD subtract_value; // Period subtract value

.
. (do the interrupt processing)
.

return;
}

-----Original Message-----
From: Roger Flor [mailto:]
Sent: Friday, September 20, 2002 10:57 AM
To:
Subject: [motoroladsp] #pragma interrupt Hello!

I have a question on #pragma interrupt In the Isr_led example for the DSP56F805, all the #pragma interrupt
directives (#pragma interrupt, pragma interrupt called, #pragma interrupt
saveall) were written outside of functions (just before the function
declaration) but the manual Targeting DSP56800 (pp DSP 139 to DSP 144,
chapter 6) says that "You must use the saveall argument only within the
scope of function body". Which is correct?
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/motoroladsp

More Groups: http://www.dsprelated.com/groups.php3 ">http://docs.yahoo.com/info/terms/