On Wed, 01 Jun 2005 15:16:17 -0500, Martin McCormick wrote: > 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. I eventually found a visually good but electrically bad connection to Vss. My current theory for the overall observed behavior is that there were enough paths to ground at any given moment that at 4 MHz there was adequate operating voltage to allow the read-modify-write operations on the port pins to succeed, but that the higher current consumption at 20 MHz pulled the processor Vss high enough that the reads normally came in as "low". > > 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 test routines sweep a duty cycle between about 10% and about 90%, so the waveform is nearly always asymmetric. The software duty cycle is the classic "average n / 256" algorithm, so at the extremes there are long periods of on or long periods of off. The intent is to put varying loads at varying frequencies out on the wires, to see what breaks. So, technically, I got what I wanted. > 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. Since the port lines exhibited the correct waveforms without the LED loads, I figured that the lack of load put the chip's Vss level back in the range where R-M-W didn't produce wrong results; reconnecting an LED when the port was "on" would cause the diode to light up until the next update... > It's good to keep stories like this in the back of one's mind >when building a project. I'm still getting used to parts that use so little current that you can inadvertently power them through the data lines. When I started in this business, five-amp power supplies were often laughably inadequate, and issues of this nature did not arise. (Cue video of "First step in Tempo I troubleshooting: use a two-by-four to re-seat all the chips".) mdr (uphill both ways) -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist