Forums

RE: RE: #pragma interrupt / modulus (%) affects int errupts?

Started by Wim de Haan April 14, 2004
Hi William,

I think, there is a slip of your keyboard. It must be:

In the DSP56800 family:
JSR pushes PC & SR on the stack.
RTS pops SR & PC from the stack, restores PC but discards SR from stack (so
SR remains unchanged).
RTI pops SR & PC from the stack, and restores both registers.

Kind regards,

Wim de Haan
Exendis B.V.
P.O.box 56, 6710 BB Ede
Keesomstraat 4, 6716 AB Ede
The Netherlands.
Tel: +31-(0)318 - 676305
mailto: <mailto:>
URL: http://www.exendis.com <http://www.exendis.com/>

-----Original Message-----
From: Yochum, William [mailto:]
Sent: dinsdag 13 april 2004 22:30
To: Corey, Rick
Cc:
Subject: [motoroladsp] RE: #pragma interrupt / modulus (%) affects
interrupts? It doesn't work generally, but in the DSP56800 family:
JSR saves SP & SR on the stack.
RTS pops SP & SR from the stack, restores SP but discards SR.
RTI pops SP & SR from the stack, and restores both registers.

So that's why the RTI is safe for a JSR call.

-----Original Message-----
From: Corey, Rick [mailto:]
Sent: Tuesday, April 13, 2004 3:34 PM
To: 'Yochum, William'; Michael W. Mann;
Subject: RE: #pragma interrupt / modulus (%) affects interrupts? Hi

RTI usually restores the SR by popping it off the stack.

If you encounter an RTI, but you never pushed the SR onto the stack in a
matching "go to ISR" mechanism, the RTI should break the stack most fatally.

Maybe you could set up a "callback function" (non-ISR, with no RTI). Have
the ISR itself do nothing but call the callback function. Since the ISR
shell would contain the RTI, main could call it, too, without blowing the
stack.

Of course the callback function would have to be re-entrant or have ISR
protection.

(Maybe callback is the wrong term if it is called directly from inside the
ISR.)

Rick Corey

-----Original Message-----
From: Yochum, William [mailto:]
Sent: Tuesday, April 13, 2004 3:23 PM
To: Michael W. Mann;
Subject: Re: #pragma interrupt / modulus (%) affects interrupts? Correct me if I'm wrong, but strictly speaking the difference between an
"RTI" and an "RTS" is restoration of the SR register. This MIGHT reenable
interrupts, but it doesn't necessarily do so, right?

If a "#pragma interrupt" routine was called from the main loop it would
simply restore the interrupt status that was active at that time. If
interrupts were off they should remain off. -----Original Message-----
From: Michael W. Mann [mailto:]
Sent: Tuesday, April 13, 2004 2:50 PM
To:
Subject: [motoroladsp] Re: #pragma interrupt / modulus (%) affects
interrupts?
--- In , "Pete Becher" <pbecher@d...>
wrote:
> Hi All,
>
> I was wondering. If you have a C function that you want to use as
an
> ISR but also call from the main loop does "#pragma interrupt" work
> for both? Does it require 2 different functions? What are the
> implications.

There are times you can get away with calling a routine that
is "#pragma interrupt" enabled from outside of an ISR processing
thread.

Basically when you call such a routine you are needlessly saving and
restoring the core's registers. This is just inefficient. But at
the return you are also enabling interrupts. That is the difference
between an RTI (return from interrupt) instead RTS (return from
subroutine). The #pragma enabled routine will return via RTI. If
enabling interrupts at that time causes on harm to your application
then you can get away with it. But be sure that it doesn't renable
interrupts when you desire to keep them masked.

If you don't want this risk then you can code up two separate
routines in C. You can also code the routine in assembly and check
the SR to see if interrupts are enabled or masked. Then you can save
or not save context accordingly.
>
> Thanks,
> Pete
_____________________________________
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
<http://www.yahoogroups.com/group/motoroladsp>

More Groups: http://www.dsprelated.com/groups.php3
<http://www.dsprelated.com/groups.php3
_____________________________________
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
<http://www.yahoogroups.com/group/motoroladsp>

More Groups: http://www.dsprelated.com/groups.php3
<http://www.dsprelated.com/groups.php3

_____

> .