Searching \ for '[PIC] ISR and forced PC address on return?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'ISR and forced PC address on return?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] ISR and forced PC address on return?'
2005\06\15@091356 by alan smith

picon face

Given, like any program...main loop is running doing
some background tasks...collecting data, or whatever.
The ISR gets invoked, in my case by means of serial
traffic via the UART so of course the main is halted
and the ISR runs, then the PC is set back to where it
was interupted from and continues.

So, bad practice to ORG the main loop so when
returning from the ISR you always restart the MAIN
again, by forcing the PC to the main address?  

The problem is, when the main is interutpted by the
data in the UART, sometimes there is delay on
responding to the command thats sitting there, because
if the main gets halted in the middle of a time delay
or something then it has to finish.  I suppose the
other way around is to set a flag in the ISR to force
the MAIN loop to restart if that flag is ever set.
Might be a safer way to approach it?

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

2005\06\15@094012 by Peter Onion

flavicon
face
On Wed, 2005-06-15 at 06:13 -0700, alan smith wrote:

> So, bad practice to ORG the main loop so when
> returning from the ISR you always restart the MAIN
> again, by forcing the PC to the main address?  

You have no control over the return address from the ISR.  It doesn't
matter where you ORG your main loop to, the return from interrupt will
go back to where it came from.  If you are suggesting putting you main
loop at address 4 and then enabling interrupts, then I think this is
"Really Bad Idea" for many reasons.

I think you need to understand how to use interrupts properly, because
from your description you seem to have misunderstood the reason for
using them and how they work.  I think you would be better off trying to
use polled I/O than trying to use interrupts in the way you seem to
think they should be used.



> The problem is, when the main is interutpted by the
> data in the UART, sometimes there is delay on
> responding to the command thats sitting there, because
> if the main gets halted in the middle of a time delay
> or something then it has to finish.  

So don't use software loops for timing.  Use one of the timers.

> I suppose the
> other way around is to set a flag in the ISR to force
> the MAIN loop to restart if that flag is ever set.
> Might be a safer way to approach it?

If your main code is going to sit polling this flag, it might as well
sit polling the status bits in the UART looking for incoming
characters.

I suggest you have a look at some of the examples on
www.piclist.com/techref/microchip/rs232.htm
for how to use interrupts properly.

Peter



More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...