Hi,
Interrupts are hardware events, you can't just use any pin you like. You must use a pin which is capable of generating an interrupt. On the 18F4550 these are PortB.0 (INT0), PortB.1 (INT1) and PortB.2 (INT2).
(PortB.4-7 are also capable of generating interrupts (interrupt on change) but they are trickier to use than the "normal" INT pins).
In the INTCON2 register you'll find bits which controlls if the interrupt should be triggered off a rising or falling edge, set that up to your needs. You then declare your interrupt as shown in every example of DT-Ints
Code:
INTCON2.6 = 0 'Interrupt on falling edge of INT0
INTCON2.5 = 1 'Interrupt on rising edge of INT1
' Here two interrupts are declared. One for INT0 (PortB.0) and one for INT1 (PortB.1).
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT0_INT, _RcvCAN, PBP, yes
INT_Handler INT1_INT, _DoSomething, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
Main:
Pause 100
Toggle LED
Goto Main
RcvCAN:
' Put your code here or GOSUB it but make SURE you have a RETURN at the end of the routine so you come back here, otherwise you'll crash.
@ INT_RETURN
DoSomethingElse:
Toggle AnotherLED
@ INT_RETURN
Well, something like that.
/Henrik.
Bookmarks