Hi all! Why my codes doesn't work?. I start the PIC16F84 pins of PORTB PB7,PB6,PB5 as outputs and when occur a Interrupt in the pin PB0/INT I have to invert this, putting PB7,PB6,PB5, as inputs. I try to save the present value in PORTB, but it doesn't work right. The value that I get is crazy, it is very different from the value that is really present. See my codes below. I don't know if I explained direct, but if somebody understood, please help me. Thanks in advance Anbar. MAIN: ORG 0 GOTO INIT_PORT ORG 4 BTFSC INTCON,T0IF ;INT TMR0 GOTO INT_TMR0 ;YES BTFSC INTCON,INTF ;INT RB0/INT GOTO INT_RB0 ;YES RETFIE INT_TMR0: RETFIE INT_RB0: MOVWF W_TEMP ;PUSH W AND STATUS SWAPF STATUS,W MOVWF STATUS_TEMP BCF INTCON,INTF ;CLR FLAG BSF STATUS,RP0 ;BANK1 BSF TRISB,7 ;PB7,PB6,PB5 NOW ARE INPUTS BSF TRISB,6 BSF TRISB,5 BCF STATUS,RP0 ;BANK0 MOVF PORTB,W ;VALOR OF PB IN W MOVWF TEMP ;STORE IN TEMP COMF TEMP,1 MOVLW B'11100000 ' ;JUST THE BITS 7,6,5 ANDWF TEMP,1 ;IS VALID SWAPF TEMP,1 ;SWAP THE NIBLLES BSF STATUS,RP0 ;BANK 1 BCF TRISB,7 ;AGAIN, BCF TRISB,6 ;PB7,PB6,PB5 NOW IS OUTPUTS BCF TRISB,5 BCF STATUS,RP0 ;BANK 0 SWAPF STATUS_TEMP,W MOVWF STATUS ;POP W AND STATUS SWAPF W_TEMP,F SWAPF W_TEMP,W RETFIE INIT_PORT: CLRF PORTA CLRF PORTB BSF STATUS,RP0 ;BANK 1 MOVLW B '00000111' ; PRESCALER TMR01/256 MOVWF OPTION_REG ; MOVLW B '00000000' ;PUT PORTA OUTPUTS MOVWF TRISA MOVLW B '00000001' ;PORTB JUST PB0 INPUT MOVWF TRISB BCF STATUS,RP0 ;BANK 0 BSF INTCON,GIE ;GLOBAL SET INTERRUPTS BSF INTCON,INTE ;RB0/INT - ON BCF INTCON,T0IE ;TMR0 - OFF BCF INTCON,RBIE ;CHANGE RB7/RB4 - OFF BCF INTCON,T0IF ;CLR FLAG TMR0 BCF INTCON,INTF ;CLR FLAG RB0/INT GOTO $