--- michael brown wrote: > > The OPTION reg shouldn't have any effect whatsoever on your port change > interrupts. Chances are much more likely that you have left the > watchdog running accidentally or have interrupts occurring while you are > switched to bank1, but the ISR doesn't know it and it blindly smacks up > the wrong registers. Or the ISR switches back to bank0, but doesn't > properly save/restore the context info causing the main level code > suffer psychotic episodes. Stuff like this won't always show up in > simulations. > > When you use port change ints, you have to read the port as well as > clearing the RBIF flag. Otherwise the interrupt will trigger again > because a mismatch condition still exists against the magical hidden > shadow reg that holds the original pin values. You have to read the > port before clearing the RBIF, or it will instantly change back to a 1 > causing the int to fire again as soon as you execute the RETFIE. This > reloads the magical hidden shadow reg. ;-) The simulator may not get > this right, it wouldn't be the first thing it didn't "simulate". > Thankz Michael! I tried swapping bsf/bcf INTCON,GIE for movwf INTCON & reading PORTB. No diff. The only thing I've found so far that does make a diff - ie causes the PIC (16F84) to stay asleep until interrrupted - is b7 (RBU') in the OPTION_REG. Hmm. OK, Pull up resistors - what //exactly// do they do or what are the pros/cons of having them enabled/disabled? And how could it possibly affect the interrupts? And I thought I had a handle on all this ... :( Here's the cut-down code if interested. The context-saving is handled by MACROS - they're basically the routines Mike Predko gave in his book. Debbie PAGE org 0x00 start goto main org 0x04 intrpt: goto alert goto main ;Catches any errors. We hope! main: setint: BANK_1 movlw b'00011111' ; Works if RBU' is cleared. ;b7 - RBPU' = 1 => Pull-ups disabled, 0 => enabled movwf OPTION_REG BANK_0 PAGE_0 movlw b'00011000' ;Disable interrupts for now. GIE=0 movwf INTCON loop: call power_off ;Michael Brown's trick ---> read the port 1st movlw b'11111000' andwf INTCON,f ;Clear the flag bits in INTCON movf PORTB,w ;Read PORTB and then bsf INTCON,GIE ;Enable the interrupt ;My orginal code ;movlw b'10011000' ;Now enable the interrupts ;movwf INTCON nop sleep ;Shut down and wait nop bcf INTCON,GIE ;Disable interrupts while doing housekeeping. goto loop ;The interrupt section ... include "handler.asm" alert: call intrpt_service bcf INTCON,GIE ;Disable interrupt temporarily goto loop goto main ;Catches errors .. we hope! end ____________________________________________________ Do you Yahoo!? Yahoo! Photos: Now with unlimited storage http://au.photos.yahoo.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist