Hardware Reference
In-Depth Information
an asynchronous serial port on your microcontroller. It
means you can still use the serial port for debugging or
communicating with other devices.
uses an Ethernet chip from WizNet, the W5100. This shield
has a built-in SD memory card slot as well, like the Arduino
Ethernet board. The Adafruit Ethernet shield also uses the
W5100 chip, or it can use the Lantronix serial-to-Ethernet
modules mentioned earlier. The projects in this chapter
will work with the Arduino Ethernet, with the Arduino
Ethernet shield, or with the Adafruit Ethernet shield with
the W5100 module, which are shown in Figure 4-2. They
will not work with the Lantronix module, however.
X
There are two options for Ethernet connections to an
Arduino. One is the Arduino Ethernet board, which is an
Arduino board that has an Ethernet module on the board
itself. The Ethernet connector replaces the USB connector
found on the standard Arduinos. To program this board,
you also need an FTDI-style USB-to-Serial adapter. The
other option is an add-on board for regular Arduino
modules, called an Ethernet shield. There are a few
versions of it on the market. The Arduino Ethernet shield
Introducing Serial Peripheral Interface (SPI)
The Ethernet shield and Arduino Ethernet communicate
with their Ethernet controllers using a form of synchronous
serial communication called Serial Peripheral Interface , or
SPI . SPI, along with another synchronous serial protocol,
Inter-Integrated Circuit or I2C (sometimes called Two-Wire
Interface , or TWI ), are two of the most common synchro-
nous serial protocols you'll encounter.
If the slave doesn't need to send any data to the master,
there will be no MISO pin.
The Arduino SPI library uses pin 11 for MOSI, pin 12 for
MISO, and pin 13 for Clock. Pin 10 is the default Chip Select
pin, but you can use others, as you'll see. For example, the
Arduino Ethernet and Ethernet shield have two slave devices
on their SPI bus: the WizNet chip and the SD card. They are
both connected to pins 11, 12, and 13 for MISO, MOSI, and
Clock. The WizNet module uses pin 10 for its Chip Select,
while the SD card uses pin 4 for its Chip Select.
+5V
RX
CTS
RTS
NC
NC
Synchronous serial protocols all feature a controlling device
that generates a regular pulse, or clock s i gnal, on one pin
while exchanging data on every clock pul s e (see Chapter 2).
The advantage of a synchronous serial protocol is that it's a
bus: you can have several devices sharin g the same physical
connections to one master controller. Each protocol imple-
ments the bus in a different way.
Master
Slave 1
Chip Select 1
CS
MOSI
MISO
CLK
SPI connections have three or four connections between
the controlling device (or master device) and the peripheral
device (or slave), as follows:
MOSI
MISO
Clock
Chip Select 2
Clock : The pin that the master pulses regularly.
Master Out, Slave In (MOSI) : The master device sends a bit
of data to the slave on this line every clock pulse.
Master In, Slave Out (MISO) : The slave device sends a bit of
data to the master on this line every clock pulse.
Slave Select (SS) or Chip Select (CS) : Because several
slave devices can share the same bus, each has a unique
connection to the master. The master sets this pin low to
address this particular slave device. If the master's not
talking to a given slave, it will set the slave's select pin
high.
Slave 2
CS
MOSI
MISO
CLK
Search WWH ::




Custom Search