0
\$\begingroup\$

I am using an STM32 microcontroller.

I need to have a GPIO output which needs an external pulldown so some relays stay in the right state when the MCU is not running yet. It seems the open drain mode is only for external pull ups as the only possible outputs are open drain and GND.

What can I do to solve my problem? I don't see a configuration that outputs either open-drain or VCC

The output of the MCU (BRAKE_PWR_CTRL) is driving a MOSFET which then drives the relay as shown:

enter image description here

Thanks.

\$\endgroup\$
  • 3
    \$\begingroup\$ When the MCU is not running, the IO pins are high (ish) impedance so what's the bother? \$\endgroup\$ – Andy aka Oct 12 '20 at 16:30
  • 1
    \$\begingroup\$ I still want to be able to turn on and off the relay after the MCU is running which means either with "open drain" or VCC output. I don't see how I can do this with stm32 MCU \$\endgroup\$ – Renato Oct 12 '20 at 16:32
  • 1
    \$\begingroup\$ It is possible to set the pin between output high and high-z. You can do it if you want, but there is no point in it as there is much simpler solution. \$\endgroup\$ – Justme Oct 12 '20 at 16:42
  • 1
    \$\begingroup\$ How are you connecting the MCU IO to the relay? Are you directly driving the coil or do you have some buffer circuit in between? Please include a schematic in your question. \$\endgroup\$ – The Photon Oct 12 '20 at 17:05
  • \$\begingroup\$ @ThePhoton, just edited the question. Thanks \$\endgroup\$ – Renato Oct 13 '20 at 8:36
6
\$\begingroup\$

Standard way is to have the pull-down resistor and in the firmware just set pin as push pull output.

And now that you actually show the schematics, you really want to drive the FET gate as fast as you can which is achievable only when the MCU pin is a push pull output.

Simply letting the resistor to discharge the gate capacitance will be slow and that makes the FET to spend more time being halfway on and heating up.

\$\endgroup\$
2
\$\begingroup\$

Just add a pull-down resistor to the output.

During and just after reset, the alternate functions are not active and the I/O ports are configured in Input Floating mode (CNFx[1:0]=01b, MODEx[1:0]=00b).

\$\endgroup\$
  • \$\begingroup\$ There is already a pull down resistor. still want to be able to turn on and off the relay after the MCU is running which means either with "open drain" or VCC output. I don't see how I can do this with stm32 MCU \$\endgroup\$ – Renato Oct 12 '20 at 16:34
  • 4
    \$\begingroup\$ Unless your pull-down resistor is crazy low in value the push-pull output will overpower it when you enable the GPIO as output. \$\endgroup\$ – Spehro Pefhany Oct 12 '20 at 16:35
  • 3
    \$\begingroup\$ The point of a pulling resistor is that it is weak enough that it is readily overriden, for example by a push/pull output driving high. In a battery powered system you would have to consider the current expended holding a signal against a pulling resistor for a long period of time, but that seems unlikely to apply if you have relays. \$\endgroup\$ – Chris Stratton Oct 12 '20 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.