16f88 interrupt


Closed Thread
Results 1 to 12 of 12

Thread: 16f88 interrupt

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tur_bot View Post
    can any one help me please. it s very urgent , it s for my project at uni and i have just a week to finish it.
    thank you
    Sounds to me like you should've started the 'project' for 'UNI' earlier...or maybe get a bit of help from the 'INSTRUCTOR' (if that's what they call them these days...I call them placeholders) or maybe even try some of your CLASSMATES.

    Use another pin to trigger your 'PORTB.4' pin, write code to trigger that pin to trigger the other pin.

    And no, I don't think this will solve your problem. If GOSUB'ing into your interrupt routine is slow, why would triggering an interrupt to go to the interrupt routine work any better? Your program is most likely hanging up in a loop somewhere or something similar making you think that it's not reacting fast enough, whereas triggering an interrupt in hardware may actually jump directly to that code.

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


    Did you find this post helpful? Yes | No

    Default

    Look for interrupt on change. But you may need to change your current hardware.
    Steve

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

  3. #3
    Join Date
    Mar 2008
    Location
    london
    Posts
    15


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by skimask View Post
    Sounds to me like you should've started the 'project' for 'UNI' earlier...or maybe get a bit of help from the 'INSTRUCTOR' (if that's what they call them these days...I call them placeholders) or maybe even try some of your CLASSMATES.

    Use another pin to trigger your 'PORTB.4' pin, write code to trigger that pin to trigger the other pin.

    And no, I don't think this will solve your problem. If GOSUB'ing into your interrupt routine is slow, why would triggering an interrupt to go to the interrupt routine work any better? Your program is most likely hanging up in a loop somewhere or something similar making you think that it's not reacting fast enough, whereas triggering an interrupt in hardware may actually jump directly to that code.
    my program is working fine but i just need to learn more about interrupt so i can make it better. by the way i started my project very early but not early enough (last summer).

    about the small piece of code that i m using to learn about interrupt,I managed to improve my code and it s working but not as expected. the interrupt is activated on the falling edge but I want it to be activated on the rising edge.

    i used a pull down resistor on the portb.0 and the main loop is running and when i connect a 5 volts to activate the interrupt nothing happens (everything stops ) but just when the 5 volts is taken off the interrupt runs for 2 second and the program is back to the main loop.

    there is the code:
    ------------------------------------------------------------
    @ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF

    DEFINE OSC 4
    OSCCON=%01101000
    ANSEL=%00000000
    CMCON=%00000111

    OPTION_REG.6=1 'Trigger on rising edge


    disable

    clear

    trisa = %11111111
    trisb = %00000000
    'Pause 500 ' Wait for startup
    LOW PORTB.6
    low portb.5

    start:
    goto loop

    On Interrupt Goto UpdateCounter

    INTCON = %10010000 'Enable INTE
    disable


    UpdateCounter:

    high portb.6
    Pause 2000 ' Wait 2 second

    low portb.6
    Pause 2000 ' Wait 2 second

    low PORTB.5


    INTCON.1=0 're-enable interrupts

    resume
    ENABLE
    GOTO loop

    loop:
    high portb.5
    Pause 2000 ' Wait 2 second

    low portb.5
    Pause 2000 ' Wait 2 second

    low PORTB.6

    Goto loop ' Do it forever

    Disable


    END
    ------------------------------

    can you tell me what i did wrong , why the interrupt is not activated on the rising edge and how can I resolve it ??

    thank you again for your advices ...
    Last edited by tur_bot; - 1st April 2008 at 17:46.

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


    Did you find this post helpful? Yes | No

    Default

    there's a kinda mess in that

    But if you want to trigger an INT0 interrupt, PORTB.0 must be set as an input.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    try this one
    Code:
            @ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF
            
            DEFINE OSC 4
            OSCCON=%01101000
            ANSEL=%00000000
            CMCON=%00000111
            
            OPTION_REG.6=1 'Trigger on rising edge
            
            trisa = %11111111
            trisb = %00000001
            CounterA    var word
    
            On Interrupt Goto UpdateCounter
            INTCON = %10010000 'Enable INTE
            
            PORTB=0
            Pause 50 ' Wait for startup
    
    loop:
            TOGGLE PORTB.5
            gosub dodelay
            Goto loop 
            
    DoDelay:
            for countera=0 to 200
                pause 1
                next
            return        
    
    
    disable
    UpdateCounter:
            low PORTB.5
            high portb.6
            Pause 2000 ' Wait 2 second
            low portb.6
            INTCON.1=0 're-enable interrupts
    resume
    ENABLE
    Steve

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

  6. #6
    Join Date
    Mar 2008
    Location
    london
    Posts
    15


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by mister_e View Post
    try this one
    Code:
            @ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF
            
            DEFINE OSC 4
            OSCCON=%01101000
            ANSEL=%00000000
            CMCON=%00000111
            
            OPTION_REG.6=1 'Trigger on rising edge
            
            trisa = %11111111
            trisb = %00000001
            CounterA    var word
    
            On Interrupt Goto UpdateCounter
            INTCON = %10010000 'Enable INTE
            
            PORTB=0
            Pause 50 ' Wait for startup
    
    loop:
            TOGGLE PORTB.5
            gosub dodelay
            Goto loop 
            
    DoDelay:
            for countera=0 to 200
                pause 1
                next
            return        
    
    
    disable
    UpdateCounter:
            low PORTB.5
            high portb.6
            Pause 2000 ' Wait 2 second
            low portb.6
            INTCON.1=0 're-enable interrupts
    resume
    ENABLE
    thank you very much , it was the trisb=0000001 command that resolved the problem. it works as expected but one more thing is not right, the portb.6 output 1.62 volts when the program goes through interrupt instead of giving a 5 volts output (a good logic one) as expected.
    is it supposed to be like this?????

    thank you again.
    Last edited by tur_bot; - 2nd April 2008 at 11:00. Reason: last little problem

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


    Did you find this post helpful? Yes | No

    Default

    Nope, seems you have a dead I/O, or faulty connections... or a dead output caused by a faulty connection
    Steve

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

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. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  3. 16F88 Interrupt
    By sskeet in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th January 2006, 15:51
  4. How to use an Interrupt to drive a menu on 16f88
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th March 2005, 01: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