>I am using the BSF instruction to set bits >on PORTD on a 16c74A. The whole port is >configured as output (CLRF TRISD). The >problem is, when I set a bit on the port, any >other bits that were set, clear and then the >bit the instruction specifies, sets. >Why don't the other bits remain set? Gavin, Sounds like youre being caught by the read-modify-write problem. When you use a bit level instruction on a port, the PIC reads the port, changes the bit and writes the previously read levels back to the output latches. But when it reads the pins, it reads in the actual voltage level at the pin (even if not configured as an input.) So suppose you set an output pin high, and then drain enough current from it to pull the voltage at the pin below the logic-low threshold. (Example: driving an LED without a series resistor) Then when you BSF or BCF another pin of the same port, that first pin is read in, and re-written as LOW. Result: your specified bit sets correctly, but other bits mysteriously clear themselves. One solution is to use a software buffer for the port. Keep a file register that mirrors your desired output for the port. Then change the value of a bit in the file register, and write the whole file register to the port each time you change a bit. regards Alec __________________________________________________________________________ ________ _______ ______ __/ ____/ W5 Ltd. \ \ / \ / / /_ \ \ / \ / /___ \ 33 Sneath Avenue \ \ / \ / \ \ London NW11 9AJ \ \ / \ / / / United Kingdom \ \/ /\ \/ ____/ / \ / \ /______/ Telephone +44 181 922 7778 \ / \ / Fax +44 976 650 110 \ / \ / eMail mail@W5.co.uk \______/ \______/ Technology * Innovation * Design * Solutions __________________________________________________________________________