DT interrupt problem


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45

    Default DT interrupt problem

    Hello everyone, I'm having trouble making my program work. I'm using DT interrupts to measure the duration of a servo pulse using CCP interrupts.
    The interrupt routine works as expected but it doesn't return to the Main program, I'm missing something. Any input is appreciated.
    Code:

    Code:
    #config
     __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF   
    #endconfig
    define OSC 8
    Include "modedefs.bas"
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    CCP1_INT,  _pulsedata,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    
    GPIO     = 000000
    TRISIO   = 000101           
    ANSEL    = 000000
    CMCON0   = 000111       
    OSCCON   = 110000  '8MHZ
    PIE1     = 100000
    INTCON   = 010000
    T1CON    = 000001  'no prescaler
    CCP1CON  = 000101  'rising edge CCP
    led      var GPIO.5
    wsave    VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    pulse    var word     'received pulse width
    
    clear
    
    Main:
         pause 100
         toggle led
    GOTO Main
    
    '---[INT - interrupt handler]---------------------------------------------------
    pulsedata:
         if CCP1CON.0 = 0 then
             pulse.lowbyte = TMR1L
             pulse.highbyte = TMR1H
            ' serout 4,N9600,[#pulse,13]    'for testing
             CCP1CON.0 = 1         'rising edge CCP         
         else
             TMR1L = 0
             TMR1H = 0
             CCP1CON.0 = 0         'falling edge
         endif         
    @ INT_RETURN
    
    
    end
    Last edited by eggman; - 14th June 2012 at 12:40. Reason: typo

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DT interrupt problem

    I'm no expert, but you've created a
    CCP1_INT interrupt, then done this...



    Code:
    @   INT_ENABLE  INT_INT       ; enable external (INT) interrupts

    to my way of thinking (possibly wrong!) it should be this...



    Code:
    @   INT_ENABLE  CCP1_INT       ; enable CCP1 interrupt

    (that's assuming you want to interrupt on CCP1 & not the INT pin?)

  3. #3
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: DT interrupt problem

    Thanks for the suggestion, but my interrupt routine works okay. I tried it but it makes no difference. Somehow it will not run the main program, it will handle all the interrupts though.

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: DT interrupt problem

    What if you change the pause from 100 to 15?
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default Re: DT interrupt problem

    Although the forum has messed up your binary numbers (as usual), you can still see problems.

    You have enabled INTE in the INTCON register, but there is no handler for INT_INT.

    You have enabled RCIE in the PIE1 register, but there is no handler for RX_INT.

    It never returns to you program, because the interrupts are never handled.
    DT

  6. #6
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: DT interrupt problem

    Thank you Darrel for pointing me in the right direction, it works fine now!

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