Interrupt question


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52

    Default Interrupt question

    Hi !

    I have a small question. If i use the following code:
    Code:
    ;==== Dec's for OSC 
    DEFINE OSC 8                                            'Int OSC @ 8 MHz, for PBP
    OSCCON      = %01110001                                 'Int OSC @ 8 MHz
    
    '==== Interrupt handler 
    on interrupt goto intHANDLER
    
    '==== Set defines 
    OPTION_REG  = %10000000                                 'Set Weak pull-ups
    WPU         = %00000000                                 'Weak pull-ups disabled
    INTCON      = %11000000                                 'Enable unmasked perhipal interrupts
    PIE1        = %00000001                                 'Set TMR1 overflow interrupt
    PIR1        = %00000000                                 '
    PCON        = %00000000
    IOC         = %00000000                                 'Interrupt On Change disabled
    PCON        = %00000000                                 'Ultra lowpower + BOR disabled
    ANSEL       = %00000000                                 'GPIO 0 Analog
    TRISIO      = %00101000                                 'GPIO 0,3 inputs
    GPIO        = %00000001                                 'All I/O low
    CMCON0      = %00000111                                 'Comparator off
    CMCON1      = %00000000                                 'Output is synced with TMR1
    VRCON       = %00000000                                 'Voltage ref. disabled
    ADCON0      = %00000000                                 'ADC off
    T2CON       = %00000100                                 'TMR2 = ON, prescaler = 1:1                                  
    T1CON       = %10000111                                 'Timer1 counts 100Hz
    CCP1CON     = %00000000                                 'CCP engine is off
    
    
    '==== Dec's for variables
    countLOOP   var word
    synclong		var word
    
    '==== Initialise variables
    countLOOP   = 0
         
    '==== Set timer1 3000 from overflow
    synclong = 65535-3000
    TMR1H = synclong.highbyte
    TMR1L = synclong.lowbyte
    
    '==== Main program
    start:	
    GPIO.0  =1															'pulse 1 on
    pauseus 800																									'Pause 800 us
    GPIO.0 = 0																									'pulse 1 off
    pauseus 800																									'pause 800 us
    goto start
    
    '==== The End =======================================================================
    theend:                                                			'Endless loop
    goto theend
    
    '==== Interrupt handler 
    DISABLE
    intHANDLER:                                                 'Disable interrupts
        intdelay = 1                                       		  'Set interrupt has occured bit
        PIR1.0 = 0																							'Clear interrupt
        TMR1H = synclong.highbyte																'Set Tmr1 3000 from overflow again
        TMR1L = synclong.lowbyte
        resume
    enable
    Tmr1 is setup as a counter. If it overflows within one of the the 800us delays, will the interrupt be fired directly, or will it first finish the 800us and then fire ?

    Should i be using the DT instant interrupts ? I've noticed that the DT interrupts can't resume to a specific label, am i right ?

    Thanks
    UB

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    The interrupt flag will be set as soon as TMR1 overflows but PBP won't "see" it until the PauseUs statement is completed. Hence, the ISR won't be executed until after the pause.

    Using DTInts won't give you that problem.

  3. #3
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    OK ! I will give the Dtint a try ...

    Thanks for the fast reply !

    Best regards,
    UB

  4. #4
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Just wondering. With the pbp ON INTERRUPT STATEMENT i could do a RESUME to a specific label.

    This is not possible with the DT int, right ?

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    DT interrupts can't return to a specific label - but you can set a flag inside the ISR and test for that in your main program loop. If set, you can jump to wherever you want.

    Although it isn't quite "instant", that method can usually accomplish what you need.
    Charles Linquist

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  2. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  3. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  4. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07
  5. Interrupt question
    By stone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th January 2005, 23:11

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