Serial Interfaces I2C, Spi, I2S
Serial Interfaces I2C, Spi, I2S
http://www.youtube.com/watch?v=wGt2v54zqAk&feature=relmfu
http://www.youtube.com/watch?v=UJlgND6sWHk&feature=related
https://circuitdigest.com/article/introduction-to-bit-banging-spi-communication-in-arduino-via-bit-banging
Introduction
I2C & SPI
• Fundamentally, the use of pull-ups to set a logic one limits the maximum speed of the bus.
This may be a limiting factor for many applications. This is why the 3.4 Mbps high speed
mode was introduced. Prior to using this mode, the bus master must issue a specific
‘High Speed Master’ code at a lower speed mode.
I2C Protocol
I2C Protocol
1. Master sends start condition (S) and controls the clock signal
2. Master sends a unique 7-bit slave device address
3. Master sends read/write bit (R/W) – 0 - slave receive,
1 - slave transmit
4. Receiver sends acknowledge bit (ACK)
5. Transmitter (slave or master) transmits 1 byte of data
I2C Protocol (cont.)
Disadvantages:
• The complexity of supporting software components can be higher
than that of competing schemes ( for example, SPI ).
Special Addresses
• general call 0000 000 0
• start byte 0000 000 1
• CBUS address 0000 001 * – used for
cooperation of I2C and CBUS
• High-speed mode master code 0000 1** *
• 10-bit slave addressing 1111 0** *
• In a 10-bit addressing system, two frames are required to transmit the slave
address.
• The first frame will consist of the code b11110xyz, where ‘x’ is the MSB (bit 9) of
the slave address, y is bit 8 of the slave address, and z is the read/write bit as
described above.
• The first frame’s ACK bit will be asserted by all slaves which match the first two bits
xy of the address. As with a normal 7-bit transfer, another transfer begins
immediately, and this transfer contains bits 7:0 of the address. At this point, the
addressed slave should respond with an ACK bit.
If it doesn’t, the failure mode is the same as a 7-bit system.
• Note that 10-bit address devices can coexist with 7-bit address devices, since the
leading ‘11110’ part of the address is not a part of any valid 7-bit addresses.
Philips I2C Logic Devices
Applications:
• Like I2C, used in EEPROM, Flash, ADC, real time clocks, …
• Better suited for “data streams”, i.e. ADC converters
• Full duplex capability, i.e. communication between a codec and
digital signal processor (DSP)
SPI Bus Configuration
0 0 Rising
0 1 Falling
1 0 Falling
1 1 Rising
SPI Protocol (cont.)
Disadvantages SPI:
- Use multiple threads;
- No support for Addressing devices;
- Need one Slave Select signal for each slave
- No flow control and acknowledgment slave (master can "empty
talk“ without knowing).
- Supports only one master
I2C vs SPI
• Both standards are successfully used for communication with slow peripherals that
are accessed intermittently (EEPROM's and real-time clocks are examples of
devices such).
• SPI is more appropriate than I2C for applications that use data streams (as opposed
to where the read/write various locations in slave device). An example application
that uses data stream is communication between the microprocessor or DSPs (digital
signal processors).
• SPI can achieve significantly higher data rates than I2C (SPI interfaces can operate
at tens of MHz)
• SPI is especially effective in applications that use the ability to perform full duplex
connections, such as communication between a "codec" (coder-decoder) and a DSP,
which involves sending of samples in both directions.
• Because there is no built-in support for the devices addressing, SPI requires more
effort and more hardware resources than I2C when you have more slaves.
• SPI is simpler and more efficient in point-to-point applications (single master, single
slave) for the same reasons: lack of device addressing means less overhead.
Summary
• Two-wire serial protocol with addressing capability – SCL, SDA
• Half-duplex, synchronous, multi-master bus, multi-slaves
• Speeds up to 3.4 Mbps (ultra-fast 5Mbps)
• Open collector bus driver, Pull-up resistors
• SPI – a 4-wire serial bus (but not official “standard”) - MOSI, MISO, SS/CS, and SCLK signals
• SCLK
• Full-duplex operation
• One master, Multiple slaves
• Best for point-to-point data transfers
• Easily supported, broadly used
I2C:
References
• http://www-us2.semiconductors.philips.com/acrobat/various/
I2C_BUS_SPECIFICATION_1995.pdf
• http://www.esacademy.com/faq/i2c/index.htm
• http://www.embedded.com/story/OEG20020528S0057
• http://www.esacademy.com/faq/i2c/
• http://www.i2cchip.com/
SPI:
• MC68HC11 manual
• http://www.mct.net/faq/spi.html
• http://links.epanorama.net/links/serialbus.html
• http://www.embedded.com/story/OEG20020124S0116
http://shepherdingelectrons.blogspot.com/2
018/09/esp8266-minimum-i2s-code.html
https://www.arduino.cc/en/Tutorial/I2SSimpleTone
I2S is optimized for digital audio data transmission
– 3-line serial bus lines
• SD: Two time-multiplexed data channels
• WS: Word Select (0=left channel, 1 = right channel)
• SCK: Clock
– Bus master generates SCK and WS
– Bus master = transmitter or separate controller
– SCK synchronizes transmitter and receiver
• Serial data format
• Two’s complement, MSB sent first
– If system word > #transmitted bits, truncate after LSB
– If system word < #transmitted bits, add 0’s after LSB
I2S Config. / Timing
• A I2S data flow can transport 1 or 2 data channels with a typical bit
rate between 512 kHz for a sampling rate of 8 kHz and 12.288 MHz,
for a sampling rate of 192 kHz.
• The data word length may be of 16, 24 or 32 de bits