Lab 8-MPMC
Lab 8-MPMC
The interconnection between two SPI devices always happens between a master
device and a slave device. Compared to some peripheral devices like sensors, which
can only run in slave mode, the SPI of the AVR can be configured for both master and
slave mode. The mode the AVR is running in is specified by the settings of the master
bit (MSTR) in the SPI control register (SPCR). Special considerations about the SS pin
must be considered for Multi Slave Systems. The master is the active part in this system
and must provide the clock signal a serial data transmission is based on. The slave is
not capable of generating the clock signal and thus cannot get active on its own. The
slave just sends and receives data, if the master generates the necessary clock signal.
The master, however, generates the clock signal only while sending data. That means
the master must send data to the slave to read data from the slave.
SPSR Register:
SPSR: SPIF WCOL - - - - - SPI2X
◼ SPIF (SPI Interrupt Flag)
A serial transfer is completed.
The SS pin is driven low in slave mode
WCOL (Write Collision)
SPI2X (Double SPI Speed)
SPCR Register:
SPCR: SPIE SPE DORD MSTR CPOL CPHA SPR1 SPR0
Example 2:
When push button at Master side is pressed, white LED at slave side turns ON. And
when the push button at Slave side is pressed, Red LED at Master side turns ON.