PIC18C242 MICROCHIP [Microchip Technology], PIC18C242 Datasheet - Page 121

no-image

PIC18C242

Manufacturer Part Number
PIC18C242
Description
High-Performance Microcontrollers with 10-Bit A/D
Manufacturer
MICROCHIP [Microchip Technology]
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC18C242-I/SO
Manufacturer:
MICROCHIP
Quantity:
2 000
Part Number:
PIC18C242/JW
Manufacturer:
NS
Quantity:
10
14.2.1
The SPI mode allows 8-bits of data to be synchro-
nously transmitted and received simultaneously. All
four modes of SPI are supported. To accomplish com-
munication, typically three pins are used:
• Serial Data Out (SDO) - RC5/SDO
• Serial Data In (SDI) - RC4/SDI/SDA
• Serial Clock (SCK) - RC3/SCK/SCL/LVOIN
Additionally a fourth pin may be used when in a slave
mode of operation:
• Slave Select (SS) - RA5/SS/AN4
14.2.1.1
When initializing the SPI, several options need to be
specified. This is done by programming the appropriate
control bits (SSPCON1<5:0>) and SSPSTAT<7:6>.
These control bits allow the following to be specified:
• Master Mode (SCK is the clock output)
• Slave Mode (SCK is the clock input)
• Clock Polarity (Idle state of SCK)
• Data input sample phase (middle or end of data
• Clock edge (output data on rising/falling edge of
• Clock Rate (Master mode only)
• Slave Select Mode (Slave mode only)
Figure 14-1 shows the block diagram of the MSSP
module, when in SPI mode.
output time)
SCK)
7/99 Microchip Technology Inc.
SPI Mode
OPERATION
Preliminary
FIGURE 14-1: MSSP BLOCK DIAGRAM
The MSSP consists of a transmit/receive Shift Register
(SSPSR) and a buffer register (SSPBUF). The SSPSR
shifts the data in and out of the device, MSb first. The
SSPBUF holds the data that was written to the SSPSR,
until the received data is ready. Once the 8 bits of data
have been received, that byte is moved to the SSPBUF
register.
(SSPSTAT<0>), and the interrupt flag bit, SSPIF, are
set. This double buffering of the received data (SSP-
BUF) allows the next byte to start reception before
reading the data that was just received. Any write to the
SSPBUF register during transmission/reception of data
will be ignored, and the write collision detect bit, WCOL
(SSPCON1<7>), will be set. User software must clear
the WCOL bit so that it can be determined if the follow-
ing write(s) to the SSPBUF register completed suc-
cessfully.
SDO
SCK
SDI
SS
Then
Read
SS Control
Select
SMP:CKE
Edge
(SPI MODE)
the
Enable
bit0
Select
Edge
SSPBUF reg
TRIS bit
Data to TX/RX in SSPSR
2
SSPM3:SSPM0
SSPSR reg
buffer
PIC18CXX2
Clock Select
4
2
full
DS39026B-page 121
Write
Prescaler
4, 16, 64
detect
clock
(
shift
TMR2 output
data bus
Internal
2
bit,
T
OSC
)
BF

Related parts for PIC18C242