Technical discussions about Freescale (Motorola) DSPs (including the DSP56000, DSP56300, DSP56600, 56800 DSPs).
Re-posting question to Yahoo group. Didn't get any help in Freescale forums.
==================
Hello all,
I'm working with 56F801 DSP for AC motor control. In my current software,
several functions are being called from an ISR. This is what I have:
-----------
From vector jumps:
... jsr ISR_Function // jump to ISR function ...
-----------
void ISR_Function{
#pragma interrupt warn
SecondFunction(); // call SecondFunction
}
-----------
#pragma interrupt called
void SecondFunction{
AsmFunction(); // call assembly function
}
-----------
#pragma interrupt called
asm void AsmFunction{
nop // do something
}
Questions:
1) are the pragmas correctly used? For some reason, I'm still getting
warnings that a non-interrupt function is being called from an interrupt
function.
2) what happens if I call SecondFunction from a non-interrupt function (say
MainBackgroundTask)?
3) Is there any special requirement for interrupt-called assembly functions?
Thanks!
Mariano
Sankar: Tried that but for some reason, compiler is not accepting that. I
did a small program with empty subroutines and it is working. I guess I have
a mistake somewhere that is taking forever to debug. Thanks for the help.
JANE: I never call the interrupt routine from main task, but I do call a
math function that is used both in the ISR and main task. The user manual
specifies that all functions called from ISRs need the "#pragma interrupt
called" to be able to save the appropiate registers to stack. Thanks.
_____
From: sankar murmu [mailto:murmu_s@murm...]
Sent: Monday, March 06, 2006 11:08 AM
To: Mariano Filippa
Subject: Re: [motoroladsp] Use of #pragma interrupt (re-post)
1. Use "#pragma interrupt called" just before writing the prototype of the
called (from an ISR or interrupt) function.
2. No issues, when you call Second function from main task.
3. You need to write prototype with "#pragma interrupt called".
Hope all these will help you.
Regards,
Sankar
On Sat, 04 Mar 2006 Mariano Filippa wrote :
>Re-posting question to Yahoo group. Didn't get any help in Freescale
forums.
>==================
>Hello all,
>
>I'm working with 56F801 DSP for AC motor control. In my current software,
>several functions are being called from an ISR. This is what I have:
>
>-----------
> From vector jumps:
> ... jsr ISR_Function // jump to ISR function ...
>-----------
>void ISR_Function{
>#pragma interrupt warn
> SecondFunction(); // call SecondFunction
>}
>-----------
>#pragma interrupt called
>void SecondFunction{
> AsmFunction(); // call assembly function
>}
>-----------
>#pragma interrupt called
>asm void AsmFunction{
> nop // do something
>}
>
>Questions:
>1) are the pragmas correctly used? For some reason, I'm still getting
>warnings that a non-interrupt function is being called from an interrupt
>function.
>2) what happens if I call SecondFunction from a non-interrupt function (say
>MainBackgroundTask)?
>3) Is there any special requirement for interrupt-called assembly
functions?
>
>Thanks!
>Mariano
>
Found my problem... The compiler needed to have the "#pragma interrupt
called" before the first prototype declaration. I had my first declaration
in the header file as 'extern'.
I checked the code and the compiler generates RTIs and RTSs where needed.
Summary:
-----------
From vector table:
... jsr ISR_Function() // jump to ISR function ...
-----------
void ISR_Function(void){
#pragma interrupt warn *** THIS ONE NEEDS TO BE IN HERE, NOT BEFORE
PROTOTYPE ***
SecondFunction(); // call SecondFunction
} *** COMPILER ISSUES AN RTI HERE ***
-----------
From header file:
#pragma interrupt called
extern void SecondFunction(void); *** FOR SOME REASON, PRAGMA GOES BEFORE
THIS DECLARATION ***
-----------
From c file:
void SecondFunction(void); *** PRAGMA DOES NOT WORK BEFORE THIS DECLARATION
***
void SecondFunction(void){
.....
} *** COMPILER ISSUES AN RTS FOR ALL CASES ***
Does this make any sense? I find it a bit strange to have to use the #pragma
in the declaration that has an 'extern'. Build manual does not seem to
specify this. Moreover, I could never make the #pragma work inside the
function body, as explained in the manual.
Thanks for all help
Mariano
-----Original Message-----
From: JANE DING [mailto:jyding2000@jydi...]
Sent: Thursday, March 09, 2006 12:50 PM
To: Mariano Filippa
Subject: RE: [motoroladsp] Use of #pragma interrupt (re-post)
Mariano,
If you have math functions called both from appl and ISR, you have to define
a semaphore for each function to lock and unlock the function to prevent the
function is being called by Appl when ISR also jumped in.
I had a similar floating calculation function was called by ISR, then the
main() had error calculation results by calling the same func.
If you see "rti" at end of your other sunroutine functions, that is wrong.
It should be "rts", because "rti" return-from-Interrupt is a system call,
it
will pop PC from Stack and send system back to Appl.
The ISR should not be run a long period time, but if you disable the cpu
interrupt at start of ISR and enable interrupt at the end of ISR, it should
be OK to prevent other higher periority ISR happens.
I use C-code, I have a 2-ms timeout ISR (defined as
#pragma) calls a regular function (0x3AA+ words long), not defined as
#pragma, and this a regular function calls other math/ADC/PWM/DAC functions,
runs about 200-us (system clk=40Mhz).
I guess you can not call me, but in case:USA 818 264-8100.
Good luck,
Jane
#pragma interrupt called /* Comment this line if the appropriate 'Interrupt
preserve registers' property */
/* is set to 'yes' (#pragma
interrupt saveall is generated before the ISR) */
void TO1_OnFalling(void)
{
/* Write your code here ... */
Cpu_DisableInt();
regulatorCycle();
Cpu_EnableInt();
}
/* END TmOut4Ms */
--- Mariano Filippa <mfilippa@mfil...> wrote:
> Sankar: Tried that but for some reason, compiler is not accepting
> that. I did a small program with empty subroutines and it is working.
> I guess I have a mistake somewhere that is taking forever to debug.
> Thanks for the help.
>
> JANE: I never call the interrupt routine from main task, but I do call
> a math function that is used both in the ISR and main task. The user
> manual specifies that all functions called from ISRs need the "#pragma
> interrupt called" to be able to save the appropiate registers to
> stack. Thanks.
>
>
>
>
> _____
>
> From: sankar murmu [mailto:murmu_s@murm...]
> Sent: Monday, March 06, 2006 11:08 AM
> To: Mariano Filippa
> Subject: Re: [motoroladsp] Use of #pragma interrupt
> (re-post)
>
>
>
> 1. Use "#pragma interrupt called" just before writing the prototype
> of the called (from an ISR or interrupt) function.
>
> 2. No issues, when you call Second function from main task.
>
> 3. You need to write prototype with "#pragma interrupt called".
>
>
> Hope all these will help you.
> Regards,
> Sankar
>
>
> On Sat, 04 Mar 2006 Mariano Filippa wrote :
> >Re-posting question to Yahoo group. Didn't get any
> help in Freescale
> forums.
> >==================
> >Hello all,
> >
> >I'm working with 56F801 DSP for AC motor control.
> In my current software,
> >several functions are being called from an ISR.
> This is what I have:
> >
> >-----------
> > From vector jumps:
> > ... jsr ISR_Function // jump to ISR function
> ...
> >-----------
> >void ISR_Function{
> >#pragma interrupt warn
> > SecondFunction(); // call SecondFunction
> >}
> >-----------
> >#pragma interrupt called
> >void SecondFunction{
> > AsmFunction(); // call assembly function
> >}
> >-----------
> >#pragma interrupt called
> >asm void AsmFunction{
> > nop // do something
> >}
> >
> >Questions:
> >1) are the pragmas correctly used? For some reason,
> I'm still getting
> >warnings that a non-interrupt function is being
> called from an interrupt
> >function.
> >2) what happens if I call SecondFunction from a
> non-interrupt function (say
> >MainBackgroundTask)?
> >3) Is there any special requirement for
> interrupt-called assembly
> functions?
> >
> >Thanks!
> >Mariano
> >
>
>
>