View previous topic :: View next topic |
Author |
Message |
homfray
Joined: 19 Nov 2003 Posts: 45 Location: Oxford
|
ext2 interrupt |
Posted: Tue Apr 06, 2004 9:14 am |
|
|
does anyone know the reason and how I can get out of this little prediciment
when I use ext_int_edge( 2, L_TO_H);
and enable_interrupts(INT_EXT2); it immediately goes to the interupt and doesn't wait for a change in state of pin_b2 to go from low to high
however when I do it the other way using ext_int_edge( 2, H_TO_L);
and enable the interupt it doesn't immediately go to the interupt it waits as it should until their is a tranistion from high to low on pin B2.
anyone got any experience with this.
its not a button de-bounce thing I have even left ten seconds before I enable the interupt and it still goes as soon as i set it |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: ext2 interrupt |
Posted: Tue Apr 06, 2004 10:06 am |
|
|
homfray wrote: | does anyone know the reason and how I can get out of this little prediciment
when I use ext_int_edge( 2, L_TO_H);
and enable_interrupts(INT_EXT2); it immediately goes to the interupt and doesn't wait for a change in state of pin_b2 to go from low to high
however when I do it the other way using ext_int_edge( 2, H_TO_L);
and enable the interupt it doesn't immediately go to the interupt it waits as it should until their is a tranistion from high to low on pin B2.
anyone got any experience with this.
its not a button de-bounce thing I have even left ten seconds before I enable the interupt and it still goes as soon as i set it |
Try this
Code: |
clear_interrupt( INT_EXT2);
enable_interrupts(INT_EXT2);
|
|
|
|
homfray
Joined: 19 Nov 2003 Posts: 45 Location: Oxford
|
|
Posted: Tue Apr 06, 2004 10:09 am |
|
|
on PCH I get the following error when I try that
Undefined identifier clear_interrupts |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Tue Apr 06, 2004 11:25 am |
|
|
homfray wrote: | on PCH I get the following error when I try that
Undefined identifier clear_interrupts |
I'm using a later compiler version.
I get this
Code: | .................... clear_interrupt( INT_EXT2);
216C: BCF FF0.1
.................... enable_interrupts(INT_EXT2);
216E: BSF FF0.4
|
You can do that as an asembly instruction with an older version of the compiler. It will clear the interupt flag that is already set before you enable jumping to the interupt routine. |
|
|
Ttelmah Guest
|
|
Posted: Tue Apr 06, 2004 2:50 pm |
|
|
Neutone wrote: | homfray wrote: | on PCH I get the following error when I try that
Undefined identifier clear_interrupts |
I'm using a later compiler version.
I get this
Code: | .................... clear_interrupt( INT_EXT2);
216C: BCF FF0.1
.................... enable_interrupts(INT_EXT2);
216E: BSF FF0.4
|
You can do that as an asembly instruction with an older version of the compiler. It will clear the interupt flag that is already set before you enable jumping to the interupt routine. |
Really the 'safe sequence', is to read portB (so that the latch is reset), then clear the interrupt, then enable the interrupts.
If your compiler is too old to have the 'clear_interrupt' function, then simply use a #bit define for the interrupt bit, and set this to zero.
Best Wishes |
|
|
homfray
Joined: 19 Nov 2003 Posts: 45 Location: Oxford
|
|
Posted: Wed Apr 07, 2004 2:33 am |
|
|
Thanks you lot I really appreciate everything!!, it now works I have added
Header
Code: | #byte INTCON3 = 0xFF0
#bit RESET_INTERRUPT = INTCON3.1 |
Main Code
Code: | input_b();
RESET_INTERRUPT = 0;
enable_interrupts(INT_EXT2); |
and it works how I planned (started to get worried for a while).
I am using PCH compiler 3.180 are you saying there is a newer version of the compiler with more commands such as clear_intterupt?
Once again thanks for all your help I really appreciate it. This is how a forum should be, a place where experience can be shared by people with the know in order to help people who would like to know |
|
|
|