Multi Interrupt How To ?


Results 1 to 6 of 6

Threaded View

  1. #4
    capitano's Avatar
    capitano Guest


    Did you find this post helpful? Yes | No

    Post Multi interrupt

    The PIC is 16F8777 at 20 Mhz

    I try to change :

    Disable
    interr:

    ...
    ....
    ...
    Enable
    return

    to

    interr:
    Disable
    ...
    ....
    ...
    Enable
    return

    but i have problem to ccp module to capture period of 1 ms the measure are instable but without interrupt the measure are correctly



    This program work fine


    ' Main Program Loop
    ' -----------------
    Loop:
    '
    ' Sample Section
    ' --------------
    TMR1L=0 ' Reset Timer
    TMR1H=0 ' Remember Timer is OFF
    capture=0 ' Reset Capture Flag
    CCP1CON = %00000100
    ' Enable the CCP1 capture, falling edge
    While Capture=0:Wend
    ' Junk 1st Result
    T1CON.0=1
    ' Enable Timer
    capture=0 ' Reset Capture Flag
    While Capture=0:Wend
    ' Wait for 2nd Result
    period.lowbyte = CCPR1L
    period.highbyte = CCPR1H
    ' Store the captured value in period variable
    T1CON.0=0 ' Timer is OFF
    CCP1CON=0 ' Capture is OFF

    Hserout[period.highbyte,period.lowbyte]

    pause 500


    Goto Loop







    This program don't work fine


    INTCON = %11100000
    PIE1=%00101111


    ON INTERRUPT GoTo interr



    mainloop:

    ' Main program

    GoTo mainloop





    ' Interrupt Header


    Disable

    interr:



    '********************************************
    'Interrupt PWM


    IF PIR1.1=1 Then ' TMR2 to PR2 interrupt flag
    PIR1.1=0

    ' Interrupt routine



    endif






    '************************************
    'Interrupt Period


    If pir1.2=1 then
    pir1.2=0

    If state=0 then

    T1CON.0=1 ' Enable Timer
    pir1.2=0 ' Reset Capture Flag
    state =1
    CCP1CON = %00000101


    else


    ' Store the captured value in period variable
    T1CON.0=0 ' Timer is OFF
    CCP1CON=0 ' Capture is OFF
    Period.lowbyte = CCPR1L
    Period.highbyte = CCPR1H
    TMR1L=0 ' Reset Timer
    TMR1H=0 ' Remember Timer is OFF
    pir1.2=0 ' Reset Capture Flag
    CCP1CON = %00000101
    state=0

    endif






    endif



    '************************************
    'Interrupt TMR0


    If INTCON.2=1 then


    ' Interrupt routine


    INTCON.2=0
    endif












    '************************************
    'Interrupt Network

    IF PIR1.5=1 Then

    ' Interrupt routine

    endif



    Resume
    Enable









    Last edited by capitano; - 3rd February 2005 at 08:51.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. 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
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  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