九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
SPI 與 I2C 協(xié)議的差異和需要考慮的事項(xiàng)

當(dāng)涉及到印刷電路板上的芯片之間的通信時(shí),兩種協(xié)議非常流行:串行外設(shè)接口(SPI)和內(nèi)部集成電路(IIC或I2C)。這些有線協(xié)議被認(rèn)為是“小”或“低端”,因?yàn)樗鼈儧](méi)有其他協(xié)議(如USB,以太網(wǎng),SATA等)吹噓的速度,魯棒性和距離。
然而,SPI和I2C非常受歡迎,因?yàn)樗鼈円子趯?shí)現(xiàn),只需要很少的組件和代碼,而不是它們的重量級(jí)表親。兩者都依靠串行通信來(lái)傳遞數(shù)據(jù),并在一條總線上支持多個(gè)設(shè)備。許多微控制器、傳感器和外設(shè)(如LCD)依靠SPI和I2C相互通信。
如果您正在設(shè)計(jì)產(chǎn)品,需要在SPI和I2C之間進(jìn)行選擇,您會(huì)選擇哪一個(gè)?

SPI

SPI 由摩托羅拉于 1980 年代開(kāi)發(fā),作為其早期微控制器和板載外設(shè)(如 EEPROM)之間通信的一種方式。摩托羅拉或任何其他組織都維護(hù)SPI協(xié)議的任何標(biāo)準(zhǔn)化。由于這種“事實(shí)上的”標(biāo)準(zhǔn),實(shí)現(xiàn)可能因制造商而異。請(qǐng)務(wù)必仔細(xì)閱讀每個(gè)支持SPI的器件的數(shù)據(jù)手冊(cè)!
SPI使用四條有源信號(hào)線(不包括電源線和接地線)在器件之間進(jìn)行通信。這些行包括:
  • SCLK:串行時(shí)鐘(由主站控制)
  • MOSI:主出從入(由主控)
  • 味噌:主入從出(由從設(shè)備控制)
  • SS:從屬選擇(由主控制)
通過(guò)這四條線路,控制設(shè)備(主設(shè)備)可以與另一個(gè)外圍設(shè)備(從設(shè)備)通信。
SPI 點(diǎn)對(duì)點(diǎn)連接
雖然SPI總線上可能只有一個(gè)主設(shè)備,但可以添加任意數(shù)量的外設(shè)。但是,對(duì)于添加的每個(gè)外設(shè),必須添加額外的 SS 行。在示例圖中,我們必須使用三條獨(dú)立的SS線,每條線控制一個(gè)單獨(dú)的外設(shè)。
用于 3 個(gè)從設(shè)備的 SPI 連接
當(dāng)主設(shè)備希望向外設(shè)發(fā)送數(shù)據(jù)或從外設(shè)接收日期時(shí),它通過(guò)將相應(yīng)的SS線拉低來(lái)開(kāi)始通信。同時(shí),它激活時(shí)鐘線(在給定頻率下切換SCLK高低)。主器件在MOSI線路上發(fā)送數(shù)據(jù),同時(shí)對(duì)MISO線路進(jìn)行采樣。因此,可以在主設(shè)備和外圍設(shè)備之間同時(shí)發(fā)送數(shù)據(jù)(全雙工)。
請(qǐng)注意,一次只能有一個(gè)外圍設(shè)備與主設(shè)備通信。
模式 0 SPI 的時(shí)序圖示例:MOSI 和 MISO 線路在上升的 SCLK 邊沿上采樣
SPI有四種不同的模式可以設(shè)置,這些模式?jīng)Q定了時(shí)鐘的工作方式。主設(shè)備和外圍設(shè)備必須使用相同的模式。模式 0 是迄今為止設(shè)備中最常見(jiàn)的模式。
  • Mode 0: data sampled on rising clock edge, clock idles low
  • Mode 1: data sampled on falling clock edge, clock idles low
  • Mode 2: data sampled on falling clock edge, clock idles high
  • Mode 3: data sampled on rising clock edge, clock idles high
SPI does not specify any particular voltage levels, maximum speed rates, or addressing schemes. As a result, it is up to you to decide these factors. SPI speeds can easily exceed 10 Mbps, so make sure you read the datasheets for all your parts, as that will determine the acceptable voltages, speed limits, and supported modes.
Because of these speeds, SPI is useful for transferring large amounts of data. SPI is often found on sensors that require fast update rates, like accelerometers, display devices, LCDs, and flash memory devices.

I2C

Philips Semiconductors (now known as NXP Semiconductors) created the I2C specification in 1982 to help standardize communication between chips on the same board. NXP does not charge anyone to use or implement I2C, but they do charge a fee if you would like to register a device address.
I2C uses 2 lines (not including power and ground) for communication:
  • SDA: Serial Data
  • SCL: Serial Clock
Any number of master devices and any number of slave devices can theoretically be attached to the same bus. Both SDA and SCL lines are required to be open-drain lines. As a result, devices can only pull each line low. A pull-up resistor is required on each line to pull the line back up to high.
I2C connections for multiple master and multiple slave devices
Because of the open-drain design, I2C supports multiple masters on the same bus. If two devices start transmitting at the same time, one of them will eventually back off in a process known as "arbitration." Devices monitor the SDA line while they communicate. If a device sees that the SDA line is low when it is trying to transmit a logic high, it knows that another device is trying to communicate, and it will stop transmitting.
To begin communication, a master device will issue a START condition, where the SDA line is pulled low while the SCL line is still high. The master then sends out the 7-bit address of the intended recipient on the bus, followed by a write bit (0) or read bit (1). If a device on the bus has that particular address, it will respond by pulling the SDA line low (ACK bit).
Data can then be sent by the master or peripheral device in packets of 1 byte at a time; each byte should be acknowledged by the recipient with an ACK bit. Once communication is complete, the master will issue a STOP condition by releasing the SDA line (which will be pulled high) while SCL is high.
Data rate was originally limited to 100 kbps (standard mode). In 1992, Philips raised the speed cap to 400 kbps (fast mode). A special 3.4 Mbps mode (high-speed mode) was added 6 years later. A special set of commands must be given at lower speeds between master and peripheral to set up a high-speed connection.
While any number of devices can be physically attached to an I2C bus, the 7-bit address limits the actual number of devices. Some of the addresses are reserved, and therefore, only 112 different devices can be present on the same bus. A special 10-bit addressing mode can be enabled to allow for more devices, if necessary.
I2C has a form of flow control known as "clock stretching." A peripheral device can hold the SCL line low, which tells the master device to slow the transmission rate. This technique allows the peripheral some time to process data before responding.
Due to the low pin count required by I2C, many sensor manufacturers use this protocol in their chips. For example, temperature sensors, accelerometers, analog-to-digital converters, etc. can be found with I2C.

Comparison

?
SPI
I2C
Pin drive
Push-pull
Open drain
Signal lines
4(每增加一個(gè)外設(shè)加 1)
2個(gè)
最大速度
無(wú)限制(10-100 Mbps 很常見(jiàn))
快速模式下為 400 kbps(高速模式下可能達(dá)到 3.4 Mbps)
外圍設(shè)備數(shù)量
僅受主機(jī)上 SS 線路可用的引腳數(shù)量限制
112 7 位尋址
多主機(jī)
是的
流量控制
是的

結(jié)論

這兩種協(xié)議都適用于許多不同的應(yīng)用。大多數(shù)情況下,您只能使用特定部件的制造商實(shí)施的協(xié)議。有一些,如Analog Devices ADXL345加速度計(jì),在同一個(gè)芯片上同時(shí)提供I2C和SPI接口。
如果您必須在兩人間做選擇,如果您需要更快的傳輸速度,SPI通常是更好的工具。另外一方面,如果您的微控制器或微控制器處理器上的可用引腳有限公司,那么I2C是最佳選擇。
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Introduction to I2C and SPI protocols
I2C和SPI總線對(duì)比
【硬件】硬件基礎(chǔ)小知識(shí) 之 SPI總線 (簡(jiǎn)潔要點(diǎn))
一直蒙圈的SPI四種模式,你知道嗎?
Understanding LVDS for Digital Test Systems -...
Direct memory access
更多類(lèi)似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服