1
\$\begingroup\$

Will it be safe if I connect STM32F407 GPIO outputs (Vdd=3.3V) to 74HC04 hex Inverter inputs (Vdd=5V)? What is the best recommended method to add an inverter at the output of STM32F407 MCU?

edit:

Included schematic details about the 74HC04 circuit.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Why not use an inverter that uses 3V3 instead? \$\endgroup\$ – Jason Han Feb 15 at 2:47
  • \$\begingroup\$ Can you suggest which 3.3V Hex Inverter can go well with STM32F407? \$\endgroup\$ – scico111 Feb 15 at 3:01
  • \$\begingroup\$ Where is your inverter output going? What current output you're looking? \$\endgroup\$ – Jason Han Feb 15 at 3:05
  • \$\begingroup\$ "Shopping" help is usually not provided on Electrical Engineering Stack Exchange. Regardless, most any 3.3V Hex inverter should "go well with" any MCU with 3.3V GPIO. \$\endgroup\$ – Brandon Hill Feb 15 at 3:05
  • 1
    \$\begingroup\$ How fast are you toggling this signal? You could invert it with a transistor and a couple of resistors \$\endgroup\$ – Colin Feb 15 at 12:06
1
\$\begingroup\$

A 74HC04 is not guaranteed to function correctly if driven from a 3.3V CMOS output (although it will almost certainly work as it is very unlikely the device will be at the data sheet limits).

The worst case Voltage required to be recognized as a high level is 70% of the supply voltage (Vih). If the 5V rail is in fact 5.25V then this would be 3.675V - above the 3.3V supplied by the GPIO. The more normal case is that it would sense just over ~50% as a high which for a 5V rail is 2.5V and so would work.

The HCT family of devices is a similar to the HC devices but are designed for this type of interfacing and have a threshold that is independent of the supply rail with a worst case of 2V which is guaranteed to work with the 3.3V input signal. They do have a more restrictive supply rail voltage of 4.5 - 5.5V though.

The 74HCT04 device is equivalent to the 74HC04 but has this better controlled threshold.

The HCT devices were actually designed to interface to bipolar TTL devices which had a worst case Voh of 2.4V but will work as well for your application.

\$\endgroup\$
  • \$\begingroup\$ Are there any 3.3V hex inverters which can be used with STM32F4 GPIO's? Will these work 74LVT04 (assets.nexperia.com/documents/data-sheet/74LVT04.pdf) or 74LVC04 (ti.com/lit/ds/scas704b/scas704b.pdf)? \$\endgroup\$ – scico111 Feb 15 at 4:14
  • 1
    \$\begingroup\$ The [Nexperia 74HC04] will work just fine with 3.3V logic signal input if Vcc is 3.3V. So will the 74LVT04 and the 74LVC04. \$\endgroup\$ – Brandon Hill Feb 15 at 5:30
  • \$\begingroup\$ Really tempted to downvote. As @BrandonHill commented, a 74HC04 will work perfectly well at 3.3 volts Vcc. However, it will only run at something like 1/2 to 1/3 the speed. Additionally, they may run OK at 5 volts, but there will be essentially no noise margin, so reliability will suffer and really good decoupling will be a must. \$\endgroup\$ – WhatRoughBeast Feb 15 at 5:56
  • \$\begingroup\$ I have edited the question and included the schematic where this hex inverter is used. How can it be replaced or is it possible to avoid it at all? \$\endgroup\$ – scico111 Feb 15 at 11:49
  • \$\begingroup\$ @WhatRoughBeast - that seems a bit harsh. The original question was whether you could interface a 3.3v signal to an HC04 running off 5V, not whether you could run an HC04 off 3.3V. As I stated it will work in the vast majority of cases but as you stated the noise margin is minimal and it is not guaranteed at the extremes of supply voltage variations. \$\endgroup\$ – Kevin White Feb 15 at 15:14
1
\$\begingroup\$

3.3V logic levels should not be used with 5V powered HC chips. One option is to use 5V tolerant IO pin on STM32 in opendrain output mode and have a pull-up resistor to 5V so this way the logic level fed to inverter is 5V. The limitation is that when MCU is in reset, the resistor keeps high and inverter output is low. Another thing is, if the MCU can use 5V logic levels, why keep the inverter at all.

\$\endgroup\$
  • \$\begingroup\$ I have edited the question to include the schematics where the hex inverter is used. There are no open drain outputs available on the MCU GPIO pins.. Can we use level shifting chips from 3.3V to 5V at the place of hex inverter? \$\endgroup\$ – scico111 Feb 15 at 12:18
  • 1
    \$\begingroup\$ False assumption, ALL gpio pins of STM32 can be configured into open drain mode!Also, the hex inverter drives an optocoupler that is also powered from 3.3V, so using 5V supply for the hex inverter makes no sense, driving 5V to optocoupler would cause the internal LED to reverse bias (though it seems it can handle it). \$\endgroup\$ – Justme Feb 15 at 17:49
0
\$\begingroup\$

It should be safe, as the hex inverter will be able to handle 0-5V on its input at least, and you will only be applying 0-3.3V. The question is whether or not the 3.3V logic high input will be recognized as a logic high or not. You need to look at the specific manufacturer datasheet for your part, and see what the "Minimum High-Level Input Voltage" is. An example here: datasheet In the case of the above part, a little linear interpolation yields 3.5 as the Minimum High-Level Input Voltage when Vcc is 5.0V. This is a worst-case scenario, and in my experience, 3.3V logic into such a part will usually work, but can't be relied upon, and you usually never want to rely upon a behavior not expressly promised in a datasheet unless you have done significant characterization testing of many parts.

Note that the Nexperia 74HC04 will work just fine as a 3.3V inverter if Vcc is 3.3V.

This part (Nexperia 74HCT04) promises a Minimum High-Level Input Voltage of 2.0V when Vcc is 5.0V. This part will definitely work just fine for your application. datasheet2

\$\endgroup\$

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.