CHAPTER7

SPI

This chapter discusses the following functions of the SPI library:

  • begin()
  • end()
  • setBitOrder()
  • setDataMode()
  • setClockDivider()
  • transfer()

The hardware needed to use these functions includes:

  • Arduino Due
  • Adafruit MAX31855 breakout board
  • Type-K thermocouple wire, from Adafruit Industries

You can find the code download for this chapter at http://www.wiley.com/go/arduinosketches on the Download Code tab. The code is in the Chapter 7 folder and the filename is Chapter7.ino.

Introducting SPI

Serial data connections have been the backbone for computer communication systems for decades. Reliable and sufficiently fast for most devices, they have been used to communicate with modems, IC programmers, and computer-to-computer communications for most of computing's history. They use few wires compared to other communications systems and are generally robust—qualities that are useful for embedded systems and peripherals.

Serial communications are also used deep inside embedded systems where space is critical. Instead of connecting a device to a 32-bit data bus, a simple temperature sensor can, instead, be connected to the microcontroller via just a few wires. It makes design simpler, cheaper, and more efficient.

Although serial connections have a lot of advantages, they also have disadvantages. Having a modem and a programmer requires a computer with two serial ports; a serial port cannot (easily) handle multiple devices. One serial port, one device. This is the same for microcontrollers ...

Get Arduino Sketches: Tools and Techniques for Programming Wizardry now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.