当前位置:网站首页>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 ——
边栏推荐
- Talk about SOC startup (VII) uboot startup process III
- Enclosed please find. Net Maui's latest learning resources
- Neural approvals to conversational AI (1)
- audit 移植
- 聊聊SOC启动(十一) 内核初始化
- Automated testing framework
- R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
- Programming examples of stm32f1 and stm32subeide -315m super regenerative wireless remote control module drive
- STM32 entry development uses IIC hardware timing to read and write AT24C08 (EEPROM)
- 【数据聚类】基于多元宇宙优化DBSCAN实现数据聚类分析附matlab代码
猜你喜欢
本地navicat连接liunx下的oracle报权限不足
相机标定(2): 单目相机标定总结
HCIA复习整理
聊聊SOC启动(七) uboot启动流程三
[shortest circuit] acwing1128 Messenger: Floyd shortest circuit
千人规模互联网公司研发效能成功之路
Half of the people don't know the difference between for and foreach???
Suggestions on one-stop development of testing life
【最短路】ACwing 1127. 香甜的黄油(堆优化的dijsktra或spfa)
【最短路】Acwing1128信使:floyd最短路
随机推荐
【系统设计】指标监控和告警系统
Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
【神经网络】卷积神经网络CNN【含Matlab源码 1932期】
[shortest circuit] acwing 1127 Sweet butter (heap optimized dijsktra or SPFA)
Suggestions on one-stop development of testing life
Distributed database master-slave configuration (MySQL)
18 basic introduction to divider separator component of fleet tutorial (tutorial includes source code)
Programming examples of stm32f1 and stm32subeide -315m super regenerative wireless remote control module drive
Android interview knowledge points
分布式数据库主从配置(MySQL)
sql里,我想设置外键,为什么出现这个问题
Enclosed please find. Net Maui's latest learning resources
STM32 entry development write DS18B20 temperature sensor driver (read ambient temperature, support cascade)
核舟记(一):当“男妈妈”走进现实,生物科技革命能解放女性吗?
Talk about SOC startup (IX) adding a new board to uboot
聊聊SOC启动(九) 为uboot 添加新的board
STM32F1与STM32CubeIDE编程实例-315M超再生无线遥控模块驱动
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
【紋理特征提取】基於matlab局部二值模式LBP圖像紋理特征提取【含Matlab源碼 1931期】
STM32入门开发 编写DS18B20温度传感器驱动(读取环境温度、支持级联)