Continuous Interrupts when using DT_INTS and an INCLUDE file


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    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.

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


    Did you find this post helpful? Yes | No

    Default

    Try this as a quick test.

    In your Alarm routine replace High PORTC.0 with PORTC.0 = INTCON3.1.

    In your Main routine replace LOW PORTC.0 with PORTC.0 = INTCON3.1.

    Your LED will show the state of the INT2 interrupt flag bit. What does
    the LED do?
    Regards,

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

  3. #3
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Smile Problem solved!

    Quote Originally Posted by HenrikOlsson View Post
    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.
    Henrik was on the right track. In mean time I received a separate notice from Darrel Taylor that cleared it all up. For the benefit of all of you who tried to help me and any future visitors to this thread, let me explain.
    I had failed to create a JumpLocation label after the include file's subroutine and a GOTO JumpLocation statement ahead of the subroutines. Therefore, as Darrel explains it:
    " DS1337_Setup.inc is being executed but it's being exeucted at the wrong time...On power up. The processor is resetting every 4.5 seconds, because that's how long the DS1337 routine takes with all the PAUSES in it.
    At the end, it returns, but it was never called by a gosub and just fell-into the code from the start. So that RETURN resets the processor on a Stack Underflow, and hence repeated interrupts.
    All include files MUST jump over their own code."

    Hope this may help someone in the future avoid my learning curve on creating/using INCLUDE files.

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