Exact match. Not showing close matches.
PICList
Thread
'[PIC] Interrupt Questions'
2008\07\28@150806
by
threewheeler7
|
I really have not had too much experience with interrupts, i have built and
coded a few things that should have had them, mostly for the reason that way
back when i first started learning about PICs, i was always warned how hard
interrupts where to implement and that i should find a way to work without
them. so that turned me off from them for the longest time. but i know they
have there place and i need to start using them more. So 1. if i am using
RB0/INT as my interrupt source, can i still read RB0 as a bit without
disabling interrupts? ie. waiting for input to fall back down. also can i
exit a interrupt routine with a "goto" instead of a "retfie"? ie. if i need
to stop the program from what its doing and do something completely
different.
--
View this message in context: www.nabble.com/Interrupt-Questions-tp18697286p18697286.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.
2008\07\28@152206
by
Bob Blick
|
Hi Three,
You can still read the pin even if it's set up to be an interrupt.
As far as using a goto instead of a retfie, any path you take must
eventually end in retfie or you'll break the stack. And since you ask
the question, let me suggest that by asking that particular question I
think the structure of your program is faulty if you are thinking about
doing it that way. Interrupts should be fairly short, maybe increment a
counter, put a byte in a buffer, or set a flag and then return.
Cheerful regards,
Bob
On Mon, 28 Jul 2008 12:07:40 -0700 (PDT), "threewheeler7"
<spam_OUTthreewheeler7TakeThisOuT
hotmail.com> said:
{Quote hidden}>
> I really have not had too much experience with interrupts, i have built
> and
> coded a few things that should have had them, mostly for the reason that
> way
> back when i first started learning about PICs, i was always warned how
> hard
> interrupts where to implement and that i should find a way to work
> without
> them. so that turned me off from them for the longest time. but i know
> they
> have there place and i need to start using them more. So 1. if i am using
> RB0/INT as my interrupt source, can i still read RB0 as a bit without
> disabling interrupts? ie. waiting for input to fall back down. also can i
> exit a interrupt routine with a "goto" instead of a "retfie"? ie. if i
> need
> to stop the program from what its doing and do something completely
> different.
--
http://www.fastmail.fm - IMAP accessible web-mail
2008\07\28@160532
by
Richard Seriani, Sr.
|
----- Original Message -----
From: "threewheeler7" <.....threewheeler7KILLspam
@spam@hotmail.com>
To: <piclist
KILLspammit.edu>
Sent: Monday, July 28, 2008 3:07 PM
Subject: [PIC] Interrupt Questions
>
> I really have not had too much experience with interrupts, i have built
> and
> coded a few things that should have had them, mostly for the reason that
> way
> back when i first started learning about PICs, i was always warned how
> hard
> interrupts where to implement and that i should find a way to work without
> them.
Not necessarily difficult, it just means a little bit of studying about what
they are, how they work, and how to implement them. If you were "always"
warned about how difficult they are to implement, you were being done an
disservice. They definitely have their place in programming any
microprocessor or microcontroller. In fact, I dare say, you can 't get
along without them if you are going to do any serious, or even semi-serious,
programming.
> so that turned me off from them for the longest time. but i know they
> have there place and i need to start using them more. So 1. if i am using
> RB0/INT as my interrupt source, can i still read RB0 as a bit without
> disabling interrupts? ie. waiting for input to fall back down.
Once enabled as an interrupt, what purpose would be served by reading the
pin? A change of state on RB0 will initiate an interrupt - what you decide
to do with that information is up to you. You can ignore it or you can use
that information to do something. If you want to use RB0 for some other
purpose (as a general purpose I/O pin), you should disable the interrupt.
> also can i
> exit a interrupt routine with a "goto" instead of a "retfie"? ie. if i
> need
> to stop the program from what its doing and do something completely
> different.
I supose you could but, if you think you need to, you likely don't really
want to use an interrupt to accomplish whatever it is you are trying to do.
You don't have an unlimited stack, so how are you going to handle stack
overflow after the number of times you get an interrupt exceeds stack size?
How are you going to re-enable the interrupt? How are you going to handle
situations where you 'interrupted' a routine that produces an change to an
output that you need to know the result of, if you don't return to the point
it was interrupted?
Please take a look at the datasheet for your PIC; it probably contains some
discussion about the RB0 interrupt. If you are using a mid-range PIC, the
mid-range family reference (available on the Microchip site) gives a bit
more info. I also recommend you try a Google search for the words PIC
tutorial; many of the hits you will get cover interrupts in general, and the
RB0 interrupt in particular. Some are better than others but, as you learn
and experiment, you'll be able to spot the not-so-good ones.
Good luck and have fun learning.
Richard
2008\07\28@163510
by
threewheeler7
thank you much guys. i definitely understand now.
--
View this message in context: www.nabble.com/Interrupt-Questions-tp18697286p18699047.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.
2008\07\28@190122
by
Jinx
>1. if i am using RB0/INT as my interrupt source, can i still read RB0
> as a bit without disabling interrupts? ie. waiting for input to fall back
> down
Yes. You can also change the edge which triggers the interrupt. ie you
can select to detect when the pin goes L->H and/or when it goes H->L
> also can i exit a interrupt routine with a "goto" instead of a "retfie"?
Yes, but there will be a return address left on the stack, and each time
that ISR is called. Eventually there'll be a crash. PICs with POP can
deal with orphaned addresses on the stack if necessary, but you're
better to exit with RETFIE to keep the stack tidy
> ie.if i need to stop the program from what its doing and do something
> completely different
Not quite sure what you mean by that. When program flow enters an
ISR, interrupts are turned off by the hardware. If you exit that ISR with
RETURN instead of RETFIE, interrupts will not be turned back on
2008\07\28@193956
by
Apptech
>> also can i exit a interrupt routine with a "goto" instead
>> of a "retfie"?
> Yes, but there will be a return address left on the stack,
> and each time
> that ISR is called. Eventually there'll be a crash. PICs
> with POP can
> deal with orphaned addresses on the stack if necessary,
> but you're
> better to exit with RETFIE to keep the stack tidy
Translation:
NO!
You can't do this unless you are an expert and understand
exactly what you are doing and what happens when you do it.
Until then, just don't do it. The consequences will almost
always be fatal (to the program's function if not to you).
Russell
'[PIC] Interrupt Questions'
2008\08\19@100354
by
Dario Greggio
>>... also can i
>>exit a interrupt routine with a "goto" instead of a "retfie"? ie. if i
>>need
>>to stop the program from what its doing and do something completely
>>different.
Just a side note:
using C18 (and possibly other C compilers) a "GOTO" which causes a jump
to the end of the interrupt handler function, or a explicit C "return"
in its body, are converted to RETFIE automagically :)
More... (looser matching)
- Last day of these posts
- In 2008
, 2009 only
- Today
- New search...