Hi Acetronics2,
thanks for your reply.
To be accurate, during power on, these I/Os turn on and off (and then stay off) very quickly (like a flash). The idea is to stop that high-low behavior.
Hi Acetronics2,
thanks for your reply.
To be accurate, during power on, these I/Os turn on and off (and then stay off) very quickly (like a flash). The idea is to stop that high-low behavior.
Simple answer- you cannot do that.
You should design your project with active low outputs to account for the High-Z input state at power on. Almost every microcontroller, I know, behaves similarly unless there is special hardware built in to retain a certain state at power on. Till such time as your program code runs, the microcontroller IO pins are kept in a High-Z state to prevent unintentional damage to itself.
Greetings,
thank you Jerson for your reply.
Regarding "design your project with active low outputs to account for the High-Z input state at power on", what do you mean exactly?
If, for example, I only have LEDs on these I/Os, what can I do?
if you have leds that illuminate on power up before the pins have been set as outputs then you are doing something very odd
or you have broken something
schematic and code ?
Warning I'm not a teacher
Yeah, this sounds very strange.
As others have said, after power on and reset (POR) all the pins come up as inputs so they should not go either high or low for any duration. Leakage current into the pin is MUCH less than a uA (200nA max) so basically "any" sort of resistance (ie several mega Ohms) to either Vdd or Vss will pull the pin to that.
And it doesn't really matter what you do with the PORT or LAT registers until you also clears the TRIS bits in questions. Ie, at power up the pins are inputs (high impedence), then you "preset" their default state(s) by writing to PORT or LAT and finally you clear the corresponding TRIS bits to enable the output drivers.
The 18F2580 have pull-ups on PORTB (and PORTB only it seems). They are disabled on POR so they should not be able to pull the pin high. The current sourced thru the pull-up resistor is between 50 and 400uA so even WITH them enabled I don't think you'd see a LED light up.
More details please...
Many a times, I have used an I/O pin to drive a relay through a transistor. So, assuming I need an active high output to turn on the relay, I have observed (across microcontroller families) that the relay flicks on for the fraction of a second till the program code takes control and the pin get set to the off - state of the relay (0). So, the ideal way to resolve such a situation is to ensure that the relay turns on only when the I/O pin is made to output a LOW.
In case of driving an LED from an IO pin, my thinking is biased with the TTL logic output specificiation where the sinking current limit is larger than the sourcing current limit. So, I usually tend to use LEDS with an active low output configuration. The IO port has to be low for the LED to turn on. This spec thing is no longer true with the current generation of microcontrollers except the 8051 family dies from old.
So, as a best practice, I tend to use active low outputs for any device that needs to be turned on.
Bookmarks