In the circuit we designed, different chips use different voltages for their pins, such as the common 1.8V, 3.3V, 5V, etc. When communicating between the pins of two chips with different voltages, we need to ensure that both sides of the voltage meet our own needs and can communicate normally, which is called level conversion.
Because there is a level mismatch problem in the communication between chips with different voltages, if the voltage difference between the two ends of the communication is too large, it may also damage the chip pins, so we need to perform level conversion.
In general, when we perform level conversion, we mainly consider the speed of signal transmission and the direction of the signal.

There are several ways:

Ⅰ.Diode level conversion circuit

When using this circuit, you need to pay attention to the direction of conversion. The high voltage end and the low voltage end cannot be swapped.
Principle analysis: When the input end 3.3V is low level, D1 is turned on, and the output end 1.8V is low level, so that both ends are low level. When the input end 3.3V is high level, D1 is turned off, and the output end is pulled up to 1.8V by R1, which is high level, so that both ends are high level.

Ⅱ. Transistor level conversion circuit
Transistors realize level conversion, similar to diodes, and it is also necessary to pay attention to the direction of conversion, as shown in Figure 2 below:
Principle analysis:

Principle analysis:
1. The left IN is the input, the right OUT is the output, and VDDA and VDDB are two different voltage domains that convert to each other. When IN inputs 0V, transistor Q1 is turned on, OUT is pulled down to a level close to 0V, and low-level conversion is realized; when IN inputs a high level (VDDA), transistor Q1 is turned off, and OUT is pulled up to VDDB, thereby realizing high-level conversion. This circuit is a unidirectional conversion circuit with conversion directions of IN input and OUT output, which is simple and easy to use.
2. When the input IN is at a low level, transistor Q1 is turned off, transistor Q2 is turned on, and output OUT is pulled low, thereby realizing low-level conversion; when the input IN is at a high level (VDDA), transistor Q1 is turned on, causing transistor Q2 to be pulled low and turned off. Therefore, the output OUT is pulled up to VDDB by R4 to realize high-level conversion. This circuit can only realize left IN input and right OUT output, and cannot be inverted. However, it will affect the delay and conversion speed of the entire circuit and is not suitable for high baud rates (greater than 400Kbps, it is not recommended).

Ⅲ. Level conversion circuit built by NMOS tube
Principle analysis:


 Level conversion circuit built by NMOS tube
Principle analysis:
1. When S (ie TXD_1V8) outputs high level, Vgs of MOS tube Q4 = 0, MOS tube is turned off, and D (ie UART1_RXD) is pulled up to 3.3V by resistor R42;
2. When S (ie TXD_1V8) outputs low level, Vgs of MOS tube Q4 = 1.8V, which is greater than the conduction voltage threshold, MOS tube is turned on, and Net2 is pulled down to low level through MOS tube;
3. When D ( When D (i.e. UART1_RXD) outputs a high level, the Vgs of MOS tube Q4 remains unchanged, the MOS tube remains in the off state, and S (i.e. TXD_1V8) is pulled up to 1.8V by resistor R37;
4. When D (i.e. UART1_RXD) outputs a low level, MOS tube Q4 is not turned on. The MOS tube first pulls S (i.e. TXD_1V8) down to a low level through the body diode. At this time, Vgs≈1.8V, the MOS tube is turned on, and the voltage of S (i.e. TXD_1V8) is further lowered;
Notes:
(1) High voltage > low voltage – 0.7V, otherwise there will be problems when D→S transmits a high level, that is, Vs = Vd+ 0.7, at this time Vs < VCC;
(2) It is necessary to pay attention to the Vgs turn-on voltage of the MOS tube. Generally, circuits involving 1.8V need to pay attention to device selection;
(3) PMOS tubes can only achieve unidirectional level conversion, not bidirectional.

Characteristics of NMOS bidirectional circuit
Suitable for low-frequency signal conversion. Since the conductance resistance of the bidirectional NMOS circuit is large, it is suitable for low-frequency signal level conversion and is inexpensive. The manufacturing cost of the NMOS bidirectional circuit design is low, so the price is relatively low. The voltage drop ratio after conduction is smaller than that of the triode. Therefore, in some application scenarios that require high voltage, the NMOS circuit is more suitable. Positive and negative bidirectional conduction is equivalent to a mechanical switch. The bidirectional NMOS circuit can achieve positive and negative bidirectional conductance equivalent to a mechanical switch, so in some application scenarios that require frequent switching, the bidirectional NMOS circuit also has advantages. It should be noted that the specific implementation method of the NMOS bidirectional circuit may vary depending on the application scenario and device characteristics. In practical applications, it is necessary to select appropriate circuit topology and device parameters according to specific needs.