当前位置:网站首页>I2C [2] - why does IIC need to use open drain output and pull-up resistor bug
I2C [2] - why does IIC need to use open drain output and pull-up resistor bug
2022-06-21 22:08:00 【A small snail in a big city】
List of articles
Project scenario :
Recently in tune ICM20602 modular ( A six axis gyroscope and accelerometer ), Use IIC Communication protocol , During this process, I encountered a problem that bothered me for a long time .
Problem description
IIC Correct agreement , But the reading fails all the time .
Cause analysis :
Finally, it was found that... Was not configured GPIO Open drain output 
Push pull output and open drain output
Push pull output : Output logic 0, be N-MOS Activate ; Output logic 1, be P-MOS Activate .
Open drain output : When the pull-up resistor is not connected , Output logic 0, be N-MOS Activate ; Output logic 1,P-MOS Will not activate , No high level output . When connecting the pull-up resistor , Output logic 0, be N-MOS Activate ; Output logic 1,P-MOS Activate , Can output high level .
That is, the open drain output if Do not connect the pull-up resistor , No, Output high level Ability . If the open drain output is required to have the ability to output high level, a pull-up resistor shall be connected . At present, many single-chip computers GPIO The pull-up resistor can be configured by software .
The figure on the left shows the open drain output ( Connect the pull-up resistor ), The picture on the right shows push-pull output
The function of open drain output
Prevent short circuit : In some cases ( For example, the bus ), Multiple GPIO Ports may be connected on the same line , There is a certain GPIO Output high level , the other one GPIO Output low level . If push-pull output is used , You'll find this GPIO Of VCC And another one. GPIO Of GND Connected together , It's a short circuit ( It's cool ). What if you change to open drain output ? VCC and GND An extra resistor , So the circuit is safe . Therefore, the bus generally uses open drain output .
Line and : Open drain output can also be realized Line and ( To baidu ), Reduce an and gate , Simplify the circuit .
IIC Why use open drain output and pull-up resistor
- IIC The protocol supports multiple master devices and multiple slave devices on the same bus , If open drain output is not used , And push-pull output , There will be a short circuit between the main equipment .
- As for why we need to pull up the resistor , That's because IIC Communication requires the ability to output high levels .
In order to realize the arbitration when multiple master devices preempt the bus .IIC There are only two wires (SCL and SDA), How to determine which master device occupies the bus ( First come first served, of course ).
Suppose the main equipment A Need to start the IIC, He needs to be in SCL High voltage usually , take SDA Convert from high level to low level as start signal . Main equipment A In the SDA After pulling up , It needs to be checked again SDA The level of .
Why? ? Because the line and . If the main equipment A pull up SDA when , There are already other main devices that will SDA Pull down . because 1 & 0 = 0 Then the main equipment A Checking SDA Peacetime , You'll find that it's not high , It's a low level . It indicates that other master devices preempt the bus earlier than it , Main equipment A Only the occupied bus can be abandoned . If it's high , Can occupy .
This is the open drain output at IIC Another role in communication .
SDA Is a high level , Describe the main equipment A It can occupy the bus , Then the main equipment A take SDA Pull it down , Start communicating .SDA Is a low level , It means someone has got there first , Main equipment A The bus cannot be occupied , The end of the communication .
therefore , simulation IIC Be sure to will GPIO The port is set to open drain output and a pull-up resistor is added .( Hardware IIC It will be automatically configured as open drain output ).
Solution :
Finally, let's talk about why we used Push pull output IIC Read RTC No problem , This is because the pull-up resistance is different ,RTC The pull-up resistor can normally pull up and pull down the low level even if the push-pull output . According to the above , You can check MCU Of datasheet, confirm IO Of PMOS and NMOS The impedance of , Calculate the voltage .
There is another simple and crude way , Problems can also be found by directly using the oscilloscope to look at the waveform
边栏推荐
- ADT Spec RI AF CheckRep Safety from Rep Exposure
- CF1481F AB Tree
- phpmailer 通过smtp发送邮件,相同发送内容有的成功有的失败
- tkinter绘制组件(29)——单选组控件
- Wechat applet JS converts numbers into letters
- Introduction to security encryption
- 挖财赠送的证券账户安全吗?可以开户吗?
- Is the security of the securities account given by digging money safe? Can I open an account?
- 面了十多家实习岗位失败的实习面试经历总结
- Jerry's SD card reuse IIC precautions [chapter]
猜你喜欢

How to Polish English papers?

新能源行业商业采购协同系统:赋能新能源行业采购业务,提升产业协同

Which iPad apps can read English literature well?

龙蜥社区成立云原生SIG,引入3大核心技术

Excuse me, which website is better for college students to check literature?
![When Jerry made Bluetooth transmission, when he modified stereo to mono differential output, there was a jam sound at the receiving end [chapter]](/img/ef/35a74fe3b1a8035afb6c50e6880860.png)
When Jerry made Bluetooth transmission, when he modified stereo to mono differential output, there was a jam sound at the receiving end [chapter]

Constructor in JS (emphasis)

ACM. Hj35 serpentine matrix ●

怎样有效率地进行外文文献检索?

phpmailer 通过smtp发送邮件,相同发送内容有的成功有的失败
随机推荐
广东疾控提醒:暑期将至,返粤大学生这样安全“归巢”
央企国电集团上海翔伟机电和中外海达成战略合作,捐赠2亿
Specificity and application of Worthington Papain
Data types in JS (basic)
2022 Foshan Tanzhou ceramics exhibition held a press conference to launch ten key points of the exhibition
阿里云容器服务负责人易立:云原生如何解企业降本提效难题?
Tc3608h high efficiency 1.2MHz DC-DC booster IC
Go语言单元测试基础从入门到放弃
3D octave view
Do you really know binary tree? (Part I)
InteliJ-IDEA-高效技巧(一)
For in JS In function
12.信号基础
Worthington collagenase raw material
对“XXX::Invoke”类型的已垃圾回收委托进行了回调。这可能会导致应用程序崩溃、损坏和数据丢失。向非托管代码传递委托时,托管应用程序必须让这些委托保持活动状态,直到确信不会再次调用它们
Worthington胰蛋白酶解决方案
Overriding Overloading final
What are the authoritative websites that search English documents like CNKI?
Summary of intelligence problems
CF1481F AB Tree