This is a second try to get the 16F685 working to respond on a signal change on RB7. I wrote this small piece of code on advise earlier after the first question about this. When i set a signal on RB7 niether RA0 or RA1 or both wil come on. Thit i missed something in the datasheet on this matter. As far i can see i have set all the registers correct. ; errorlevel -302, -305 ; Suppress Bank Warnings list p=16F685, r=hex INCLUDE "P16F685.INC" __CONFIG 0x3CE2 ; --- Definetions section ---------------------------------------------------- ; --- Macros definitions ; --- Constant values #define DCCIN PORTB, 7 ; DCC signal input ; --- Variables in RAM cblock 0x070 ; On bottom of all banks INT_W ; Interrupt context registers INT_STAT ; EEDATA0 ; EEPROM shadow variables endc ; --- Program section -------------------------------------------------------- org 0x000 PowerUp: clrf STATUS ; Bank0 is default clrf INTCON ; Disable all interrupts at first clrf PCLATH ; All tables on Bank0 ; Following the datasheet the above could ; onmitted but we use it to be sure goto Init ; --- Interrupt routine ------------------------------------------------------ org 0x004 Interrupt: movwf INT_W ; Save content register 1 swapf STATUS, W ; 2 movwf INT_STAT ; 3 clrf STATUS ; Interrupt uses BANK0 4 btfsc DCCIN ; DCC signal present 5 bsf PORTA, 0 bsf PORTA, 1 nop EndInt: swapf INT_STAT, W ; Restore content registers 49 34 movwf STATUS ; 50 35 swapf INT_W, f ; 51 36 swapf INT_W, w ; 52 37 retfie ; 53 54 38 39 ; --- Set used registers in correct setting ---------------------------------- Init: ; These registers are in BANK0 clrf PORTA clrf PORTB clrf PORTC BANKSEL TRISA ; These registers are in BANK1 clrf TRISA ; Set to all outputs movlw b'10110000' ; Set RB7, RB5 and RB4 to Input movwf TRISB clrf TRISC ; Set to all outputs movlw b'10001000' ; Set Optionregister to no PullUps, ; no prescaller and WDT 1:1 movwf OPTION_REG clrf WPUA ; Dont use WeakPullUp on PORTA ; We dont use IOC on PORTA so leave it as it is BANKSEL ANSEL ; These registers are in BANK2 clrf ANSEL ; Set to all digital I/O clrf ANSELH clrf WPUB ; Dont use WeakPullUps on PORTB movlw b'10000000' ; Set RB7 to InterruptOnChange PORTB movwf WPUB BANKSEL 0x00 ; Return to BANK0 movlw b'00110001' ; Set Timer1 on at 1:8 movwf T1CON movlw b'10001000' ; Enable all unmasked interrupts and ; enable PORTA/PORTB interrupt on change movwf INTCON nop bsf PORTC, 2 nop goto $ end Regards Harry -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist