Multi Interrupt How To ?


Closed Thread
Results 1 to 6 of 6
  1. #1
    capitano's Avatar
    capitano Guest

    Post Multi Interrupt How To ?

    I write this program for multi interrupt routine but it don't work fine..
    help me please....
    thank you in advance





    DEFINE LOADER_USED 1




    DEFINE OSC 20




    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50


    OPTION_REG=%00000111 ' Pull-up PORTB: Enabled


    T1CON=%00100000
    CCP1CON=%00000101

    T2CON=%00000101 ' Timer 2 is ON - Timer 2 Prescaler 1
    CCP2CON=%00001100 ' PWM mode


    ADCON0=%00000001 ' A/D converter module is operating
    ADCON1=%00000100 ' Confing D D D D A D A A


    TRISA = %11101011
    TRISB = %11111100
    TRISC = %10011100
    TRISD = %00000000
    TRISE = %00000011




    RCSTA = $90 ' Enable USART receive
    TXSTA = %00100100 ' Set USART parameters High Speed
    SPBRG = 20 ' Set baud rate to 57600



    TMR1L=0 ' Reset Timer
    TMR1H=0 ' Remember Timer is OFF
    pir1.2=0 ' Reset Capture Flag
    pir1.0=0

    CCP1CON = %00000101



    clear










    ' Interrupt


    INTCON = %11100000
    PIE1=%00101011


    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 Velocità


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

    ' Interrupt routine

    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




    the problem is that the interrupt routine are very slow ....
    and i have problem tu use te CCP module, the measure are wrong....


    there is another via to manage interrupt ???

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    we will be more than grateful if you can tell us wich PIC you're using
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Capitano,

    C>>' Interrupt Header


    Disable

    interr:
    <<


    Just a quick glance through your code.. and I notice one thing....

    Your disable is BEFORE your interupt label. It should be just after the interupt label..

    interr:
    Disable
    ...
    ....
    ...
    Enable
    return
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  4. #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.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Originally posted by Dwayne

    Just a quick glance through your code.. and I notice one thing....

    Your disable is BEFORE your interupt label. It should be just after the interupt label..
    NOP, you must disable before the label an ENABLE after RESUME. it's in the PBP manual

    capitano

    looks wierd... at this point i've never use CCP module and manage many interrupt together... interesting thread. I'll try something and let you know. BTW, i'm sure there's also somebody here who'll see the problem quick.

    The PIC is 16F8777 at 20 Mhz
    can we assume it's a 16F877 or a really brand new demo unknow at this point ;-)
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Mister_e,

    Hello Steve...Thanks for correcting me. I appreciate it.

    I was looking through my philips books and it is just opposite of PBP for the PHilips chips <g>. Oh well...I will always learn something new every day.... and as I get older, I will learn more things in one day...because I forgot them yesterday...<g>

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

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 : 1

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