Handeling multiple Interrupts


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    24


    Did you find this post helpful? Yes | No

    Question I dont get it

    Hmmm.....
    Sort of. But if what you say is correct then the TMr0 interrupt would be seen and not the tmr1.
    I am seeing the Tmr1 and not the Tmr0.

    Am I missing something in what your saying?

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobSpencerr View Post
    Hmmm.....
    Sort of. But if what you say is correct then the TMr0 interrupt would be seen and not the tmr1.
    I am seeing the Tmr1 and not the Tmr0.

    Am I missing something in what your saying?
    Hold on....thinking....

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Your original code with a few changes.

    DEFINE INTHAND ROLLOVER

    wsave var BYTE $020 SYSTEM : wsave1 var BYTE $0a0 SYSTEM : wsave2 var BYTE $120 SYSTEM : wsave3 var BYTE $1a0 SYSTEM : ssave var BYTE BANK0 SYSTEM : psave var BYTE BANK0 SYSTEM
    i_hour var BYTE : i_minu var BYTE : i_sec var BYTE : i_tic var BYTE : i_sec0 var BYTE : i_tic0 var BYTE : 'PowerLed var Portd.2

    GOTO AFTERINT 'Jump past interrupthandler

    asm
    rollover
    movwf wsave
    swapf STATUS, W
    clrf STATUS
    movwf ssave
    movf PCLATH, W
    movwf psave

    ; interrupt code follows here
    recheckints
    btfsc PIR1,0
    goto timer1Interrupt
    btfsc INTCON,2
    goto timer0Interrupt
    goto restoreall

    timer1Interrupt
    ;Timer 1
    movlw 0x58
    movwf TMR1L
    movlw 0x9e ;restart timer from ffff - 9e58 => 5Hz if using 4MHz
    movwf TMR1H
    decfsz _i_tic,f
    goto slutint1
    incf _i_sec,f
    movlw 5 ;5 = 1Hz if using 4MHz (change to 10 for 8MHz and so on)
    movwf _i_tic
    movf _i_sec,w
    slutint1
    bcf PIR1,0 ;zero tmr1 interrupt flag
    endasm
    if i_sec = 60 then
    i_sec = 0
    endif
    toggle portd.2
    goto recheckints
    asm

    timer0Interrupt
    ; Timer 0
    movlw 00010000
    movwf option_reg
    decfsz _i_tic0,f
    goto slutint2
    incf _i_sec0,f
    movlw 1 ;5 = 1Hz if using 4MHz (change to 10 for 8MHz and so on)
    movwf _i_tic0
    movf _i_sec0,w
    slutint2
    bcf intcon,2
    bcf PIE1,0 ;zero tmr0 interrupt flag
    endasm
    if i_sec0 = 60 then
    i_sec0 = 0
    endif
    toggle portd.3
    goto recheckints
    asm

    ;end of interruptcode
    ; restorecode follows here
    restoreall
    movf psave,w ;restore
    movwf PCLATH
    swapf ssave,w
    movwf STATUS
    swapf wsave,f
    swapf wsave,w
    retfie
    endasm

    AFTERINT:

    INTCON = %00000000 'all interrupts off
    PIR1 = %00000000 'zero tmr1 interrupt flag
    PIE1 = %00000001 'enable timer1 interrupt
    TMR1L = $58 : TMR1H = $9e : i_sec = 0 : i_sec0 = 0
    i_tic = 5 'this value should be the same as the value of line 8 in the ISR
    i_tic0 = 5
    T1CON = %00110001 'timer1 on, prescaler=1/8
    INTCON = %11010000 'interrupt on

    MAINLOOP:
    pauseus 1 : goto mainloop

    END '<- VERY Important to have this part!

    Try that. Added new labels to recheck the interrupt flags and a loop for the program to run while it waits for stuff to handle.

  4. #4
    Join Date
    Mar 2006
    Posts
    24


    Did you find this post helpful? Yes | No

    Smile Thanks

    I realy do appreciate your help here.
    As you no doubt know, it can get realy frustrating when things Should work but dont.

    Ill try this code tonight

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BobSpencerr View Post
    I realy do appreciate your help here.
    As you no doubt know, it can get realy frustrating when things Should work but dont.

    Ill try this code tonight


    Ok, it's this thread.
    Hurry up! Get on it! Some readers (me in particular) are dying to know!

  6. #6
    Join Date
    Mar 2006
    Posts
    24


    Did you find this post helpful? Yes | No

    Smile I will

    I work in a University.
    The programmer is at home.
    I am itching to try it too but we will have to be patient now wont we.

  7. #7
    Join Date
    Mar 2006
    Posts
    24


    Did you find this post helpful? Yes | No

    Red face No good.

    No good dude.
    Didnt work either.

    I am going to rewrite it all starting with tmr0 interrupt when I can find info on its use.
    Then I will impliment the tmr1.

    Thanks anyway for the time.

Similar Threads

  1. Problem with multiple interrupts
    By aratti in forum General
    Replies: 7
    Last Post: - 2nd June 2009, 09:18
  2. General Question About Multiple Interrupts
    By grzeh666 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2008, 18:09
  3. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 16:10
  4. Turning on & off multiple interrupts
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 30th June 2005, 18:50
  5. Multiple HW Interrupts
    By Radiance in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th August 2003, 23:35

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