PORTB(4-7) _Button Click Interrupt problem

Thread Starter

pancikok

Joined Oct 31, 2009
26
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:

Rich (BB code):
list p=16f84
include p16f84.inc

__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC


org 0x00
goto Main

org 0x04 
goto ISR

Main
BSF STATUS,RP0 
MOVLW B'00100000'  ;RB5 set to input
MOVWF TRISB

MOVLW B'10000000'     
MOVWF OPTION_REG  ;RBPU, set OFF


BCF STATUS,RP0
CLRF PORTB

BSF PORTB,1  ; Turn on PORTB(1)

BSF INTCON,RBIE  ; enable rb(4-7) interrupt
BSF INTCON,GIE   ;enable global interrupt

MainLoop
nop
goto MainLoop


ISR

BTFSS PORTB,1
goto TurnOn
BCF PORTB,1

        BCF    INTCON,0       ;clear interrupt flag before return
        RETFIE                     ;return from interrupt

TurnOn
 BSF PORTB,1

        BCF    INTCON,0       ;clear interrupt flag before return
        RETFIE                     ;return from interrupt

END
Thank you
 

Markd77

Joined Sep 7, 2009
2,796
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.
 

Markd77

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

Thread Starter

pancikok

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

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

Markd77

Joined Sep 7, 2009
2,796
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.
 

Thread Starter

pancikok

Joined Oct 31, 2009
26
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 ?!?!
 

Thread Starter

pancikok

Joined Oct 31, 2009
26
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
 
Top