I am using a 16F716 with all portb pins tied to ground through 20k resistors. I have also tied portb(4..7) to Vcc through switches and 1k resistors. I use portb(4..7) to address a mux and portb(0..3) to drive relays through a buffer. I want to be able to read the switches on-the-fly without affecting portb(0..3). However, I always get all 1's for the switch setting if I try to reconfigure portb on-the-fly. If I only read the switches at the beginning of the program, I get the correct values. Here is what I have tried so far (sorry for the parallax): First I configure portb for outputs so I can run some code: setb rp0 mov trisb,#00000000b clrb rp0 Some code goes here... Then I call this code to read the switches on portb(4..7): setb rp0 mov trisb,#11110000b clrb rp0 mov Temp_lvl,portb swap Temp_lvl and Temp_lvl,#00001111b setb rp0 mov trisb,#00000000b clrb rp0 After this I jump back into my main loop. I have found that even if I do not write anything to portb after initially configuring it for all outputs, or even if I write all 0's to portb before calling my switch reading subroutine, I get all 1's for my switch setting. The only way the code for reading the switches works is if I only run it once at the very beginning of the code. I am wondering how to do this and whether it is possible without affecting the outputs driving the relays on portb(0..3). Thanks. Bruce -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist