View previous topic :: View next topic |
Author |
Message |
irmanao
Joined: 08 Apr 2015 Posts: 77
|
Dual external interrupt problem |
Posted: Tue Jun 13, 2017 7:26 am |
|
|
I'm trying to use both external interrupts (on 18f4550 and vs5.008) EXT1 and EXT2 but when i add the line Code: | enable_interrupts(INT_EXT1); | the program acts erratically without even the push of the button(with pull-up resistor).
If i exclude this line the interrupt on RB2 works fine.
Code: | enable_interrupts(GLOBAL);
ext_int_edge(1, H_TO_L);
ext_int_edge(2, H_TO_L);
clear_interrupt(INT_EXT1);
//enable_interrupts(INT_EXT1);
clear_interrupt(INT_EXT2);
enable_interrupts(INT_EXT2); |
What am i missing?
thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Tue Jun 13, 2017 7:49 am |
|
|
Without seeing what is in your INT_EXT1 interrupt handler, we can't help.
Odds are you have something in it, that is resulting in something like the classic compiler warning 'interrupts disabled to prevent re-entrancy', or just resulting in the code being stuck inside the EXT1 handler. |
|
|
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
Posted: Tue Jun 13, 2017 8:50 am |
|
|
Just a simple add function Code: | #INT_EXT1
void ext_int1 (void){
minutes++;
if (minutes>59)
hours--;
}
#INT_EXT2
void ext_int2 (void){
hours++;
} |
Both work on their own but not together.. there is no warning from the compiler. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Tue Jun 13, 2017 8:56 am |
|
|
hmm.. v5.008 was really 'young' and may not be compiling correct code.You should make the smallest program possible, compile, test and dump the listing to see what is being created.
Post here so we can see it...
Jay |
|
|
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
Posted: Tue Jun 13, 2017 9:48 am |
|
|
How do i test and dump the listing...?
Never done this before..
I actually fixed the issue. It was a faulty push button, changed it and everything is stable now. I would like to know how to do the test thingy.
thanks for your time |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 14, 2017 3:02 am |
|
|
Look in your project folder. This the folder that has your C source file(s)
for the project. After a successful compilation with no errors, you will see
a .LST file in your project directory. It will have the same name as your
main C source file, but the file extension will be .LST. It has the ASM
code listing for the program.
There is compiler option to make the .LST file in "Symbolic" mode.
I suggest that you use that option. The ASM code will be easier to read. |
|
|
|