PORTB(4-7) _Button Click Interrupt problem

Discussion in 'Embedded Systems and Microcontrollers' started by pancikok, Dec 19, 2009.

  1. pancikok

    Thread Starter New Member

    Oct 31, 2009
    26
    0
    Hi Everybody!!

    i ve got a problem , cant get an button click , i mean, RB(4-7) pin change interrupt,! im working on PIC16f84, MPLAB IDE , !help me please, this is my code, very simple:

    Code ( (Unknown Language)):
    1.  
    2. list p=16f84
    3. include p16f84.inc
    4.  
    5. __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
    6.  
    7.  
    8. org 0x00
    9. goto Main
    10.  
    11. org 0x04
    12. goto ISR
    13.  
    14. Main
    15. BSF STATUS,RP0
    16. MOVLW B'00100000'  ;RB5 set to input
    17. MOVWF TRISB
    18.  
    19. MOVLW B'10000000'    
    20. MOVWF OPTION_REG  ;RBPU, set OFF
    21.  
    22.  
    23. BCF STATUS,RP0
    24. CLRF PORTB
    25.  
    26. BSF PORTB,1  ; Turn on PORTB(1)
    27.  
    28. BSF INTCON,RBIE  ; enable rb(4-7) interrupt
    29. BSF INTCON,GIE   ;enable global interrupt
    30.  
    31. MainLoop
    32. nop
    33. goto MainLoop
    34.  
    35.  
    36. ISR
    37.  
    38. BTFSS PORTB,1
    39. goto TurnOn
    40. BCF PORTB,1
    41.  
    42.         BCF    INTCON,0       ;clear interrupt flag before return
    43.         RETFIE                     ;return from interrupt
    44.  
    45. TurnOn
    46.  BSF PORTB,1
    47.  
    48.         BCF    INTCON,0       ;clear interrupt flag before return
    49.         RETFIE                     ;return from interrupt
    50.  
    51. END
    52.  
    53.  
    Thank you
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I've just run it in MPlab sim because I couldn't see any problems.
    Works fine in the sim, the problem must be with the hardware.
    Please post a schematic.
     
  3. pancikok

    Thread Starter New Member

    Oct 31, 2009
    26
    0
    i just run it in RealPicSimulator , no hardware, ))
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I have no experience with that, but I think MPlab sim is going to be accurate in this case.
     
  5. pancikok

    Thread Starter New Member

    Oct 31, 2009
    26
    0
    hmm, but i havent ever worked with MPlab simulator.,:((((

    but, anyway. thanks for attention !! now i know there isn't any problem
     
  6. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    It's pretty easy, just click mplab sim from the select tool option in the debugger menu of MPlab IDE.
    Its fairly easy to use and free. The stimulus option can be used for most kinds of digital inputs for the pins.
     
  7. pancikok

    Thread Starter New Member

    Oct 31, 2009
    26
    0
    i did that, and also specify the Simulink model name,and it says please wait, in output window, in MatLab interactions tab, what i gotto do next ?!?!
     
  8. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I think you are in the tools menu instead of the debugger menu.
     
  9. pancikok

    Thread Starter New Member

    Oct 31, 2009
    26
    0
    yeah. now i got it, right :))
    woow, we just ve gotto specify when to set high or low the input pin, i liked it :))
    thank you very much, now me either can see it works in real time
     
Loading...