cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt on how to interface a 5V circuit to a 3V microcontroller (STM32) - Input Pins

Killstreet30
Associate III

0693W00000YAfLGQA1.png 

Hello,

The input 1 and input2 signals will be fed from an STM32 but the problem is the signal sent from STM32 is 3.3V but the input to the IC is 5V. How do I convert the same? Please help.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

Well, that good olde L293D.

This is a no brainer because even 3.3V supplied GPIO output generates 5V TTL compatible signal levels.

See data sheet of your chip.

Application note AN4899 "STM32 microcontroller GPIO hardware settings..." is worth reading.

View solution in original post

5 REPLIES 5
KnarfB
Principal III

Well, that good olde L293D.

This is a no brainer because even 3.3V supplied GPIO output generates 5V TTL compatible signal levels.

See data sheet of your chip.

Application note AN4899 "STM32 microcontroller GPIO hardware settings..." is worth reading.

0693W00000YAi6JQAT.png 

I thought I'll use this circuit but how will I calculate the R and R' values? Any idea?

That way you build a voltage divider so that the input will never see neither 0 V nor 5 V.

So better check the datasheet what "5V input" means (high / low thresholds, min / max over complete temperature range), then you might find that what KnarfB said is correct.

The most simple level shifter would be putting a npn transistor (or N-mosfet) "between" your 2 resistors, although then you would have an inverted signal.

Well, the 2 R's work as intended if GPIO is configured as open-drain. Then R' pulls up to 5V when GPIO is open and if R is considerably lower, then it pulls down to a low voltage when the GPIO is pulling to gnd.

Dimensioning: make R' small enough that the 5V input gets enough current, but not much smaller. Then, make R such that the low voltage will be low enough when the GPIO is low, but not much smaller.

In case of doubt: use LTspice simulator.

hth

KnarfB

Oops, I never used STM32 GPIOs as open drain, so I actually forgot about that feature...