Combine Interrupts


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default Combine Interrupts

    Hi,

    I need a little help,did some one know if I can Combine this two interrupt like here:

    INCLUDE "modedefs.bas"

    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 25 ' 9600 Bauds
    DEFINE HSER_CLROERR 1
    INTCON = %11100000 ' Enable interrupts Usart and TMR0
    OPTION_REG =%00000110 'Prescaler = 128



    On INTERRUPT GoTo Main '''''Usart
    PIE1.5 = 1
    On INTERRUPT GoTo Overflow ''''''Timer0 Overflow
    PIE1.0 = 1


    Loop:

    ........
    ........
    ........

    Goto Loop

    Disable

    Main:
    .......
    .......
    Resume

    Overlow:
    .......
    .......

    INTCON.2=0 '''''''''''''''''''''''Clear Overflow

    Resume

    Thanks a lot for any answer.

    Regard Pesti
    Last edited by Pesticida; - 1st April 2007 at 20:24.

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


    Did you find this post helpful? Yes | No

    Default

    You can only have 1 ON INTERRUPT handler on a 16F.

    In that handler, you can monitor the different Flags associated with the different interrupts and then execute the appropriate routine.

    In your case, you want TMR0 and the USART, so you need to watch for TMR0IF and RCIF.

    Most people only check for the flag, but I also like to make sure the Interrupt source is Enabled too, by checking TMR0IE and RCIE. That way it will stil work according to plan when you disable/enable interrupts at random.

    For your suedo code, it might look like this...
    Code:
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD  9600
    DEFINE HSER_CLROERR 1
    
    PEIE   VAR INTCON.6
    RCIE   VAR PIE1.5
    RCIF   VAR PIR1.5
    T0IE   VAR INTCON.5
    T0IF   VAR INTCON.2
    
    OPTION_REG = %00000110  ' Prescaler = 128, RB pull-ups on
    PEIE = 1           ' enable Peripheral interrupts
    T0IE = 1           ' enable TMR0 interrupts
    RCIE = 1           ' enable USART RX interrupts
    
    On INTERRUPT GoTo IntHandler 
    
    Loop:
        ........
        ........
        ........
    Goto Loop
    
    Disable
    ;___________________________________
    IntHandler:
        IF RCIE and RCIF then USART_RX
        IF T0IE and T0IF then TMR0_OVR
        HIGH PORTB.0  ; indicate "Unchecked Interrupt"
    Resume
    
    ;___________________________________
    TMR0_OVR:
        .......
        .......
    
        T0IF = 0  'Clear Timer0 flag
    Resume
    
    ;___________________________________
    USART_RX:
        .......
        .......
    
        Dummy = RCREG ' Clear USART Flag by reading USART data
    Resume
    HTH,
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thank you !

    Now I understand how the Interrupts are working!

    Tahnks a lot.

    Regard.

    Pesti.

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 21:42
  3. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  4. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  5. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10

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