Datasheet
PIC12(L)F1822/PIC16(L)F1823
DS41413C-page 238 2010-2012 Microchip Technology Inc.
The MSSP1 consists of a transmit/receive shift register
(SSP1SR) and a buffer register (SSP1BUF). The
SSP1SR shifts the data in and out of the device, MSb
first. The SSP1BUF holds the data that was written to
the SSP1SR until the received data is ready. Once the
eight bits of data have been received, that byte is
moved to the SSP1BUF register. Then, the Buffer Full
Detect bit, BF of the SSP1STAT register, and the
interrupt flag bit, SSP1IF, are set. This double-buffering
of the received data (SSP1BUF) allows the next byte to
start reception before reading the data that was just
received. Any write to the SSP1BUF register during
transmission/reception of data will be ignored and the
write collision detect bit, WCOL, of the SSP1CON1
register, will be set. User software must clear the
WCOL bit to allow the following write(s) to the
SSP1BUF register to complete successfully.
When the application software is expecting to receive
valid data, the SSP1BUF should be read before the
next byte of data to transfer is written to the SSP1BUF.
The Buffer Full bit, BF of the SSP1STAT register,
indicates when SSP1BUF has been loaded with the
received data (transmission is complete). When the
SSP1BUF is read, the BF bit is cleared. This data may
be irrelevant if the SPI is only a transmitter. Generally,
the MSSP1 interrupt is used to determine when the
transmission/reception has completed. If the interrupt
method is not going to be used, then software polling
can be done to ensure that a write collision does not
occur.
The SSP1SR is not directly readable or writable and
can only be accessed by addressing the SSP1BUF
register. Additionally, the SSP1STAT register indicates
the various Status conditions.
FIGURE 25-5: SPI MASTER/SLAVE CONNECTION
Serial Input Buffer
(BUF)
Shift Register
(SSP1SR)
MSb
LSb
SDO
SDI
Processor 1
SCK
SPI Master SSP1M<3:0> = 00xx
Serial Input Buffer
(SSP1BUF)
Shift Register
(SSP1SR)
LSb
MSb
SDI
SDO
Processor 2
SCK
SPI Slave SSP1M<3:0> = 010x
Serial Clock
SS
Slave Select
General I/O
(optional)
= 1010