ASM Interrupt


Results 1 to 10 of 10

Thread: ASM Interrupt

Threaded View

  1. #4
    mikep's Avatar
    mikep Guest


    Did you find this post helpful? Yes | No

    Default

    Nothing like a bit of trial and error to figure things out.

    So I've been playing on the dev board and here is what I figured out so far.

    After the ASM interrupt routine is handled the rest of the line that was executing while the interrupt is received will execute. So in my case if I have a 5 second sound, and the PIC receives the interrupt after 1 second, when it comes out of the interrupt the other 4 seconds will play. There is a significant amount of delay mind you during the interrupt even though all I am doing in my test is lighting up an LED.

    So no matter what, so far the way I see it, once I start a sound I have no way of terminating it.

    And I will still have to check to see if I had an interrupt during the sound afterwards.

    So basically my main problem now is back to, is there anyway I can have my ASM interrupt routine jump to a different part of my PBP code when it is done executing instead of continuing where it left off.

    The other thing that troubles me is that even though I turn on the LED in the interrupt, it will go back off once it returns to executing the PBP code where it left off.

    So how then would I set a flag to know that the interrupt happend if everything is restored back to it's state before the interrupt. Or is that only the hardware state of things that are reset. I guessed if I move a value in to a var in the ASM code that woulkd remain the same. Right? I will try that next.

    Just for archival sake and if anyone else ever needs this, here is the code I am using to test. It basically comes out of the PBP manual. I don't think it handles the possibility of being in several RAM banks so that could cause some problems on longer code etc.

    Off to read more on ASM instructions..... I wish I took a speed reading course!



    DEFINE __16F876 1


    ' Define Oscillator Speed
    DEFINE OSC 10

    ADCON1 = 7

    ' Shutdown comparators
    CCP1CON = 0
    CCP2CON = 0

    ' Set the port directions
    ' 0=output 1=input
    TRISA=%00000000 ' Set PORTA
    TRISB=%00000000 ' Set PortB
    TRISC=%00000000 ' Set PortC

    led var PORTB.2

    wsave var byte $20 system
    ssave var byte bank0 system
    psave var byte bank0 system

    GOTO Start

    ' Define interrupt handler
    define INTHAND myint

    ' Assembly language interrupt handler
    asm

    ; Save W, STATUS and PCLATH registers
    myint movwf wsave
    swapf STATUS, W
    clrf STATUS
    movwf ssave
    movf PCLATH, W
    movwf psave

    ; Insert interrupt code here
    ; Save and restore FSR if used

    bsf _led ; Turn on LED

    ; Restore PCLATH, STATUS and W registers
    movf psave, W
    movwf PCLATH
    swapf ssave, W
    movwf STATUS
    swapf wsave, F
    swapf wsave, W
    retfie
    endasm
    ' Added to see if it would use some PBP code as well
    ' But it will not.
    ' Would have to perhaps move retfie to after this code?
    SOUND PortB.1,[120,160]
    PAUSE 3000

    Start:
    LOW led ' Turn LED off

    ' Enable interrupt on PORTB.0
    INTCON = %10010000

    Main:
    SOUND PortB.1,[100,160]
    PAUSE 3000
    SOUND PortB.1,[110,160]
    PAUSE 3000
    GOTO Main
    Last edited by mikep; - 23rd October 2003 at 16:10.

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. 18F2480 asm interrupt
    By Richard Storie in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th March 2009, 19:40
  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. 16F877a ASM Interrupt Confused
    By modifyit in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th September 2005, 03:16
  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