Quote Originally Posted by ShawnB View Post

So I should look at adding PORTx = 0 before the TRISx register to clear the port register?

Is this good programming practice (newbe question)?

I have pull-down resistors on the input but not on the outputs, so I can look at adding those.
Hi, Shawn

Clearing PORTx is not the way ...

but you must set PORTx to get a SAFE and KNOWN state at your Program start ...

so, if you have a PNP transistor driving something ... it's driving port initial state MUST be a "1" state with a Pullup resistor ... for the transistor NOT to conduct.

I already had the "gag" with an electronic ignition :

@ Power UP the guy had programmed a CLEAR Port.

and after he had preset the Port pin to 1 ... as the transistor driven was a PNP ...


so, When turning the contact Key ... often an explosion occured in a cylinder : not so good , hey ???

The Good practice is to ensure a SAFE initial state ... processor placed or not.

Alain