Professional Documents
Culture Documents
DSP
OVERVIEW OF SPI MODULE
Includes:
Pins: SPISOMI, SPISIMO, SPISTE, SPICLK
Two operational modes: master and slave
125 different programmable baud rates
(SPIBRR register)
Four clocking schemes
Programmable data word length ( 1 to 16)
Simultaneous receive and transmit operation:
accomplished through either interrupt-driven or
polled algorithms.
12 SPI module control registers (16-bit)
SPI OPERATION
MASTER/SLAVE bit
(SPICTL.2) selects the
operating mode and
source of SPICLK signal.
The master initiates data transfer by sending the SPICLK signal.
For both the slave and the master, data is shifted out of the shift registers on one edge of
the SPICLK and latched into the shift register on the opposite SPICLK clock edge.
The master can initiate data transfer at any time because it controls the SPICLK signal.
MASTER MODE (BIT MASTER/SLAVE = 1)
SPI provides the serial clock on SPICLK pin
Data output – SPISIMO pin and latched from – SPISOMI pin
Data in Bits gets transferred after SPIDAT have shifted its bits To network when
SPIDAT SPICLK signal is
SPITXBUF OTHERWISE
If no character is being transmitted, after writing to received from
SPITXBUF is done , transferring to SPIDAT takes place network master
immediately
To receive data SPI waits until SPICLK signal is received from network
master data in on SPISIMO pin to SPIDAT.
TALK bit (SPICTL.1)
If equal to 0
SPI INT FLAG bit (SPISTS.6) : indicates that a character is placed in SPI receiver buffer and is ready to
be read.
OVERRUN INT ENA bit (SPICTL.4) : allows assertion of an interrupt whenever SPISTS.7 bit is et by
hardware.
RECEIVER OVERRUN FLAG BIT (SPISTS.7): set, whenever a new character is received and loaded into
the SPIRXBUF.
DATA FORMAT
Four bits of SPICCR (D0-D3) – specifies the no. of bits in the data character.
If characters are less than 16, then following should be noted:
Data must be left-justified when written to SPIDAT and SPITXBUF
Data read back from SPIRXBUF is right-justified
SPIRXBUF contains the most recently received character, right-justified, plus any bits that remain from
previous transmission(s) that have been shifted to the left
CLOCKING SCHEMES
Bits CLOCK POLARITY bit (SPICCR.6) and CLOCK PHASE bit (SPICTL.3) controls four
different clocking schemes.
CLOCK POLARITY bit- selects active edge, either rising or falling
CLOCK PHASE bit – selects half-cycle delay
They are:
Falling Edge Without Delay
Falling Edge With Delay
Rising Edge Without Delay
Rising Edge With Delay
SPI CONTROL REGISTERS
THE SPI IS CONTROLLED AND ACCESSED THROUGH REGISTERS IN THE CONT ROL REGISTER FILE.
SPI SW CLOCK Reserved SPILBK SPI CHAR3 SPI CHAR2 SPI CHAR1 SPI CHAR0
Reset POLARITY
Reserved SPI BIT SPI BIT SPI BIT SPI BIT SPI BIT SPI BIT SPI BIT
RATE 6 RATE 5 RATE 4 RATE 3 RATE 2 RATE 1 RATE 0
Baud Rate
Determination:
6) SPI Serial Receive Buffer Register (SPIRXBUF)
SPIRXBUF contains the received data. Reading SPIRXBUF clears the SPI INT FLAG bit (SPISTS.6).
In master mode, if no transmission is currently active, writing to this register initiates a transmission in the
same manner that writing to SPIDAT does