Searching \ for '[PIC]: help please on correct Multiple Interupt ha' 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: 'help please on correct Multiple Interupt ha'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: help please on correct Multiple Interupt ha'
2001\01\02@065701 by Paul Erkiert

flavicon
face
Hi I am trying to test multiple interupts (T0IF BRIF and INTF)
I need to                     btfss    INTCON,TOIF
                   goto     test_next          ;THIS Doesn't seem very elegant!
                   goto     toifint                ;handle toif int
test_next      btfss    INTCON,BRIF    ;test for next

is there a more elegant way?
Also after handling (say)toif and clearing toiFlag
should I jump back and continue testing flags or just RETFIE and if multiple flags were set
is it ok to then just re-enter as a new inturupt as the other flag would cause it re interupt?

Paul Erkiert

spam_OUTpaulTakeThisOuTspamg4bks.fsnet.co.uk

http://www.g4bks.fsnet.co.uk/

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@070957 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

I presume that BRIF=RBIF?  If so then you are using the lowest three bits in
INTCON so I guess you could branch dependant on the value of these three
bits e.g.

movwf   INTCON
andlw   0x07
addwf   PCL
goto    test1
goto    test2
goto    test3
etc..
etc...

but to be honest I don't see the problem with the original method.  Whether
you re-test the flags after servicing an interrupt depends if you want to
have the minimum latency.  By exiting the ISR and imediately re-entering it,
you have all the overhead of saving and restoring the W and STATUS
registers.

Regards

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@082741 by Drew Vassallo

picon face
>I am trying to test multiple interupts (T0IF BRIF and INTF)
>I need to
>                     btfss    INTCON,TOIF
>                     goto     test_next          ;THIS Doesn't seem very
>elegant!
>                     goto     toifint                ;handle toif int
>test_next      btfss    INTCON,BRIF    ;test for next

I never really heard of the computed goto used for interrupt polling.  I
suppose it would be useful if you wanted to go to different routines
depending on multiple flag bits set each time.  If you want to poll for one
single flag bit, though, your way is fine, with one exception:

btfsc INTCON, T0IF  ;  Note that this uses a ZERO, not an "O" in the flag
goto t0ifint
btfsc INTCON, RBIF
goto rbint
etc...

Don't create a label just to test the next bit.  Skip over the goto if the
bit is clear rather than checking for it being set.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@095352 by Olin Lathrop

face picon face
> I am trying to test multiple interupts (T0IF BRIF and INTF)
> I need to=20
>                     btfss    INTCON,TOIF
>                     goto     test_next          ;THIS Doesn't seem very =
> elegant!
>                     goto     toifint                ;handle toif int
> test_next      btfss    INTCON,BRIF    ;test for next
>
> is there a more elegant way?

Yes:

   btfsc  intcon, t0if
   goto   toifint
   btfsc  intcon, ...
   goto   ...

> Also after handling (say)toif and clearing toiFlag
> should I jump back and continue testing flags or just RETFIE and if =
> multiple flags were set
> is it ok to then just re-enter as a new inturupt as the other flag would =
> cause it re interupt?

I usually do the latter.  You give up a little efficiency if the two
interrupts happen to come together, but you don't waste cycles every time
when they don't.  It's also just a little less complex, and therefore
maintainable, which is usually more important that a few cycles anyway.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, EraseMEolinspam_OUTspamTakeThisOuTembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@111319 by Dan Michaels

flavicon
face
If so then you are using the lowest three bits in
>INTCON so I guess you could branch dependant on the value of these three
>bits e.g.
>
>movwf   INTCON
>andlw   0x07
>addwf   PCL
>goto    test1
>goto    test2
>goto    test3
>etc..
>etc...
>

With this scheme, would not the subroutine accessed by test3
have to service "both" bit 0 and bit 1 interrupts?

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@121357 by Bob Ammerman

picon face
----- Original Message -----
From: Dan Michaels <oricomspamspam_OUTUSWEST.NET>
To: <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Tuesday, January 02, 2001 11:13 AM
Subject: Re: [PIC]: help please on correct Multiple Interupt handling,


{Quote hidden}

It would _have_ to service at least one of the them. It _could_ service
both.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@123131 by Dan Michaels

flavicon
face
>> >movwf   INTCON
>> >andlw   0x07
>> >addwf   PCL
>> >goto    test1
>> >goto    test2
>> >goto    test3
>> >etc..
>> >etc...
>> >
>>
>> With this scheme, would not the subroutine accessed by test3
>> have to service "both" bit 0 and bit 1 interrupts?
>
>It would _have_ to service at least one of the them. It _could_ service
>both.
>

Then all you have done is required "another" filter at the
next level down to sort bit 0 from bit 1. And then test7 would
require 3 filters, I believe.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@133533 by Andrew Warren

flavicon
face
Paul Erkiert <KILLspampaulKILLspamspamg4bks.fsnet.co.uk> wrote:

> I am trying to test multiple interupts (T0IF BRIF and INTF)
> I need to
>                    btfss    INTCON,TOIF
>                    goto     test_next
>                    goto     toifint
>     test_next      btfss    INTCON,BRIF
>
> is there a more elegant way?
> Also after handling (say)toif and clearing toiFlag
> should I jump back and continue testing flags or just RETFIE and if
> multiple flags were set is it ok to then just re-enter as a new
> inturupt as the other flag would cause it re interupt?

Paul:

   btfsc   INTCON,TOIF
   goto    toifint
   btfsc   INTCON,BRIF
   goto    brifint
   ....

Or, if you want to solve BOTH of your problems at once:

       btfss   INTCON,TOIF
       goto    test_brif

       ; do TOIF processing here...

   test_brif:

       btfss   INTCON,BRIF
       goto    test_intf

       ; do BRIF processing here...

   test_intf:

       ....

-Andy


=== Andrew Warren --- RemoveMEaiwTakeThisOuTspamcypress.com
=== Staff Systems Engineer, IPD
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@163208 by Olin Lathrop

face picon face
{Quote hidden}

Or you could implement a priority scheme with the table entries.  For
entries that have multiple interrupt conditions, just jump to the handler
for the highest priority one.  In other words 7 entries but only 3 different
handler routines.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spamBeGoneolinspamBeGonespamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\02@232922 by Dan Michaels

flavicon
face
Olin wrote:
.......
>Or you could implement a priority scheme with the table entries.  For
>entries that have multiple interrupt conditions, just jump to the handler
>for the highest priority one.  In other words 7 entries but only 3 different
>handler routines.
>

Yeah, this "almost" seems like a clever way to prioritze interrupts:

movwf   INTCON
andlw   0x07
addwf   PCL
nop
goto    test1
goto    test2
goto    test2
goto    test3
goto    test3
goto    test3
etc..
etc...

It is a "very" fast filter, but it gets extremely unwieldy as
you add more interrupts 8 -> 16 -> 32 -> 64/etc table entries.
To do PIR1 this way, you need a table with 256 entries. Oops,
---> on to the next problem :).

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\01\03@031251 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

Yes.  It was just a suggestion for a possible alternative. Like I said, I
couldn't really think of a situation that checking the flags consecutively
wouldn't be OK.

Mike

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\03@031504 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

Absolutely.  It would only work in the original posters case because he
happens to be using just the lower three bits of INTCON.  As you say, it
would rapidly become unusable if the extra interrupt flags in PIR1 etc. had
to be checked.

Mike

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\03@052909 by Alan B. Pearce

face picon face
> If so then you are using the lowest three bits in
> >INTCON so I guess you could branch dependant on the value of these three
> >bits e.g.
> >
> >movwf   INTCON
> >andlw   0x07
> >addwf   PCL
> >goto    test1
> >goto    test2
> >goto    test3
> >etc..
> >etc...
> >
>
> With this scheme, would not the subroutine accessed by test3
> have to service "both" bit 0 and bit 1 interrupts?

Surely this would depend on being able to deal with the latency of doing a
retfie from the test3 routine, which would immediately be followed by another
interrupt which would be handled by the test2 routine. After this does its
retfie then there would be another interrupt handled by the test1 routine
(assuming the hardware setting bits 2 or 3 have not triggered again).

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\03@104933 by Bob Ammerman

picon face
A timing analysis:

> > >movwf   INTCON        ;[1]
> > >andlw   0x07               ;[2]
> > >addwf   PCL               ;[3-4]
> > >goto    test1                ;[5-6]
> > >goto    test2
> > >goto    test3
> > >etc..
> > >etc...

so test1, test2 and test3 all get control after 6 cycles.

With:

   btfsc    INTCON,0      ;[1]
   goto    test1                ;[2-3]
   btfsc    INTCON,1      ;[3-4]
   goto    test2                ;[4-5]
   btfsc    INTCON,2      ;[5-6]
   goto    test3                ;[6-7]

Now test1 gets control after 3 cycles, test 2 after 5 and test3 after 6.

A little quicker for the 'higher priority' interrupt this way.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\03@143138 by Paul Erkiert

flavicon
face
thanks for all the help
obvious dont know why that gave me trouble
 btfsc INTCON,RBIF ; IF PORT CHANGE
 goto rbifint
 btfsc INTCON,T0IF ; TEST FOR T0INT
 goto tmr0int
 btfsc INTCON,INTF
 goto intfint
 bsf Flags,6  ; should never get here error
with a little catch all error if things go wrong elswhere

Paul

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


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