PDA

View Full Version : 18F2455 - Interrupts config question



NL2TTL
- 11th October 2010, 15:29
I have a PIC 18F2455 and try to use serval interrupts:

RB0
RB1
RB2

I found the following in the PBP Manual:

INTCON = %10010000

Only I can't find the explanation from this (already take a look in the datasheet)
How can i configure the RB1 and RB2 Interrupts as well.

Maybe a simple question only not for me (at this moment).

mackrackit
- 11th October 2010, 15:48
Take a look at the INTCON3 register.
RB1 is INT1
RB2 is INT2

NL2TTL
- 11th October 2010, 15:57
Oke I understand I can take a look at the INTCON3 only I can not figure out how the INTCON settings work.

What does INTCON = %10010000 do exactly
And how do I have to config INTCON3

mackrackit
- 11th October 2010, 16:09
What does INTCON = %10010000 do exactly
BIT 7 Enables all unmasked interrupts
BIT 4 Enables INT0 which is RB0

For the others INTCON3 will have bits 3 and 4 set
INTCON3 = %00011000

NL2TTL
- 11th October 2010, 16:22
And do I understand it the right way that INTCON3 overwrite the INTCON2?
Or do i have to set INTCON2 also?

NL2TTL
- 11th October 2010, 16:32
I think after reading the datasheet again this is what I need, can sombody please confirm?


INTCON = %10010000 ; Enable External Interupt INT0
; INTCON.7 = Enables all unmasked interrupts
; INTCON.6 = Enables all unmasked peripheral interrupts
; INTCON.5 = Disables the TMR0 overflow interrupt
; INTCON.4 = Enables INT0 which is RB0
; INTCON.3 = Disables the RB port change interrupt
; INTCON.2 = TMR0 register did not overflow
; INTCON.1 = The INT0 external interrupt did not accur
; INTCON.0 = None of the RB7:RB4 pins have changed state

INTCON2 = %11110000 ; INTCON2.7 = All pull up are disabled
; INTCON2.6 = INT0 trigger on rising edge
; INTCON2.5 = INT1 trigger on rising edge
; INTCON2.4 = INT2 trigger on rising edge
; INTCON2.3 = Not used
; INTCON2.2 = TMR0 low priority
; INTCON2.1 = Not used
; INTCON2.0 = Port change priority / LOW priority

INTCON3 = %00011000 ; INTCON3.7 = INT2 Low priority
; INTCON3.6 = INT1 LOW priority
; INTCON3.5 = Not used
; INTCON3.4 = INT2 external enabled
; INTCON3.3 = INT1 external enabled
; INTCON3.2 = Not used
; INTCON3.1 = INT2 Flag (Read Only)
; INTCON3.0 = INT1 Flag (Read Only)

mackrackit
- 11th October 2010, 16:32
They are separate registers.
If INTCON2 needs set to do what you want then set the bits needed, otherwise you can leave it alone.

NL2TTL
- 11th October 2010, 16:34
I think a give the answer :) thank you very much: mackrackit

mackrackit
- 11th October 2010, 16:36
I think after reading the datasheet again this is what I need, can sombody please confirm?
That looks like it will work.

NL2TTL
- 12th October 2010, 23:12
Last part of the interrupt question:

In the PBP manual it says: on interrupt goto lable.
Do i have to check in the lable for state on port INT0 INT1 INT2 example:

On interrupt goto led


LED:
IF PORTB.0 = 1 Then GOTO LED100
ELSE
IF PORTB.1 = 1 Then GOTO LED200
ELSE
IF PORTB.2 = 1 Then GOTO LED300
ENDIF

mackrackit
- 13th October 2010, 02:24
Yes, something like that...
I am feeling lazy so read these
http://www.picbasic.co.uk/forum/showthread.php?t=8494&p=54775#post54775
http://www.picbasic.co.uk/forum/showthread.php?t=3463&p=18511#post18511