I thought maybe that the output ports were simply in an undefined state upon reboot (the so-called “third state”), but it appears it is not. It’s very definitely going “high” to about ~0.8V upon reset for about 2-3 seconds, and then dropping to zero (I assume just as I initialize the OutputPort). This is enough to trigger the transistor (2N2222) I have connected to that port (through a 2k2 resistor).
I tried putting a 47k resistor between the port and ground, but that did not work.
I tried using a different GPIO pin, but that did not work either (tried Di8 and Di20).
What can I do to prevent this? Should I use a smaller value resistor between the port and ground? The folks over at electronics.stackexchange.com seem to think that the MCU shouldn’t change port states just because it was reset.
I see in [url]http://www.tinyclr.com/forum/1/1082/#/1/msg11135[/url] you recommended a 1k external pulldown to prevent the pin going high upon startup. That’s fine, but does that mean I’ll be pulling ~3.3mA through the pin all the time, or just during startup?
I had this problem too. If you’re using a bread board there is a quick and easy fix. My friend suggested that you have a pin allocated to “enable” which you drive low at the beginning of the program. Essentially, you disable all the inputs on your breadboard when the “enable” pin is high (i.e. when you reset your board) then when the program finally initializes, the first thing you do is drive in the pin low to re-enable all your other pins.
It struck me that I might be able to use a PNP transistor as a switch instead of an NPN. That way, I can simply keep the output high, and my solenoids wouldn’t switch on upon reset. Sound like a viable plan? Downsides?
PNP is a no-go, since I’m driving the transistor from 5V and the output is only 3.3V. I just experimented a bit with pulldowns and it seems a 10K will do the trick. That’s not much current, so I can live with it.