18F2455 - Interrupts config question


Closed Thread
Results 1 to 11 of 11
  1. #1

    Default 18F2455 - Interrupts config question

    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).

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Take a look at the INTCON3 register.
    RB1 is INT1
    RB2 is INT2
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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
    Dave
    Always wear safety glasses while programming.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    And do I understand it the right way that INTCON3 overwrite the INTCON2?
    Or do i have to set INTCON2 also?

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I think after reading the datasheet again this is what I need, can sombody please confirm?

    Code:
    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)

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    They are separate registers.
    If INTCON2 needs set to do what you want then set the bits needed, otherwise you can leave it alone.
    Dave
    Always wear safety glasses while programming.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    I think a give the answer thank you very much: mackrackit

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I think after reading the datasheet again this is what I need, can sombody please confirm?
    That looks like it will work.
    Dave
    Always wear safety glasses while programming.

  10. #10


    Did you find this post helpful? Yes | No

    Default

    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

    Code:
    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

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts