Avoiding undefined port state upon reboot

I’ve found that some/all of my output ports are in an undefined state upon reboot. I plan to solve this with an external pulldown resistor, but I’m wondering, does that mean I should use ResistorMode.None when initializing the port?

Is there a better way to accomplish this?

There is no direct answer fro this question. It depends on what is connected to the pin. ResistorMode.None or other wouldn’t matter.

I’ve got a BJT connected to the port, and to that I’ve got an SSR (phototriac) driving a solenoid. I’ll eventually have 16 of these, and if they all switched on for a few seconds, and then off, the results could be… well… spectacular :slight_smile:

is your question that you want to know how to define an outputport, when you have external physical pulldown resistors? In that case, yes, you shouldn’t define it with internal pullup/down.

And yes, this is the right approach where you must force a specific configuration when you start a device. That way you control what the uC sees at start time and you control what the connected peripherals do at that time.

Right, it’s important that the outputs stay LOW at boot time. Something like this ought to work?

Yes that should do it.

I was just browsing through, thought i’d mention - Looking at your diagram there is no point in connecting the collector of Q2 to 5V - The voltage at the emitter will always be base voltage - voltage drop, no matter the voltage at the collector. If you do want to amplify the voltage, you want to connect your device between the collector and Vcc, which is what I’m guessing you wanted to do, otherwise you can stick with 3v3.

Also currently this will act as a current source, which might cause problems.

Indeed. This ought to be much better. Thanks for the good catch.

… but it doesn’t. The output still goes high upon reboot. Should I be using a different value for the pulldown resistor?


What you need to do is put a scope on the output of the FEZ when it’s rebooted, work out what’s the voltage of an undefined pin upon reboot. Now what you have is a potential divider, where some of the voltage is dissipated across a pulldown resistor, and the rest across base emitter junction of the transistor.

What you now need to work out is the maximum voltage you can affoard across the transistor without triggering the circuit, and work out the two resistor values (keep in mind on resistance of the transistor and resistor value tolerance), for the base and the pulldown.

What you want is for the voltage on reboot to be below the threshold that triggers the circuit, and the voltage on pin high to be above.

Another thing you could do is just slap a PNP transistor from the pin to ground, that is connected to a “Ready” pin, that turns on when the chip finished initialising. That would pull all those pins down hard on reboot.

Or you could use a zener diode to do the same job.

Another idea - have a common terminal for all of the outputs that you need low on reboot - and have that activated with a single FET, running off a “Ready” pin on the micro.

I ended up solving the problem by driving the outputs with a 74HC595 shift register instead of from pins directly… since the /OE pin (output enable, active low) gets pulled up as well, nothing gets output until I’m good and ready.

Yeah I was thinking shift register but I wasn’t sure of your exact requirements :slight_smile:

Why don’t you drive the Optocoupler LED directly from the Fez output pin? According to the specs it can source 4mA - which should be enough to drive a LED on the optocoupler (usually less than 1mA required via resistor).

The pin would need to be “really high” to switch on - not just floating or weak pull-up - so it should stay off unless the pin is pulled high by the program.

What do the others think? Is this safe?

I’m using the Sharp PR26MF12NSZF solid-state relay: http://media.digikey.com/pdf/Data%20Sheets/Sharp%20PDFs/PR26,36MF1xNSZ.pdf

Sharp recommends driving with at least 2x the minimum trigger current, which is either 10mA for rank 1 devices, or 5mA for rank 2 devices. My devices are rank 2, so based on the table on page 9 of the datasheet, Sharp recommends driving with between 10mA and 15mA. Rank 1 devices they recommend between 20mA and 25mA.

The maximum forward current on these things is actually 50mA. (!!!)

I don’t know why they’re such high-current, but there you go.