当前位置:网站首页>How to connect 5V serial port to 3.3V MCU serial port?
How to connect 5V serial port to 3.3V MCU serial port?
2022-07-07 11:51:00 【Embedded Linux,】
Write it at the front : Due to the different levels of the two microcontrollers , Serial communication may fail , At this time, it needs to be solved by level conversion circuit , This paper gives two methods , One is built by triode , The other is MOS Pipe construction , Such questions often appear in the written examination of hardware engineers .
3.3V SCM and 5V The idea of SCM communication
3.3V Single chip microcomputer | Direction of communication | 5V Single chip microcomputer |
---|---|---|
Send logic 1( Corresponding voltage 3.3V) | → | Acceptance logic 1( Corresponding voltage 5V) |
Send logic 0( Corresponding voltage 0V) | → | Acceptance logic 0( Corresponding voltage 0V) |
Acceptance logic 1( Corresponding voltage 3.3V) | ← | Send logic 1( Corresponding voltage 5V) |
Acceptance logic 0( Corresponding voltage 0V) | ← | Send logic 0( Corresponding voltage 0V) |
MOS Tube conversion circuit
working principle :
1、 When 3V3 SCM sending logic 1, namely 3V3_TX=3.3V,Ugs=0V,MOS Pipe cut off ,5V_RX adopt R2 Pull up to +5V,5V_RX=5V;
2、 When 3V3 SCM sending logic 0, namely 3V3_TX=0V,Ugs=3V,MOS The pipe is open ,5V_RX Will be pulled down ,5V_RX=0V;

Then someone said ,5V How to send the data to 3V3 Single chip microcomputer ? Is it OK to change the signal direction and power supply , Let's take a look .
working principle :
1、 When 5V SCM sending logic 1, namely 5V_TX=5V,Ugs=0V,MOS Pipe cut off ,3V3_RX adopt R1 Pull up to 3V3,3V3_RX=3.3V;
2、 When 5V SCM sending logic 0, namely 5V_TX=0V,Ugs=5V,MOS The pipe is open ,3V3_RX Pulled down , therefore 3V3_RX=0;
The above analysis seems reasonable , In fact, the following circuits are not available , The above first 2 There is no problem with dot , It's mainly the first 1 spot , When MOS When the pipe is cut off ,5V_TX Of 5V The voltage will pass MOS The body diode of the tube reaches 3V3_RX, send 3V3_RX The voltage of is higher than 3.3V(4V many , Depends on the conduction voltage drop of the body diode ). In this case , One side 4V More voltage and 3.3V There is a differential pressure , after R1 The resistance will consume electricity ; On the other hand ,4V Too much voltage can also damage 3.3V Single chip microcomputer RX Pin .
Use simulation software to simulate , You can see MOS When the pipe is cut off , The output is 4.44V, Significantly higher than 3.3V, It verifies the above viewpoint .
Simulate the above unavailable circuit
How to design 5V Send to 3.3V Single chip microcomputer ? Actually, it's simple , Two devices are done , The following is the circuit diagram .
1、5V_TX=5V when , diode D1 end ,3V3_RX=3.3V;
2、5V_TX=0V when , diode D1 Conduction ,3V3_RX≈0.6V; actual 3V3_RX How much is the , Depending on D1 Forward conduction voltage drop , Because to get a lower voltage , commonly D1 Select Schottky diode , Schottky has the advantage of small conduction voltage drop .

Triode conversion circuit
working principle :
1、 When 3V3 SCM sending logic 1, namely 3V3_TX=3.3V,NPN Triode cut off ,5V_RX adopt R2 Pull up to +5V,5V_RX=5V;
2、 When 3V3 SCM sending logic 0, namely 3V3_TX=0V,NPN Triode conduction ,5V_RX Will be pulled down , therefore 5V_RX=0V;

Using a triode ,5V SCM sends to 3.3V Single chip microcomputer , Whether the power supply and signal can be interchanged , and MOS Tube circuit is the same , The following circuits also cannot be used .
The reason is that 5V_TX by 5V when , Emitter reverse bias , however 5V Through resistance R1 From the base of the triode to the collector of the triode , Cause positive deviation of collector , and MOS Tube circuit is the same , send 3V3_RX The voltage is higher than 3.3V(4V many ), You can simulate , I won't simulate here .

as follows , given 5V MCU to 3.3V Circuit diagram sent by MCU , With two NPN Triode construction .
working principle :
1、 When 5V SCM sending logic 1, namely 5V_TX=5V,Q1 Conduction ,Q2 The base of is pulled down ,Q2 end , therefore 3V3_RX=3.3V;
2、 When 5V SCM sending logic 0, namely 5V_TX=0V,Q1 end ,Q2 Conduction , therefore 3V3_RX=0V;

You can see , I didn't draw two NMOS Pipe construction 5V MCU to 3.3V The circuit sent by MCU , Actually, replace the triode in the figure above with NMOS tube , Can achieve , In the actual circuit design , To reduce costs , Try to use less devices to connect the circuit , Therefore, the diode scheme is generally used .
This is the end of today's article ...
Oh no , The above question is not over
The reason why I forward this article is that I discussed this problem with my friends in the evening , We also held a Tencent meeting because of this problem .
If you want to connect 3.3V MCU serial port , We should think of it at the first time that we also use 3.3V The single chip computer of , Two 3.3V There must be no problem with the power supply of single chip microcomputer . And now there are a lot of ARM chip , All are 3.3V Of GPIO Port voltage ,5V Single chip microcomputer as a primary entry level , Has been slowly replaced , Of course , And after 1.8V The single chip computer of .
—— The End ——
边栏推荐
- R语言可视化分面图、假设检验、多变量分组t检验、可视化多变量分组分面箱图(faceting boxplot)并添加显著性水平、添加抖动数据点(jitter points)
- R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
- STM32 entry development write DS18B20 temperature sensor driver (read ambient temperature, support cascade)
- The running kubernetes cluster wants to adjust the network segment address of pod
- Various uses of vim are very practical. I learned and summarized them in my work
- Flet教程之 18 Divider 分隔符组件 基础入门(教程含源码)
- 【系统设计】指标监控和告警系统
- Technology sharing | packet capturing analysis TCP protocol
- 聊聊SOC启动(九) 为uboot 添加新的board
- 千人规模互联网公司研发效能成功之路
猜你喜欢
Talk about SOC startup (VII) uboot startup process III
Test the foundation of development, and teach you to prepare for a fully functional web platform environment
Technology sharing | packet capturing analysis TCP protocol
[system design] index monitoring and alarm system
聊聊SOC启动(十一) 内核初始化
【纹理特征提取】基于matlab局部二值模式LBP图像纹理特征提取【含Matlab源码 1931期】
About how to install mysql8.0 on the cloud server (Tencent cloud here) and enable local remote connection
Camera calibration (1): basic principles of monocular camera calibration and Zhang Zhengyou calibration
Unsupervised learning of visual features by contracting cluster assignments
聊聊SOC启动(九) 为uboot 添加新的board
随机推荐
STM32 entry development NEC infrared protocol decoding (ultra low cost wireless transmission scheme)
核舟记(一):当“男妈妈”走进现实,生物科技革命能解放女性吗?
MATLAB实现Huffman编码译码含GUI界面
总结了200道经典的机器学习面试题(附参考答案)
STM32 entry development write DS18B20 temperature sensor driver (read ambient temperature, support cascade)
R语言可视化分面图、假设检验、多变量分组t检验、可视化多变量分组分面箱图(faceting boxplot)并添加显著性水平、添加抖动数据点(jitter points)
Two week selection of tdengine community issues | phase II
Swiftui swift internal skill: five skills of using opaque type in swift
[system design] index monitoring and alarm system
一度辍学的数学差生,获得今年菲尔兹奖
大佬们有没有人遇到过 flink oracle cdc,读取一个没有更新操作的表,隔十几秒就重复读取
Talk about SOC startup (IX) adding a new board to uboot
[extraction des caractéristiques de texture] extraction des caractéristiques de texture de l'image LBP basée sur le mode binaire local de Matlab [y compris le code source de Matlab 1931]
R language uses image of magick package_ Mosaic functions and images_ The flatten function stacks multiple pictures together to form a stack layers on top of each other
.NET MAUI 性能提升
Complete collection of common error handling in MySQL installation
Test the foundation of development, and teach you to prepare for a fully functional web platform environment
R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
Talk about SOC startup (x) kernel startup pilot knowledge
禁锢自己的因素,原来有这么多