Stan Ockers wrote: > You may not get what you expect with a read, but what do you expect? You should get what you read unless you have not taken into account the TRIS or periferal setting (if applicable) of the pin. > "but, what if the latch is high and the pin is pulled low?". > Can someone explain how this is possible with out exceeding the 25 ma > sink limit of the pins? Due to external load the pin may be pulled low enough for the input latch to see a low state. It doesn't have to be all the way to ground. > I understand that a BCF on one output pin could affect the state on > another output pin if the pin level does not match the latched level but > normally this doesn't happen does it? Imagine this. (PortB) Output Latch = 00001111 TRIS = 11110000 Input Latch = 11001111 Execute BCF portb,0 PortB is read. ALU = 11001111 BCF bit 0 ALU = 11001110 Write back to PortB PortB Out Latch = 11001110 You can see that bit 7 and 6 of the PortB ouput latch have changed state. This does not matter at all because these bits are set as inputs. It only matters when you decide to change the TRIS setting for bits 7 and 6 and make them outputs. If you now change the TRISB to 00110000 then the Output latch will have the value 11001110 which may cause problems with whatever is connected to pins 7 and 6. You can use a shadow register to keep track of the port value, or you can specifically set the port output latch to a known state before changing the TRIS value. > I also read somewhere "inputs always read as 0". Should not the pin > level of inputs read high or low depending on whether the pin is being pulled > high or low by an external source or sink? Some pins have periferal functions that can be assigned to them. In this case you may read 0's from a pin configured as an input. Best to check the device data sheet. > BTW can anyone point me to a list which shows which instructions are > read, modify write and which are not? Any instruction that reads data, modifies it, and writes it back. ie BCF, BSF, XORWF, ANDWF, etc. -- Best regards Tony PicNPoke - Multimedia 16F84 Beginners PIC Tools. http://www.picnpoke.com Email picnpoke@cdi.com.au