
Originally Posted by
ShawnB
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
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks