Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Fri Jan 18, 2019 2:04 am |
|
|
GLOBAL needs to be enabled.
This is the 'master gate'. Allows _all_ enabled interrupts to be
turned on/off. To use an interrupt, it must be enabled, and GLOBAL
must also be enabled.
Then when an interrupt occurs, it's handler will be called. The handler
has to exist, or the code will go off into nowhere.
Then there is an issue.
With an interrupt, there is the 'event' that triggers it, and the flag
that gets set. Clearing an interrupt resets the flag, and this is done
automatically for you be the compiler, so you don't need an extra clear
in the routine. However this does not reset the 'event'. In this case
the 'event', is the act of PortB not matching what has last been
read from PortB. On and interrupt on change, the
handler _must_ read the port, to reset the event, or the flag cannot
be cleared (since the event is set, it'll keep resetting the flag). If this
is not done, the code can't actually leave the interrupt handler - it'll
be called for ever.
So, GLOBAL needs to be enabled.
Handler must exist.
Handler must read the input pin. |
|