Interrupt Problem


Results 1 to 16 of 16

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Kamikaze47 is right.

    There is definately a problem using PAUSE in an ASM interrupt.

    Pause uses 2 internal PBP variables. (R0 and R1). So if, another PBP statement that uses either R0 or R1 gets interrupted, the interrupt routine will change those values and the main program will get confused.

    It's possible to have a pause in the interrupt, IF you save both of the system vars first, then restore them when the int is finished.

    In that case, toms example would look like this...
    Code:
    R0save VAR WORD
    R1save VAR WORD
    
    asm
    int_handler
        ; Save Resisters ;
        IF (CODE_SIZE <= 2)
            movwf   wsave               ; Save W Register into wsave
            swapf   STATUS,W            ; Save STATUS Register into ssave
            clrf    STATUS                  
            movwf   ssave              
            movf    PCLATH,W            ; Save PCLATH Register into psave
            movwf   psave
            movf    FSR,W               ; Save FSR Register into fsave
            movwf   fsave
        endif
    endasm
        R0save = R0
        R1save = R1
        high LED
        pause 100
        low LED
        R1 = R1save
        R0 = R0save
    asm
        ; Restore Resisters ;
        movf    fsave,W             ; Restore FSR Resister
        movwf   FSR                 
        movf    psave,W             ; Restore PCLATH Resister
        movwf   PCLATH
        swapf   ssave,W             ; Restore STATUS Resister
        movwf   STATUS
        swapf   wsave,F             ; Restore W Resister
        swapf   wsave,W
        bcf INTCON,1
        retfie
    endasm
    But then, like tom says ... "it is not advisable to use delays in interrupt"
    <br>
    Last edited by Darrel Taylor; - 16th November 2005 at 18:48.
    DT

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. Problem with Interrupt on PIC18F4620 PORTB
    By rookie in forum Off Topic
    Replies: 1
    Last Post: - 22nd March 2007, 01:34
  3. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  4. Interrupt stack overflow problem with Resume {label}
    By Yuantu Huang in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd May 2005, 01:17
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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