Morgan Olsson wrote: > At 12:25 1998-02-24 -0500, Mike Keitz wrote: > >>* Put the setting of TRIS registers inside the loop. Sometimes >> a glitch will corrupt the settings in the TRIS registers. > > :-O > ?? What ?? How ? Glitch where? When? Morgan, consider the proverbial stray cosmic ray, some RF noise coupling to MCLR, mains interference causing a tran- sient dip on the power rails, back EMF from a relay being switched... There are many ways in which the operation of an embedded microcontroller can be disrupted. When it happens, it is often the I/O pin control registers that are effected. For these reasons, it is standard practice with embedded controllers to place as much of the initialization code as possible in the program's outermost loop. Then, if someone starts the arc-welder (or that kiln controller switches on a 5kW heating coil ;) ) and a spike gets through to the pic (just enough to glitch TRISA but not kill the micro) then next time around the loop it should be put right. ___Bob