DT interrupt problem


Results 1 to 6 of 6

Threaded View

  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

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