Searching \ for 'PIC interrupts' 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/ints.htm?key=interrupt
Search entire site for: 'PIC interrupts'.

Truncated match.
PICList Thread
'PIC interrupts'
1998\08\26@061308 by Nuno Pedrosa

flavicon
face
Hi! How do I deal with interrupts in PIC16x.. ?

Here's what I (think) know:
- Single int vector in 0x0004
- I need to check which int to handle in the routine

But, what flags are changed upon an interrupt call, and which flags are
recovered after the int call?

>From the docs, I think it's possible to use the ints in a polling way.
I would do this by disabling the GIE (mask off all ints) and then, in
the code, check the individual flags.
Is this possible?

Thank you,
Nuno.

--
   .^.                                              _,^,_         /\
___( | )_____ Nuno Filipe Freitas Pedrosa __________ o(`} | , __/\/ /__
/*\\|//*\    SIEMENS S.A. Portugal                  (]|  /'    \ \/\
\(\\V//)/    spam_OUTNuno.PedrosaTakeThisOuTspamoen.siemens.de     (]|`%   (") \/\ \
 ` -=- '     Tel.  :00351-1-4242454         (")      /`/        / /\/
__B//|\\P___________________________________________\' / `/______\/____
   `-' "Try and leave this world a little better than you found it..."

1998\08\26@083136 by Clyde Smith-Stubbs

flavicon
face
On Wed, Aug 26, 1998 at 11:02:13AM +0000, Nuno Pedrosa wrote:
> Hi! How do I deal with interrupts in PIC16x.. ?
>
> - Single int vector in 0x0004
> - I need to check which int to handle in the routine

Correct. Be aware that you must check both the flag and enable bits
to determine if an interrupt actually was triggered by a particular
source - the flag bits will be set even if the corresponding enable bit
is not.

> But, what flags are changed upon an interrupt call, and which flags are
> recovered after the int call?

None. If you do anything in your interrupt routine that may alter the
flags, you must save them first. This means you can do things like bit
test and set instructions, but not much else, without saving the status.
To save the status you must first save W, and how and where you do that
is dependent on the particular PICMicro, since some have RAM in all
banks, some have common RAM, some have RAM in bank0 only but SFRs
in bank1 etc. It's quite a job to cater for all that (a good C compiler
does that for you, hint, hint!)

> >From the docs, I think it's possible to use the ints in a polling way.
> I would do this by disabling the GIE (mask off all ints) and then, in
> the code, check the individual flags.

Yup absolutely, if you call that using interrupts (which it ain't). But it's a
perfectly legitimate technique for some situations.

HAve fun!

--
Clyde Smith-Stubbs               |            HI-TECH Software
Email: .....clydeKILLspamspam@spam@htsoft.com          |          Phone            Fax
WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  (408) 490 2885
PGP:   finger clydespamKILLspamhtsoft.com   | AUS: +61 7 3354 2411 +61 7 3354 2422
---------------------------------------------------------------------------
HI-TECH C: compiling the real world.

1998\08\27@021159 by Dr. Imre Bartfai

flavicon
face
Hi,

yes, it is possible to check the IT flags. However, you should reset the
flags the same way as in the ISR. To answer the question which flags are
re-set, see the following:

all the IT's have their individual enable flags (maybe associated with any
group or global flag), ending with E, e. g. INTE.

then the IT will set the associated F flag (e. g. INTF). You must evaluate
these, and reset that caused the interrupt actually. In the majority of
cases, the E and F bits are in the same register. Not always, but more and
more often ("nicht immer, aber immer šfter!").

Imre

On Wed, 26 Aug 1998, Nuno Pedrosa wrote:

{Quote hidden}

1998\08\27@024143 by Caisson

flavicon
face
> Van: Nuno Pedrosa <EraseMEnuno.pedrosaspam_OUTspamTakeThisOuTOEN.SIEMENS.DE>
> Aan: PICLISTspamspam_OUTMITVMA.MIT.EDU
> Onderwerp: PIC interrupts
> Datum: woensdag 26 augustus 1998 13:02
>
> Hi! How do I deal with interrupts in PIC16x.. ?
>
> Here's what I (think) know:
> - Single int vector in 0x0004
> - I need to check which int to handle in the routine

Correct !

> But, what flags are changed upon an interrupt call, and which flags are
> recovered after the int call?

Aww ... In a PIC ?  None & none !  You have to do it yourself offcourse ;-)

> >From the docs, I think it's possible to use the ints in a polling way.
> I would do this by disabling the GIE (mask off all ints) and then, in
> the code, check the individual flags.
> Is this possible?

Yes. That's right.

Greetz,
 Rudy Wieser

1998\08\27@102632 by Stefan Sczekalla-Waldschmidt

flavicon
face
Hi Folks,

> > But, what flags are changed upon an interrupt call, and which flags are
> > recovered after the int call?

I think this question is misunderstood.

I think Pedro likes to know, what irq-flag is set if e.g.
tmr0-irq appears, what flags ar reset/cleared with the retfie
instructions.

Pedro, have a look at the Data-sheet which will be a good source
for answers.

You have GIE which enables or disables interrupts at all.
Also you have the interrupt-enable-flag's and corresponding interupt
flag's.

When GIE enables interupts and each special irq-enable-flag is
set an jump to org 0004h is executed. The interupt flag's
can be used to test which of the enabled interrupts occured.

for further reading refer to the corresponding PIC-Data-sheet.
( I don4t like to give the info, and have no data-sheet available
at th moment).

Kind regards

       Stefan Sczekalla-Waldschmidt
       @spam@sswKILLspamspamoikossw.de

1998\08\27@122426 by Stefan Sczekalla-Waldschmidt

flavicon
face
Hi Nuno,

Just like to excuse me because I remebered your name completely wrong.
Sorry for have it lost in my sieve, called brain.

Kind regards

       Stefan Sczekalla-Waldschmidt
       KILLspamsswKILLspamspamoikossw.de

1998\08\27@145801 by andre

flavicon
face
> > But, what flags are changed upon an interrupt call, and which flags are
> > recovered after the int call?
>
> Aww ... In a PIC ?  None & none !  You have to do it yourself offcourse ;-)
>

each interrupt has its own flag

intcon   register

bit 2  -  TMR0 overflow int flag
bit1   -  external int flag
bit0  - RB port on change

and  a few more

but you have to clear it in software.

Andre  Abelian

1998\08\28@023602 by Mike Keitz

picon face
On Thu, 27 Aug 1998 15:59:04 +0100 Stefan Sczekalla-Waldschmidt
<RemoveMEsswTakeThisOuTspamOIKOSSW.DE> writes:
>Hi Folks,
>
>> > But, what flags are changed upon an interrupt call, and which
>flags are
>> > recovered after the int call?
>
>I think this question is misunderstood.
>
>I think Pedro likes to know, what irq-flag is set if e.g.
>tmr0-irq appears, what flags ar reset/cleared with the retfie
>instructions.

The GIE flag is the only one that is automatically operated.  It is
always cleared when an interrupt starts (after the last instruction in
the interrupted program executes, but before the first instruction in the
ISR executes).  This prevents the ISR from being interrupted.  The RETFIE
instruction sets GIE before returning.  (The set of GIE is the only
difference between RETFIE and RETURN.)  If an interrupt is still pending
when the RETFIE executes, the PIC will start again at the top of the ISR
before executing any of the main program.


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\08\28@082534 by Thomas McGahee

flavicon
face
The response below is correct, but there is one more matter
of interest that must be taken into account. Before performing
the RETFIE you must Clear the appropriate interrupt flag bit.
Failure to do so will cause the interrupt to re-assert itself
over and over again. The "appropriate" flag bit to Clear is
the one associated with the interrupt action taken. In many
programs the user may only have enabled a single form of
interrupt, but often the user will enable multiple interrupt
sources, and in that case the ISR (Interrupt Service Routine)
must poll the interrupt flags, perform the appropriate action,
and then Clear the appropriate interrupt flag just prior to
executing the RETFIE instruction.

Hope this helps.
Fr. Tom McGahee

----------
{Quote hidden}

1998\08\28@122534 by Nuno Pedrosa

flavicon
face
Hi! Thank you all for your help!

Int handling is quite simple to understand in PIC, I guess. PIC does
very little. 8)
I know what I wanted: on a int, the GIE is disabled, and then will be
enabled by RETFIE. All other flags, all the registers and whatever
cleaning is needed, must be done in SW.

Regarding Stack Manipulation, someone suggested me to use C.  8)
Well, I'd love to, but the PIC needs to complete certain
tasks in less than 64us in my project. So, since they are simple, I
stood by assembly. It's not that difficult...I just comment each line,
so I don't forget what it does. ;)

Have a nice weekend!
Nuno Pedrosa.


{Quote hidden}

--
   .^.                                              _,^,_         /\
___( | )_____ Nuno Filipe Freitas Pedrosa __________ o(`} | , __/\/ /__
/*\\|//*\    SIEMENS S.A. Portugal                  (]|  /'    \ \/\
\(\\V//)/    Nuno.PedrosaEraseMEspam.....oen.siemens.de     (]|`%   (") \/\ \
 ` -=- '     Tel.  :00351-1-4242454         (")      /`/        / /\/
__B//|\\P___________________________________________\' / `/______\/____
   `-' "Try and leave this world a little better than you found it..."

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