Microchip Technology DM183037 Data Sheet

Page of 696
PIC18F97J94 FAMILY
DS30575A-page 372
 2012 Microchip Technology Inc.
20.5
I
2
C Mode
The MSSPx module in I
2
C™ mode fully implements all
master and slave functions (including general call
support), and provides interrupts on Start and Stop bits
in hardware to determine a free bus (multi-master
function). The MSSPx module implements the standard
mode specifications, as well as 7-bit and 10-bit
addressing.
Two pins are used for data transfer: 
• Serial Clock (SCLx) – RC3/SCL1 or RD6/SCL2
• Serial Data (SDAx) – RC4/SDA1 or RD5/SDA2
The user must configure these pins as inputs by setting
the associated TRIS bits.
FIGURE 20-7:
MSSPx BLOCK DIAGRAM 
(I
2
C™ MODE)      
20.5.1
REGISTERS
The MSSPx module has seven registers for I
2
C
operation. These are: 
• MSSPx Control Register 1 (SSPxCON1)
• MSSPx Control Register 2 (SSPxCON2)
• MSSPx Control Register 3 (SSPxCON3)
• MSSPx Status Register (SSPxSTAT)
• Serial Receive/Transmit Buffer Register 
(SSPxBUF)
• MSSPx Shift Register (SSPxSR) – Not directly 
accessible
• MSSPx Address Register (SSPxADD)
• I
2
C Slave Address Mask Register (SSPxMSK)
SSPxCON1, SSPxCON2, SSPxCON3 and SSPxSTAT
are the control and status registers in I
2
C mode opera-
tion. The SSPxCON1, SSPxCON2, and SSPxCON3
registers are readable and writable. The lower 6 bits of
the SSPxSTAT are read-only. The upper two bits of the
SSPxSTAT are read/write.
SSPxSR is the shift register used for shifting data in or
out. SSPxBUF is the buffer register to which data bytes
are written to or read from.
SSPxADD contains the slave device address when the
MSSPx is configured in I
2
C Slave mode. When the
MSSPx is configured in Master mode, the lower seven
bits of SSPxADD act as the Baud Rate Generator
reload value. 
SSPxMSK holds the slave address mask value when
the module is configured for 7-Bit Address Masking
mode. While it is a separate register, it shares the same
SFR address as SSPxADD; it is only accessible when
the SSPM<3:0> bits are specifically set to permit
access. Additional details are provided in
In receive operations, SSPxSR and SSPxBUF
together, create a double-buffered receiver. When
SSPxSR receives a complete byte, it is transferred to
SSPxBUF and the SSPxIF interrupt is set.
During transmission, the SSPxBUF is not double-
buffered. A write to SSPxBUF will write to both
SSPxBUF and SSPxSR. 
Read
Write
Match Detect
SSPxADD reg
SSPxBUF reg
Internal
Data Bus
Addr Match
Set, Reset
S, P bits
(SSPxSTAT reg)
Shift
Clock
MSb
LSb
Note:
Only port I/O names are used in this diagram
for the sake of brevity. Refer to the text for a
full list of multiplexed functions.
SCKx
SDIx
Start and
Stop bit Detect
Address Mask
SSPxSR reg