1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

SETUP AN INTERRUPT IN 16f690

Discussion in 'Microcontrollers' started by c36041254, May 16, 2008.

  1. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland
    :eek:Sorry ! to bother my bread board is damaged the ckt works on the other one
     
  2. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,013
    Likes:
    317
    Location:
    Brisbane Australia
    You can't have a goto inter in your interrupt. It will never get out of the interrupt code.

    Your interrupt should check the relevent bits and execute the appropriate code.
    Something like this,
    Code (text):

    inter:
            movwf   temp
            swapf   STATUS,w
            clrf    STATUS
            movwf   temp_s
            btfss   INTCON,RBIF ;is it Port B change interrupt
            goto    NotPortB    ;no, go check other interrupts
            movfw   PORTB       ;read port B to clear change condition
            bcf INTCON,RBIF ;Yes so clear the interrupt flag

            ;put code here for RB4 change

    NotPortB    btfss   INTCON,INTF ;is it INT0 interrupt
            goto    NotIntF     ;no
            bcf INTCON,INTF ;Yes so clear the interrupt flag

            ;Put code here for RB0 rising edge
           
    NotIntF
            swapf   temp_s,w
            movwf   STATUS
            swapf   temp,w
            retfie
     
    You can add as many other checks as you have interrupts enabled. So, if you want a timer0 interrupt you would check INTCON,T0IF and branch as necessary.

    Mike.
     
  3. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland
    Thanks Mike! but, some times interrupt with goto did work.!!! though I'll never do that again:)
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland

    I used 220 ohm resistor as pull down and the codes work well but now it is melfunctioning, is it possible that the PIC is damaged because of very low (220 ohm) pull down resistance ? Can I verfy that ? Please answer me I'm worried:(:confused:
     
  6. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,013
    Likes:
    317
    Location:
    Brisbane Australia
    Even if you set the pin to output you wouldn't damage it (5/220=22mA). With it set to input it is impossible to damage it with a pullup/down unless you are using a supply that is too high (>5.5V).

    Mike.
     
  7. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland
    O.K. again it is working right but, by mistake I shorted Vss and Vdd once and then the busy LED on PIC kit 2 start blinking and I have to turn off the PC and then the PIC again start melfunctioning but, after reloading the codes it works fine, Can shrting Vss and Vdd damage PIC kit or PIC ?
     
  8. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,013
    Likes:
    317
    Location:
    Brisbane Australia
    You probably crashed the Pickit2. When this happens, you can rectify it by unplugging the Pickit2 from the USB (and any other source of power) wait a few seconds and then plug it back in. Next, in MPLAB, deselect PicKit2 by selecting none and then reselect it.

    Mike.
     
  9. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland
    Does that damaged the KIT permanently ?:(
     
  10. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,013
    Likes:
    317
    Location:
    Brisbane Australia
    I don't think so but it's not a good idea.

    Mike.
     
  11. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland
    Mine MPLAB shows (in programmer selection) pic kit 2 in gray (not available) thiugh transfering hex file still do work on kit, what should I do to make pic kit 2 available in programmer list ?
     
    Last edited: May 23, 2008
  12. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,013
    Likes:
    317
    Location:
    Brisbane Australia
    The Pickit2 doesn't support the 16F628, only the 16F628A. How did you get it working previously?

    Mike.
     
  13. c36041254

    c36041254 Member

    Joined:
    Apr 1, 2008
    Messages:
    154
    Likes:
    1
    Location:
    Newzealand, Auckland
    previously I was working on 16f690 demo board supplied with kit, so I thought it was working and now it stops but, if the kit does'nt support 16f628 then how can I be able to programme it ? That's what I have done successfuly :confused:
    Edit: Though I got what do you mean by not supported but still curious that why so ?
     
    Last edited: May 23, 2008

Share This Page