Hi,
Perhaps not related to your problem but in the Alarm subroutine you have this:
Code:
GOTO Alarm ' Jump over Subroutines, so they don't try to execute
'-------------------[ Begin Alarm Interrupt Handler ]--------------------
Alarm:
Which seems to not jump OVER the Alarm subroutine but rather TO it.
Try setting only the related bits in INTCON2 and do it before you enable the interrupts ie:
Code:
INTCON2.4 = 0 'INT2 interrupts on falling edge
@ INT_ENABLE INT2_INT ; enable external (INT) interrupts
It is correct that you don't need to mess with the BITS concerning the interrupt flag, interrupt enable flag and interrupt priority bit but you still need to set it up to respond the way you want.
The reason it does not initially work if you don't write to INTCON2 is because if you look at table 5.2 in the datasheet you see that bit4 defaults to 1 at power on which means it interrupts on the falling edge as default and you'll need to change that.
Another thing is that because you write all zeros to INTCON2 you are enabling the pullups on PortB (which are disabled by default) and as it happens INT2 is on PORTB.2. So if you by any chance have an external pull down resistor to hold the line low you are effectively creating a voltage divider and the voltage on the pin might actually be anywhere between Vdd and Vss - a little noice there and it might trip the interrupts.
Well, that's all just speculations but IMO worth looking into.
/Henrik.
Bookmarks