@Darrel Taylor Interrupt ;-)


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44

    Default @Darrel Taylor Interrupt ;-)

    Hi Darrel,
    iīm using your last interrupt posting to me for a 16F913. But something is not working just like at the 16F872. I read the datasheet for the 16F913 and i think itīs the same parameter like 16F872.
    I set all PORTS to DIGITAL I/O (this was really hard to find out for this device). I think they are ok so.

    Maybe you know why the interrupt is not working.
    Code:
    DEFINE OSC 8
    ADCON1 = %111
    ANSEL = 0
    CMCON0 = 7
    LCDCON = %01000000
    LCDSE0 = 0
    LCDSE1 = 0
    
    @ERRORLEVEL -306
    
    RBCPins     VAR Byte
    LastPins    VAR Byte
    Lastpins =  PORTB
    
    INTCON.0 = 0
    INTCON.3 = 1
    
    TRISA = %00111000       ' RA0-2 OUT, RA3-5 INPUT
    TRISB = %11100000       ' RB7 & RB6 PORTChange by Interrupt, RB5 Input Clicker as Input is not needed for Interrupt change
    TRISC = %00000000
    
    ON INTERRUPT GOTO MyINT
    
    Main:
    '...
    '...
    '...
    GOTO Main
    
    DISABLE                        
    MyINT:
    RBCpins = PORTB
    IF RBCpins.7 <> Lastpins.7 THEN
        DPO2 = 0
        PAUSE 20
        DPO1 = 0
        PAUSE 40
        DPO2 = 1
        DPO1 = 1
    ENDIF
    
    IF RBCpins.6 <> Lastpins.6 THEN
        DPO1 = 0
        PAUSE 20
        DPO2 = 0
        PAUSE 40
        DPO1 = 1
        DPO2 = 1
    ENDIF
    INTCON.0 = 0
    RESUME
    ENABLE
    thx Robson
    Last edited by Robson; - 30th August 2007 at 23:25.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Maybe ....

    Code:
    IF RBCpins.7 <> Lastpins.7 THEN
        Lastpins.7 = RBCpins.7
        DPO2 = 0
        PAUSE 20
        DPO1 = 0
        PAUSE 40
        DPO2 = 1
        DPO1 = 1
    ENDIF
    
    IF RBCpins.6 <> Lastpins.6 THEN
        Lastpins.6 = RBCpins.6
        DPO1 = 0
        PAUSE 20
        DPO2 = 0
        PAUSE 40
        DPO1 = 1
        DPO2 = 1
    ENDIF
    DT

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Are you setting INTCON.GIE somewhere not shown?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    That Horrible Nasty Wicked ON INTERRUPT sets GIE for you.
    DT

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hmm! Maybe one more reason I don't use it...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Here's another reason ...,

    You can't turn GIE off. If you do, it jumps to the handler then turns GIE back on.
    Code:
    LED1  VAR PORTB.0
    
    ON INTERRUPT GOTO MyINT
    
    Main:
        PAUSE 500
        INTCON.7 = 0
    GOTO Main
    
    DISABLE
    MyINT:
        TOGGLE LED1
    RESUME
    That will flash the LED via the Interrupt handler, even though no interrupts have occured.
    <br>
    DT

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    One more reason to use DT-INTS ehh..;o}

    BTW: Nice work on the new interrupt routines Darrel. Most impressive.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Itīs not working. The INTCON registers seems to be the same, but nothing happens to PORTB change...
    Oh i didnīt see your last post.
    Is it not possible to work like before with RBCPins ... ?

    What does Note1 means?
    bit 7 GIE: Global Interrupt Enable bit
    1 = Enables all unmasked interrupts
    0 = Disables all interrupts
    bit 6 PEIE: Peripheral Interrupt Enable bit
    1 = Enables all unmasked peripheral interrupts
    0 = Disables all peripheral interrupts
    bit 5 T0IE: Timer0 Overflow Interrupt Enable bit
    1 = Enables the Timer0 interrupt
    0 = Disables the Timer0 interrupt
    bit 4 INTE: RB0/INT External Interrupt Enable bit
    1 = Enables the RB0/INT external interrupt
    0 = Disables the RB0/INT external interrupt
    bit 3 RBIE: PORTB Change Interrupt Enable bit(1)
    1 = Enables the PORTB change interrupt
    0 = Disables the PORTB change interrupt
    bit 2 T0IF: Timer0 Overflow Interrupt Flag bit(2)
    1 = TMR0 register has overflowed (must be cleared in software)
    0 = TMR0 register did not overflow
    bit 1 INTF: RB0/INT External Interrupt Flag bit
    1 = The RB0/INT external interrupt occurred (must be cleared in software)
    0 = The RB0/INT external interrupt did not occur
    bit 0 RBIF: PORTB Change Interrupt Flag bit
    1 = When at least one of the PORTB general purpose I/O pins changed state (must be cleared in software)
    0 = None of the PORTB general purpose I/O pins have changed state
    Note 1: The appropriate bits in the IOCB register must also be set.
    Last edited by Robson; - 31st August 2007 at 01:07.

  9. #9
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Oh i get it ;-)
    Only to set
    IOCB.7 = 1
    IOCB.6 = 1

    and it works !

    Thanks a lot

    with
    INTCON.7 = 0 in the main loop the interrupt is repeating 2 times. Pushed 1x and release 1x.
    With the IOCB only on change till the interrupt is executed.
    Last edited by Robson; - 31st August 2007 at 01:36.

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh, Very good!

    I didn't even notice the 913 had individual enable bits for the RBC interrupts.
    Sitting here with the datasheet too going, "It should work!" Doh!, wrong.

    Nice job.
    <br>
    DT

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    BTW: Nice work on the new interrupt routines Darrel. Most impressive.
    Thanks Bruce,

    Let me know when you get the CAN module working. <hr>

    Oh, and Robson,

    I was just chit-chating with Bruce before.

    INTCON.7 = 0 should not be in your program.

    Sorry for the confusion.
    <br>
    DT

Members who have read this thread : 1

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