I don't remember if there were capacitors on the PWM lines for the LED's, but if so, they would have a much lower impedance at the higher clock frequency and might have been acting as enough of a load to cause the read to always return the same state, messing up the following write. That is the only reason I can think of if the PIC is running at a clock frequency it is supposed to run at, to behave differently at 20 MHZ than it does at 4 MHZ. If there was asymmetry in the wave form, then that would tend to always end up in one state or the other, either LED's full on or full off. The flash when disconnecting a LED and reconnecting it is another indicator (puns, who me?), that the output probably tried to function when the LED was disconnected, but then reverted to its failure mode as soon as the load was re-applied. It might even have been the capacitance in the lines from the PIC to the LED that became significant at the higher frequency and loaded down the output enough to confuse the RMW. It's good to keep stories like this in the back of one's mind when building a project. Martin McCormick WB5AGZ Stillwater, OK OSU Information Technology Division Network Operations Group -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist