I'm trying to design a circuit to connect this quadrature encoder AMT11 output signal to my microcontroller STM32L4R5ZIT6P that's running on 3.3V. Since the output from the encoder is 5V, if I directly connect the output signal to the 5V tolerant pin on the micro (eg. pin 18,19), will it damage the microcontroller in the long run if the pins are receiving 5V constantly? Do I need any protection on the pin?

  • \$\begingroup\$ If the input pin is truly spec'ed as "5V tolerant" then it can accept a 5V signal without undue wear and tear - it's designed for that purpose. \$\endgroup\$
    – td127
    Commented Jan 27, 2022 at 18:19
  • \$\begingroup\$ ZT means 100-pin LQFP, is this correct? Pin 19 is analog ground, definitely not 5V tolerant. Which package and pins you mean, don't say pin number, but preferably e.g. PC2 which is unique regardless of package. And, will you have 5V fed to unpowered MCU? \$\endgroup\$
    – Justme
    Commented Jan 27, 2022 at 18:36
  • \$\begingroup\$ @Justme it's the LQFP-144 package. Sorry I meant Pf6 and PF7. Ah thanks for pointing that out. I might have to do something to make sure the 5V won't feed into the unpowered MCU \$\endgroup\$
    – cy1125
    Commented Jan 27, 2022 at 19:09
  • \$\begingroup\$ Someone asked this exact same scenario a few days ago: electronics.stackexchange.com/questions/605523/… \$\endgroup\$
    – DKNguyen
    Commented Jan 27, 2022 at 21:32

3 Answers 3


The absolute maximum input voltage is min(VDD, VDDA, VDDIO2, VDDUSB) + 4.0 with some notes.

It does not appear to me that it's safe to apply 5V to the pin if min(VDD, VDDA, VDDIO2, VDDUSB) < 1V.

In other words, supply sequencing may be necessary to ensure that the 3.3V supply is not absent with the 5V supply present. (Or, you could just use a level translator that has two Vdd pins and is designed for this kind of application).

enter image description here


What you need is a bi-directional voltage level converter between 3.3V and 5V. You can find additional information in this stackexchange post: Is there any bidirectional 5v-3.3v level shifter? If you search the internet for “3.3V to 5V level shifter bidirectional IC” you will find several companies with integrated circuits that do the job.

Basically the circuit works like this:

• On one side you have the 3.3V from the power supply of the microcontroller feeding its 3.3V level signal.

enter image description here

• On the other side you have the 5V from the power supply of the quadrature encoder feeding the level 5V signal.

enter image description here

• In the middle you have a transistor (BJT or MOSFET) to isolate them and provide the correct voltage to the other side.

enter image description here

• The ground of both power supplies (3.3V and 5V) are common.

• Here is the final circuit. Please note the substrate diode direction. You want it to be forward biased from the 3.3V to 5V and in reversed biased from the 5V to 3.3V.

enter image description here

• When the signal from the microcontroller is high (3.3V) the MOSFET is OFF and the signal on the quadrature encoder is pulled-up (5V) by the Rhigh resistor.

• When the signal from the microcontroller is low (0V) the MOSFET is ON and the signal on the quadrature encoder is pulled-down (0V) by the MOSFET.

• When the signal from the quadrature encoder is low (0V) the substrate diode pulls the signal from the microcontroller low (0V) ) turning the MOSFET ON.

• When the signal quadrature encoder is (5V) the MOSFET source pin is pulled up by the 3.3V and the MOSFET is OFF.

• Note: This works for open collector type of gates.

  • \$\begingroup\$ Why bidirectional? How can you tell that there are inputs to the encoder from the MCU? \$\endgroup\$
    – Lundin
    Commented Jan 28, 2022 at 10:12
  • \$\begingroup\$ @Lundin, the circuit will work with traffic from either side of the connection. If there is no traffic from one of the sides it won't alter the functionality of the circuit. In case of traffic from only one side, with some modifications, the MOSFET can be replaced by a BJT transistor. \$\endgroup\$
    – VictorTito
    Commented Jan 28, 2022 at 16:13

If all you want to do is convert the 5V quadrature signals to 3.3V for the microcontroller, then a few resistors connected as voltage dividers should work fine. In general, this will degrade the rise time a little, but full featured encoders like this usually have muscular output drivers, so it might not even be noticeable unless you're trying to spin the encoder at its maximum speed.


simulate this circuit – Schematic created using CircuitLab


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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