Inter-Integrated Circuit (I2C) PDF
Inter-Integrated Circuit (I2C) PDF
HIGHLIGHTS
This section of the manual contains the following major topics:
Note: This family reference manual section is meant to serve as a complement to device
data sheets. Depending on the device variant, this manual section may not apply to
all PIC24 and dsPIC33 devices.
Please consult the note at the beginning of the “Inter-Integrated Circuit™ (I2C™)”
chapter in the current device data sheet to check whether this document supports
the device you are using.
Device data sheets and family reference manual sections are available for
download from the Microchip Worldwide Web site at: http://www.microchip.com.
This document supersedes the following PIC24 and dsPIC® DSC Family Reference Manual sections:
1.0 INTRODUCTION
The Inter-Integrated Circuit™ (I2C™) module is a serial interface useful for communicating with
other peripheral or microcontroller (MCU) devices. The external peripheral devices may be serial
EEPROMs, display drivers, Analog-to-Digital Converters (ADC) and so on.
The I2C module can operate as any one of the following in the I2C system:
• Slave device
• Master device in a single master system (slave may be active)
• Master or slave device in a multi-master system (bus collision detection and arbitration are
available)
The I2C module contains an independent I2C master logic and a I2C slave logic, which generates
interrupts based on their events. In the multi-master systems, the user software is simply
partitioned into the master controller and the slave controller.
When the I2C master logic is active, the slave logic also remains active, detecting the state of the
bus and potentially receiving messages from itself in a single master system or from the other
masters in a multi-master system. No messages are lost during the multi-master bus arbitration.
In a multi-master system, the bus collision conflicts with the other masters in the system when
detected and the module provides a method to terminate and then restart the message.
The I2C module contains a Baud Rate Generator (BRG). The I2C BRG does not consume other
timer resources in the device. Figure 1-1 illustrates the I2C module block diagram.
Key features of the I2C module include the following:
• Independent master and slave logic
• Multi-master support which prevents message losses in arbitration
• Detects 7-bit and 10-bit device addresses with configurable address masking in Slave mode
• Detects general call addresses as defined in the I2C protocol
• Bus Repeater mode allowing the module to accept all messages as a slave, irrespective of
the address
• Automatic SCLx clock stretching provides delays for the processor to respond to a slave
data request
• Supports 100 kHz and 400 kHz bus specifications
• Supports the Intelligent Platform Management Interface (IPMI) standard
• Supports SDAx hold time for SMBus (300 nS or 150 nS) in Slave mode
Note: For more information, refer to the SDAHT bit description in the specific device data sheet.
I2CxRCV
Read
Shift
SCLx Clock
I2CxRSR
LSB
I2CxMSK
Write Read
I2CxADD
Read
Write
Start and Stop
Bit Detect
I2CxSTAT
Start and Stop
Bit Generation Read
Write
Control Logic
Collision
Detect I2CxCONH
Read
Write
Acknowledge
Generation
I2CxCONL
Clock
Stretching Read
Write
I2CxTRN
LSB
Read
Shift Clock
Reload
Control
Write
BRG
I2CxBRG
Down Counter
Read
TCY or TCY/2(1)
Note 1: Refer to specific device data sheet for the clock rate.
VDD VDD
dsPIC33/PIC24 24LC256
2.2 k
(typical)
SCLx SCL
SDAx SDA
NACK
SDAx
ACK
Figure 2-3: A Typical I2C™ Message: Read of Serial EEPROM (Random Address Mode)
Restart
NACK
Address EEPROM Address EEPROM Address Address Data
ACK
ACK
ACK
ACK
Start
Stop
R/W
R/W
Bus
Idle
Idle
Byte High Byte Low Byte Byte Byte
Activity
Master
SDAx S 1 0 1 0 A A A 0 X R 1 0 1 0 A AA1 N P
2 1 0 2 1 0
Output
Slave
SDAx A A A A
Output
The transmit data is written to the I2CxTRN register. This register is used when the module
operates as a master transmitting data to the slave or when it operates as a slave sending reply
data to the master. As the message progresses, the I2CxTRN register shifts out the individual
bits. Therefore, the I2CxTRN register cannot be written to unless the bus is Idle.
The data being received by either the master or the slave is shifted into a non-accessible shift
register, I2CxRSR. When a complete byte is received, the byte transfers to the I2CxRCV register.
In receive operations, the I2CxRSR and I2CxRCV registers create a double-buffered receiver.
This allows reception of the next byte to begin before reading the current byte of the received
data.
If the module receives another complete byte before the user software reads the previous byte
from the I2CxRCV register, a receiver overflow occurs and sets the I2COV bit (I2CxSTAT<6>).
The byte in the I2CxRSR register is lost if (BOEN = 0). Further reception and clock stretching
are disabled until the I2C module sees a Start/Repeated, Start/Stop condition on the bus. If the
I2COV flag has been cleared, the reception can proceed normally. If the I2COV flag is not
cleared, the module will receive the next byte correctly, but will send a NACK. It will then be
unable to receive further bytes or stretch the clock until it detects a Start/Repeated and Start/Stop
condition.
The I2CxADD register holds the slave device address. In 10-Bit Addressing mode, all bits are
relevant. In 7-Bit Addressing mode, only the I2CxADD<6:0> bits are relevant. The
I2CxADD<6:0> bits correspond to the upper 7 bits in the address byte. The read/write bit is not
included in the value in this register. The A10M bit (I2CxCON<10> or I2CxCONL<10>) specifies
the expected mode of the slave address. By using the I2CxMSK register with the I2CxADD reg-
ister in Slave Addressing mode, one or more bit positions can be removed from the exact
address matching, allowing the module, in Slave mode, to respond to multiple addresses.
Note 1: The IPMIEN bit should not be set when the I2C module is operating as a master.
bit 5 ACKDT: Acknowledge Data bit (I2C Master mode; receive operation only)
Value that will be transmitted when the user software initiates an Acknowledge sequence.
1 = Sends a NACK during an Acknowledge
0 = Sends an ACK during an Acknowledge
bit 4 ACKEN: Acknowledge Sequence Enable bit (I2C Master mode receive operation)
1 = Initiates the Acknowledge sequence on the SDAx and SCLx pins and transmits the ACKDT data bit
(hardware clears at the end of the master Acknowledge sequence)
0 = Acknowledge sequence is not in progress
bit 3 RCEN: Receive Enable bit (I2C Master mode)
1 = Enables Receive mode for I2C (hardware clears at the end of eighth bit of master receive data byte)
0 = Receive sequence is not in progress
bit 2 PEN: Stop Condition Enable bit (I2C Master mode)
1 = Initiates the Stop condition on the SDAx and SCLx pins (hardware clears at the end of master Stop
sequence)
0 = Stop condition is not in progress
bit 1 RSEN: Repeated Start Condition Enable bit (I2C Master mode)
1 = Initiates the Repeated Start condition on the SDAx and SCLx pins (hardware clears at the end of
master Repeated Start sequence)
0 = Repeated Start condition is not in progress
bit 0 SEN: Start Condition Enable bit (I2C Master mode)
1 = Initiates the Start condition on the SDAx and SCLx pins (hardware clears at the end of master Start
sequence)
0 = Start condition is not in progress
Note 1: The IPMIEN bit should not be set when the I2C module is operating as a master.
Note 1: Automatically cleared to ‘0’ at the beginning of the slave transmission; automatically cleared to ‘0’ at the
end of the slave reception.
2: Automatically cleared to ‘0’ at the beginning of the slave transmission.
bit 7 GCEN: General Call Enable bit (I2C Slave mode only)
1 = Enables the interrupt when a general call address is received in I2CxRSR; the module is enabled for
reception
0 = General call address is disabled
bit 6 STREN: SCLx Clock Stretch Enable bit
In I2C Slave mode only; used in conjunction with the SCLREL bit.
1 = Enables clock stretching
0 = Disables clock stretching
bit 5 ACKDT: Acknowledge Data bit
In I2C Master mode during Master Receive mode. The value that will be transmitted when the user
initiates an Acknowledge sequence at the end of a receive.
In I2C Slave mode when AHEN = 1 or DHEN = 1. The value that the slave will transmit when it initiates
an Acknowledge sequence at the end of an address or data reception.
1 = NACK is sent
0 = ACK is sent
bit 4 ACKEN: Acknowledge Sequence Enable bit
In I2C Master mode only; applicable during Master Receive mode.
1 = Initiates the Acknowledge sequence on the SDAx and SCLx pins, and transmits the ACKDT data bit
0 = Acknowledge sequence is in Idle mode
bit 3 RCEN: Receive Enable bit (I2C Master mode only)
1 = Enables Receive mode for I2C; automatically cleared by hardware at the end of an 8-bit receive
data byte
0 = Receive sequence is not in progress
bit 2 PEN: Stop Condition Enable bit (I2C Master mode only)
1 = Initiates the Stop condition on the SDAx and SCLx pins
0 = Stop condition is in Idle mode
bit 1 RSEN: Restart Condition Enable bit (I2C Master mode only)
1 = Initiates the Restart condition on the SDAx and SCLx pins
0 = Restart condition is in Idle mode
bit 0 SEN: Start Condition Enable bit (I2C Master mode only)
1 = Initiates the Start condition on the SDAx and SCLx pins
0 = Start condition is in Idle mode
Note 1: Automatically cleared to ‘0’ at the beginning of the slave transmission; automatically cleared to ‘0’ at the
end of the slave reception.
2: Automatically cleared to ‘0’ at the beginning of the slave transmission.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
R-0, HSC R-0, HSC R-0, HSC U-0 U-0 R/C-0, HS R-0, HSC R-0, HSC
(1)
ACKSTAT TRSTAT ACKTIM — — BCL GCSTAT ADD10
bit 15 bit 8
R/C-0, HS R/C-0, HS R-0, HSC R-0, HSC R-0, HSC R-0, HSC R-0, HSC R-0, HSC
IWCOL I2COV D/A P S R/W RBF TBF
bit 7 bit 0
Note 1: Refer to the specific device data sheet for availability of the ACKTIM bit.
Note 1: Refer to the specific device data sheet for availability of the ACKTIM bit.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at Reset ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: This register is not available on all devices. Refer to the specific device data sheet for availability.
2: The calibration value must be retrieved from the Flash memory and stored in this location at start-up time.
or
I2CxBRG = --------------
1 - – Delay Fcy – 2. Default
See Note 1 and Note 2
FSCL
Where:
Typical value of delay varies from 110 ns to 130 ns.
Note 1: Refer to the specific device data sheet for BRG reload value calculation.
2: If there is no calculation mentioned in the data sheet, then the default BRG
reload value calculation should be considered.
Note: Equation 4-1 is only for a design guideline. Due to system-dependent parameters,
the actual baud rate may differ slightly. Testing is required to confirm that the actual
baud rate meets the system requirements. Otherwise, the value of the I2CxBRG
register has to be adjusted.
I2CxBRG<8:0>
Reload Reload
SCLx
Control
TSCL
TCY or TCY/2(1) Down Counter TBRG =
2
Note 1: Refer to specific device data sheet for the clock rate.
Figure 5-1: A Typical I2C™ Message: Read of Serial EEPROM (Random Address Mode)
Restart
NACK
Address EEPROM Address EEPROM Address Address Data
ACK
ACK
ACK
ACK
Start
Stop
R/W
R/W
Bus
Idle
Idle
Byte High Byte Low Byte Byte Byte
Activity
Master A A A A A A
SDAx S 1 0 1 0 0 R 1 0 1 0 1 N P
2 1 0 2 1 0
Output
Slave
SDAx A A A A
Output
The I2C module supports Master mode communication with the inclusion of the Start and Stop
generators, data byte transmission, data byte reception, Acknowledge generator and a BRG.
Generally, the user software will write to a control register to start a particular step, then wait for
an interrupt or poll status to wait for completion. These operations are discussed in the
subsequent sections.
Note: The I2C module does not allow queuing of events. For example, the user software
is not allowed to initiate a Start condition, and immediately write the I2CxTRN
register to initiate transmission, before the Start condition is complete. In this case,
the I2CxTRN register will not be written to and the IWCOL status bit (I2CxSTAT<7>)
will be set, indicating that this write to the I2CxTRN register did not occur.
SEN
1 2 3 4
I2CxTRN
I2C™ Bus State (Q) (D) (Q) (D) (Q) (A) (Q)
TBRG TBRG
SCLx (Master)
SCLx (Slave)
SDAx (Master) D7 D6 D5 D4 D3 D2 D1 D0
SDAx (Slave)
TRSTAT
TBF
MI2CxIF Interrupt
ACKSTAT
1 2 3 4 5 6 7 8
1 Writing the I2CxTRN register will start a master transmission event. The TBF status bit is set.
2 The BRG starts. The Most Significant Byte (MSB) of the I2CxTRN register drives SDAx. The SCLx remains low.
The TRSTAT status bit is set.
3 The BRG times out. The SCLx is released and the BRG restarts.
4 The BRG times out. The SCLx is driven low. After SCLx is detected low, the next bit of the I2CxTRN register drives SDAx.
5 While the SCLx is low, the slave can also pull the SCLx low to initiate a Wait (clock stretch).
6 Master has already released SCLx and slave can release to end Wait. The BRG restarts.
7 At the falling edge of the eighth SCLx clock, the master releases SDAx. The TBF status bit is cleared.
The slave drives an ACK/NACK.
8 At the falling edge of the ninth SCLx clock, the master generates the interrupt. The SCLx remains low until the next event.
The slave releases SDAx and the TRSTAT status bit is clear.
After the falling edge of the eighth SCLx clock, the following events occur:
• The RCEN bit is automatically cleared
• The contents of the I2CxRSR register transfer into the I2CxRCV register
• The RBF status bit (I2CxSTAT<1>) is set
• The I2C module generates the MI2CxIF interrupt
When the CPU reads the receive buffer (I2CxRCV), the RBF status bit is automatically cleared.
The user software can process the data and then execute an Acknowledge sequence.
The sequence of events that occurs during master transmission and master reception is
illustrated in Figure 5-4.
RCEN
2
I C™ Bus State (Q) (Q) (D) (Q) (Q) (D) (Q)
TBRG TBRG
SCLx (Master)
SCLx (Slave)
SDAx (Master)
SDAx (Slave) D7 D6 D5 D4 D3 D2 D1 D0
I2CxRCV
RBF
MI2CxIF Interrupt
1 2 3 4 5 6
1 Typically, the slave can pull SCLx low (clock stretch) to request a Wait to prepare the data response.
The slave will drive the MSB of the data response on SDAx when ready.
2 Writing the RCEN bit will start a master reception event. The BRG starts. SCLx remains low.
5 The BRG times out. The MSB of the response is shifted to the I2CxRSR register. SCLx is driven low for the next baud
interval.
6 At the falling edge of the eighth SCLx clock, the I2CxRSR register is transferred to the I2CxRCV register.
The module clears the RCEN bit. The RBF status bit is set. Master generates the interrupt.
Figure 5-5 illustrates an ACK sequence and Figure 5-6 illustrates a NACK sequence. The ACKDT
bit (I2CxCON<5> or I2CxCONL<5>) specifies an ACK or NACK sequence.
After two baud periods, the ACKEN bit is automatically cleared and the module generates the
MI2CxIF interrupt.
ACKDT = 0
1 2 3 4
ACKDT = 1
1 2 3 4
When the PEN bit is set, the master generates the Stop sequence, as illustrated in Figure 5-7.
• The slave detects the Stop condition, sets the P status bit (I2CxSTAT<4>) and clears the
S status bit (I2CxSTAT<3>)
• The PEN bit is automatically cleared
• The module generates the MI2CxIF interrupt
1 2 3 4 5
To generate a Repeated Start condition, the user software sets the RSEN bit (I2CxCON<1> or
I2CxCONL<1>). The master module asserts the SCLx pin low. When the module samples the
SCLx pin low, the module releases the SDAx pin for 1 TBRG. When the BRG times out and the
module samples SDAx high, the module deasserts the SCLx pin. When the module samples the
SCLx pin high, the BRG reloads and begins counting. SDAx and SCLx must be sampled high for
1 TBRG. This action is then followed by assertion of the SDAx pin low for 1 TBRG while SCLx is
high.
The following is the Repeated Start sequence:
1. The slave detects the Start condition, sets the S status bit (I2CxSTAT<3>) and clears the
P status bit (I2CxSTAT<4>).
2. The RSEN bit is automatically cleared.
3. The I2C module generates the MI2CxIF interrupt.
SDAx (Master) 3 The BRG times out. Module drives SDAx low.
BRG restarts.
S
4 Slave logic detects Start. Module sets S = 1 and P = 0.
P
MI2CxIF Interrupt 5 The BRG times out. Module drives SCLx low.
Module clears RSEN. Master generates the interrupt.
1 2 3 4 5
The user software will begin a message by issuing a Start condition. The user software will record
the state number corresponding to the Start.
As each event completes and generates an interrupt, the interrupt handler may check the state
number. Therefore, for a Start state, the interrupt handler will confirm execution of the Start
sequence and then start a master transmission event to send the I2C device address, changing
the state number to correspond to the master transmission.
On the next interrupt, the interrupt handler will again check the state, determining that a master
transmission just completed. The interrupt handler will confirm successful transmission of the
data, then move on to the next event, depending on the contents of the message. In this manner,
on each interrupt, the interrupt handler will progress through the message protocol until the
complete message is sent.
Figure 5-9 provides a detailed examination of the same message sequence as shown in
Figure 5-1. Figure 5-10 provides a few simple examples of the messages using a 7-bit address-
ing format. Figure 5-11 provides an example of a 10-bit addressing format message sending data
to a slave. Figure 5-12 provides an example of a 10-bit addressing format message receiving
data from a slave.
RSEN
RCEN
ACKEN
AKDT
PEN
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
(Master)
A11
A10
SDAx
A9
A8
1 0 1 0 A2 A1 A0 W 0 0 0 0 A7 A6 A5 A4 A3 A2 A1 A0 1 0 1 0 A2 A1 A0 R N
(Master)
SCLx
(Slave)
SDAx A A A A D7 D6 D5 D4 D3 D2 D1 D0
(Slave)
I2CxTRN
TBF
I2CxRCV
RBF
ACKSTAT
MI2CxIF Interrupt Flag Cleared by User Software
MI2CxIF
1 2 3 4 5 6 7 8 9
2007-2014 Microchip Technology Inc.
1 Setting the SEN bit starts a Start event. 6 Writing the I2CxTRN register starts a master transmission. The data is a re-send of
the serial EEPROM device address byte, but with R/W status bit set, indicating a read.
2 Writing the I2CxTRN register starts a master transmission. The data is the serial
EEPROM device address byte, with the R/W status bit clear, indicating a write. 7 Setting the RCEN bit starts a master reception. On interrupt, the user software reads
the I2CxRCV register, which clears the RBF status bit.
3 Writing the I2CxTRN register starts a master transmission. The data is the first
byte of the EEPROM data address. 8 Setting the ACKEN bit starts an Acknowledge event. ACKDT = 1 to send a NACK.
4 Writing the I2CxTRN register starts a master transmission. The data is the second 9 Setting the PEN bit starts a master Stop event.
byte of the EEPROM data address.
5 Setting the RSEN bit starts a Repeated Start event.
Figure 5-10: Master Message (7-Bit Address: Transmission and Reception)
2007-2014 Microchip Technology Inc.
SEN
RSEN
RCEN
ACKEN
AKDT
PEN
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
(Master)
SDAx A7 A6 A5 A4 A3 A2 A1 W D7 D6 D5 D4 D3 D2 D1 D0 A7 A6 A5 A4 A3 A2 A1 R N
(Master)
SDAx A A A D7 D6 D5 D4 D3 D2 D1 D0
(Slave)
I2CxTRN
TBF
I2CxRCV
RBF
ACKSTAT
MI2CxIF Interrupt Flag Cleared by User Software
MI2CxIF
1 2 3 4 5 6 7 8 9
1 Setting the SEN bit starts a Start event. 6 Writing the I2CxTRN register starts a master transmission. The data is the
address byte with the R/W status bit set.
2 Writing the I2CxTRN register starts a master transmission. The data is the
address byte with the R/W status bit clear. 7 Setting the RCEN bit starts a master reception.
DS70000195F-page 31
3 Writing the I2CxTRN register starts a master transmission. The data is the 8 Setting the ACKEN bit starts an Acknowledge event. ACKDT = 1 to send a NACK.
message byte.
4 Setting the PEN bit starts a master Stop event. 9 Setting the PEN bit starts a master Stop event.
5 Setting the SEN bit starts a Start event. An interrupt is generated on completion
of the Start event.
Figure 5-11: Master Message (10-Bit Transmission)
DS70000195F-page 32
RSEN
RCEN
ACKEN
AKDT
PEN
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
(Master)
SDAx 1 1 1 1 0 A9 A8 W A7 A6 A5 A4 A3 A2 A1 A0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
(Master)
SCLx
(Slave)
SDAx A A A A A
(Slave)
I2CxTRN
TBF
I2CxRCV
RBF
ACKSTAT
MI2CxIF Interrupt Flag Cleared by User Software
MI2CxIF
2007-2014 Microchip Technology Inc.
1 2 3 4 5 6 7
1 Setting the SEN bit starts a Start event. 5 Writing the I2CxTRN register starts a master transmission. The data is the second
byte of the message data.
2 Writing the I2CxTRN register starts a master transmission. The data is the first
byte of the address. 6 Writing the I2CxTRN register starts a master transmission. The data is the third
byte of the message data.
3 Writing the I2CxTRN register starts a master transmission. The data is the second
byte of the address. 7 Setting the PEN bit starts a master Stop event.
4 Writing the I2CxTRN register starts a master transmission. The data is the first
byte of the message data.
Figure 5-12: Master Message (10-Bit Reception)
2007-2014 Microchip Technology Inc.
SEN
RSEN
RCEN
ACKEN
AKDT
PEN
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
(Master)
SDAx 1 1 1 1 0 A9 A8 W A7 A6 A5 A4 A3 A2 A1 A0 1 1 1 1 0 A9 A8 R A N
(Master)
SDAx A A A D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
(Slave)
I2CxTRN
TBF
I2CxRCV
RBF
ACKSTAT
MI2CxIF Interrupt Flag Cleared in User Software
MI2CxIF
1 2 3 4 5 6 7 8 9 10
1 Setting the SEN bit starts a Start event. 6 Setting the RCEN bit starts a master reception. On interrupt, the user software reads
the I2CxRCV register, which clears the RBF status bit.
2 Writing the I2CxTRN register starts a master transmission. The data is the first
byte of the address with the R/W status bit cleared. 7 Setting the ACKEN bit starts an Acknowledge event. ACKDT = 0 to send ACK.
DS70000195F-page 33
3 Writing the I2CxTRN register starts a master transmission. The data is the second 8 Setting the RCEN bit starts a master reception.
byte of the address.
4 Setting the RSEN bit starts a master Restart event. 9 Setting the ACKEN bit starts an Acknowledge event. ACKDT = 1 to send NACK.
5 Writing the I2CxTRN register starts a master transmission. The data is a re-send 10 Setting the PEN bit starts a master Stop event.
of the first byte with the R/W status bit set.
dsPIC33/PIC24 Family Reference Manual
6.0 COMMUNICATING AS A MASTER IN A MULTI-MASTER ENVIRONMENT
The I2C protocol allows more than one master to be attached to a system bus. Taking into
account that a master can initiate message transactions and generate clocks for the bus, the
protocol has methods to account for situations where more than one master is attempting to
control the bus. The clock synchronization ensures that multiple nodes can synchronize their
SCLx clocks to result in one common clock on the SCLx line. The bus arbitration ensures that if
more than one node attempts a message transaction, only one node will be successful in
completing the message. The other nodes lose bus arbitration and are left with a bus collision.
Note: The IPMIEN bit (I2CxCON<11>) should not be set when operating as a master.
TBRG TBRG
SDAx (Master)
SCLx (Master)
SCLx (Slave)
Baud Counter 000 003 002 001 000 003 002 001 000 003
TCY
1 2 3 4 5 6
1 The baud counter decrements twice per TCY. On rollover, the master SCLx will transition.
2 The slave has pulled SCLx low to initiate a Wait.
3 At what would be the master baud counter rollover, detecting SCLx low holds counter.
4 Logic samples SCLx once per TCY. Logic detects SCLx high.
TBRG TBRG
1 Master transmits bit value of ‘1’ in next SCLx clock.
SCLx (Master)
Module releases SDAx.
SDAx (Master)
2 Another master on bus transmits bit value of ‘0’
SCLx (Bus) in next SCLx clock. Another master pulls SDAx low.
SDAx (Bus) 3 BRG times out. Module attempts to verify SDAx high.
Bus collision detected.
BCL Module releases SDAx and SCLx. Module sets BCL status bit
and clears the TBF status bit. Master generates the interrupt.
TBF
MI2CxIF Interrupt
1 2 3
10-Bit
Address
Restart
NACK
Address Address Data Address Data
Start
ACK
ACK
ACK
ACK
Stop
R/W
R/W
Bus Byte Byte Byte Byte Byte
Activity R
Master
SDAx S 111 1 0 A A 0 A A AA A A A A R 111 1 0 A A 1 N P
Output 9 8 7 6 5 4 3 2 1 0 9 8
Slave
SDAx A A A A
Output
After a Start condition, the slave receives and checks the device address. The slave can specify
either a 7-bit address or a 10-bit address. When a device address is matched, the module will
generate an interrupt to notify the user software that its device is selected. Based on the R/W
status bit sent by the master, the slave either receives or transmits data. If the slave is to receive
data, the slave automatically generates the Acknowledge (ACK), loads the I2CxRCV register
with the received value currently in the I2CxRSR register and notifies the user software through
an interrupt. If the slave is to transmit data, the user software must load the I2CxTRN register.
Note 1: The SCIE bit may not be available on all devices. Refer to the specific device data sheet for availability.
NACK
SDAx A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SI2CxIF
RBF
ACKDT
SCLREL
ACKTIM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
2007-2014 Microchip Technology Inc.
1 Detecting Start bit enable address detection, interrupt flag is set if SCEN is set. 9 User software clears the interrupt flag.
2 User software clears the interrupt flag. 10 If DHEN = 1, hardware clears SCLREL bit. I2CxRCV is loaded with I2CxRSR,
3 Slave receives the address byte with R/W = 0. Hardware clears the SCLREL. ACKTIM is asserted at the end of 8th falling edge of SCLx by hardware.
Interrupt flag is asserted. ACKTIM is asserted. I2CxRCV is loaded with 11 User software reads I2CxRCV; clears the RBF flag.
I2CxRSR and RBF is asserted.
4 User software clears the interrupt flag. 12 User software releases the SCLREL, ACKTIM is cleared by hardware.
5 User software reads I2CxRCV, that clears the RBF flag. 13 Interrupt flag is set.
6 ACKDT is written with ACK by user software. User software clears the interrupt flag.
14
7 User software sets SCLREL bit to release clock, ACKTIM is cleared by hardware. 15 NACK.
8 Interrupt flag is set (not set if NACK is received). 16 Slave recognizes the Stop event.
Figure 7-4: I2C™ Slave, 7-Bit Address, Reception (STREN = 1, AHEN = 0, DHEN = 0)
2007-2014 Microchip Technology Inc.
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
NACK
R/W = 0
SDAx A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0
SI2CxIF
I2COV
SCLREL
1 2 3 4 5 6 7 8 9 10 11 12 13
1 Detecting Start bit, enables address detection, interrupt is set if SCEN is set. 8 Data is loaded into I2CxRCV. RBR flag is asserted.
2 User software clears the interrupt flag. 9 On the 9th falling clock edge, interrupt is asserted.
3 RBF is set on the 8th falling clock, address is loaded to I2CxRCV. RBF is asserted. 10 SCLx is stretched and held at low until SCLREL is set.
DS70000195F-page 41
4 Interrupt is asserted. 11 User software releases SCLx line by writing SCLREL to ‘1’.
5 SCLx is stretched low until SCLREL is set. 12 NACK is received (SCLx is not stretched to low).
6 User software reads the I2CxRCV buffer that clears the RBF flag. 13 Slave recognizes the Stop event.
Figure 7-5: Slave Read 7-Bit Address Detection Timing Diagram (AHEN = 0)
Note 1: The SCIE bit may not be available in all the devices. Refer to the specific device data sheet for availability.
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
R/W = 1
SDAx A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0
SI2CxIF
TBF
RBF
SCLREL
ACKTIM
1 2 3 4 5 6 7 8 9 10 11 12 13
1 Detecting Start bit, enables address detection, interrupt is set if the SCEN bit is set. 8 Hardware clears SCLREL to suspend master clock if R/W = 1.
2 User software clears the interrupt flag. 9 User software clears the interrupt flag.
3 Slave receives the address byte with R/W = 1. Hardware clears the SCLREL to 10 User software loads the I2CxTRN register with response data. TBF = 1
suspend master clock. ACKTIM and interrupt flag are asserted. indicates that the buffer is full.
4 User software clears the interrupt flag. 11 After last bit, module clears TBF bit, indicating buffer is available for next byte.
DS70000195F-page 43
5 Software reads the I2CxRV register, that clears the RBF flag. 12 At the end of ninth clock, if master sent NACK, no more data is expected.
Module does not suspend the clock.
6 ACKDT is written with ACK.
13 Module recognizes Stop event.
7 User software sets SCLREL to release clock hold. Master clocks in the
Acknowledgment sequence. ACKTIM is cleared by hardware.
dsPIC33/PIC24 Family Reference Manual
7.3.5 10-BIT ADDRESSING MODE
In 10-Bit Addressing mode, the slave must receive two device address bytes, as illustrated in
Figure 7-7. The 5 Most Significant bits (MSbs) of the first address byte specify a 10-bit address.
The R/W status bit of the address must specify a write, causing the slave device to receive the
second address byte. For a 10-bit address, the first byte would equal, ‘11110 A9 A8 0’, where
A9 and A8 are the 2 MSbs of the address.
The I2CxMSK register can mask any bit position in a 10-bit address. The 2 MSbs of the I2CxMSK
register are used to mask the MSbs of the incoming address received in the first byte. The remaining
byte of the register is then used to mask the lower byte of the address received in the second byte.
Following the Start condition, the module shifts eight bits into the I2CxRSR register. The value of
the I2CxRSR<2:1> bits is evaluated against the value of the I2CxADD<9:8> and I2CxMSK<9:8>
bits, while the value of the I2CxRSR<7:3> bits is compared to ‘11110’. Address evaluation
occurs on the falling edge of the eighth SCLx clock. For the address to be valid, the
I2CxRSR<7:3> bits must be equal to ‘11110’, while the I2CxRSR<2:1> bits must exactly match
any unmasked bits in the I2CxADD<9:8> bits (if both bits are masked, a match is not needed). If
the address is valid, the following events occur:
• An ACK is generated
• The D/A and R/W status bits are cleared
• The module generates the SI2CxIF interrupt on the falling edge of the ninth SCLx clock
The module does generate an interrupt after the reception of the first byte of a 10-bit address;
however, this interrupt is of little use.
The module will continue to receive the second byte into the I2CxRSR register. This time, the
I2CxRSR<7:0> bits are evaluated against the I2CxADD<7:0> and I2CxMSK<7:0> bits. If the
lower byte of the address is valid, as previously described, the following events occur:
• An ACK is generated
• The ADD10 status bit is set
• The module generates the SI2CxIF interrupt on the falling edge of the ninth SCLx clock
• The module will wait for the master to send data or initiate a Repeated Start condition
Note: Following a Repeated Start condition in 10-Bit Addressing mode, the slave only
matches the first 7-bit address, ‘11110 A9 A8 0’.
I2C™ Bus State (S) (D) (D) (D) (A) (D) (D) (D) (A) (Q)
SCLx (Master)
R/W = 0
SDAx (Master) 1 1 1 1 0 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0
SDAx (Slave)
SI2CxIF Interrupt
R/W
D/A
ADD10
SCLREL
1 2 3 4 5 6
3 Reception of first byte clears the R/W status bit. Slave logic generates an interrupt.
4 Address match of first and second byte sets the ADD10 status bit and causes slave logic to generate an ACK.
5 Reception of second byte completes the 10-bit address. Slave logic generates an interrupt.
SCLx 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2
SI2CxIF
RBF
ADD10
SCLREL
ACKTIM
4 6
1 2 3 5 7 8 9 10
1 Detecting the Start bit enables address detection; interrupt is set if the SCEN bit is set. 6 User software sets SCLREL to release clock hold.
2 User software clears the interrupt flag. 7 Slave interrupt is asserted.
8 User software reads I2CxRCV buffer, that clears RBF flag.
3 Slave receives first address byte. Write indicated. Interrupt flag is asserted. ACKTIM
DS70000195F-page 45
is asserted. If AHEN = 1, slave suspends clock. SCLREL is cleared by hardware. 9 Slave Acknowledges the second address byte.
4 User software clears the interrupt flag. 10 User software reads data from the I2CxRCV register.
Figure 7-9: General Call Address Detection Timing Diagram (GCEN = 1; AHEN = 0)
SCLx (Master)
1 Detecting Start bit enables
SDAx (Master) R/W address detection.
1 2 3 4
Note: The user application must clear the IPMIEN bit (I2CxCON<11>) during an I2C
master operation and set this bit while acting as an IPMI slave.
Note: When the STRICT bit is cleared, the ACK signal is generated, only if the address is
matched, even for reserved addresses. The slave device does not generate an ACK
if there is an address mismatch, even if the address is a reserved address. Irrespec-
tive of the STRICT bit setting, and the address is reserved or not, an ACK signal is
generated for a proper address match.
SCLx (Master) 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SDAx (Master) A7 A6 A5 A4 A3 A2 A1 W D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCLx (Slave)
SDAx (Slave) A A A A A
I2CxRCV
RBF
I2COV
R/W
D/A
STREN
SCLREL
SI2CxIF Interrupt Flag Cleared by User Software
SI2CxIF
1 2 3 4 3 4 3 4 3 4 5
2007-2014 Microchip Technology Inc.
3 Next received byte is message data. The byte moved to the I2CxRCV register sets the RBF status bit.
Slave generates interrupt. Slave Acknowledges reception.
4 User software reads the I2CxRCV register. RBF status bit clears.
SCLx (Master) 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCLx (Slave)
SDAx (Slave) A A A A A
I2CxRCV
I2COV
R/W
D/A
STREN
SCLREL
SI2CxIF Cleared by User Software
SI2CxIF
1 2 3 4 5 4 5 4 5 6
1 Slave recognizes Start event, S and P bits set/clear accordingly. 4 Next received byte is message data. Byte moved to the I2CxRCV register, sets RBF.
Slave Acknowledges and generates interrupt.
2 Slave receives address byte. High-order address matches.
Slave Acknowledges and generates interrupt. Address byte is 5 User software reads I2CxRCV register. RBF bit clears.
DS70000195F-page 53
SCLx (Master) 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SDAx (Master) A7 A6 A5 A4 A3 A2 A1 W D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
SCLx (Slave)
SDAx (Slave) A A N N N
I2CxRCV
RBF
I2COV
R/W
D/A
STREN
SCLREL
SI2CxIF Cleared by User Software
SI2CxIF
1 5 2 3 4 5 6 2 5
2007-2014 Microchip Technology Inc.
1 Slave receives address byte. Address matches. Slave generates interrupt. Address byte 4 Next byte also received before I2CxRCV read by software. I2CxRCV
is moved to I2CxRCV register and must be read by user software to prevent buffer overflow. register unchanged. Slave generates interrupt. Slave sends NACK for
reception. The master state machine should not be programmed to send
2 Next received byte is message data. The byte moved to I2CxRCV register, sets RBF. another byte after receiving a NACK in this manner. Instead, it should abort
Slave generates interrupt. Slave Acknowledges reception. the transmission with a stop condition or send a repeated start condition
and attempt to retransmit the data.
3 Next byte received before I2CxRCV read by software. I2CxRCV register unchanged. 5 User software reads I2CxRCV register. RBF bit clears.
I2COV overflow bit set. Slave generates interrupt. Slave sends NACK for reception.
6 User software clears I2COV bit. Reception will still not be able to proceed
normally until the module sees a stop/repeated start bit. If neither of these
conditions is met, an additional transmission will be received correctly, but
send a NACK and set the I2COV bit again.
Figure 7-14: Slave Message (Write Data to Slave: 7-Bit Address; Clock Stretching Enabled; A10M = 0; GCEN = 0; IPMIEN = 0; AHEN = 0; DHEN = 0;
2007-2014 Microchip Technology Inc.
SCLx (Master) 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCLx (Slave)
SDAx (Slave) A A A A
I2CxTRN
I2CxRCV
RBF
I2COV
R/W
D/A
STREN
SCLREL
SI2CxIF
1 2 3 4 5 6 3 5 7 8 9 3 5
1 User software sets the STREN bit to enable clock stretching. 6 User software sets SCLREL bit to release clock.
2 Slave receives address byte. I2CxRCV register is read by user software to 7 Slave does not clear SCLREL because RBF = 0 at this time.
prevent buffer overflow.
DS70000195F-page 55
8 User software may clear SCLREL to cause a clock hold. Module must detect SCLx
3 Next received byte is message data. The byte moved to I2CxRCV register, sets RBF. low before asserting SCLx low.
4 Because RBF = 1 at ninth clock, automatic clock stretch begins. 9 User software may set SCLREL to release a clock hold.
Slave clears SCLREL bit. Slave pulls SCLx line low to stretch clock.
5 User software reads I2CxRCV register. RBF bit clears.
dsPIC33/PIC24 Family Reference Manual
7.5 Sending Data to a Master Device
When the R/W status bit of the incoming device address byte is ‘1’ and an address match occurs,
the R/W status bit (I2CxSTAT<2>) is set. At this point, the master device is expecting the slave
to respond by sending a byte of data. The contents of the byte are defined by the system protocol
and are only transmitted by the slave.
Note: When the IPMIEN bit (I2CxCON<11>) is equal to ‘1’ (IPMI mode), the I2C module
assumes that the R/W bit is ‘0’. Therefore, the slave transmission function is
disabled. If the R/W bit is ‘1’, the I2C module will trigger an interrupt. This interrupt
should be ignored (that is, the I2C interrupt flags should be cleared) and the I2C
slave transmission event should be aborted.
When the interrupt from the address detection occurs, the user software can write a byte to the
I2CxTRN register to start the data transmission.
The slave sets the TBF status bit (I2CxSTAT<0>). The eight data bits are shifted out on the falling
edge of the SCLx input. This ensures that the SDAx signal is valid during the SCLx high time.
When all 8 bits have been shifted out, the TBF status bit is cleared.
The slave detects the Acknowledge from the master-receiver on the rising edge of the ninth SCLx
clock.
If the SDAx line is low, indicating an ACK, the master is expecting more data and the message
is not complete. The module generates a slave interrupt and the ACKSTAT status bit
(I2CxSTAT<15>) can be inspected to determine whether more data is being requested.
A slave interrupt is generated on the falling edge of the ninth SCLx clock. User software must
check the status of the I2CxSTAT register and clear the SI2CxIF interrupt flag.
If the SDAx line is high, indicating a NACK, the data transfer is complete. The slave resets and
generates an interrupt and it waits for detection of the next Start bit.
SCLx (Slave)
I2CxTRN
TBF
I2CxRCV
RBF
I2COV
R/W
D/A
STREN
SCLREL
SI2CxIF
1 2 3 4 5 6 3 4 5 6 3 4 5 7 8
2007-2014 Microchip Technology Inc.
1 Slave recognizes Start event, S and P bits set/clear accordingly. 5 After last bit, module clears TBF bit, indicating buffer is available for next byte.
2 Slave receives address byte. Address matches. Slave generates interrupt. 6 At the end of ninth clock, if the master has sent an ACK, module clears SCLREL
Address byte is moved to I2CxRCV register and is read by user software to prevent to suspend clock. Slave generates interrupt.
buffer overflow. R/W = 1 to indicate read from slave. SCLREL = 0 to suspend
master clock. 7 At the end of ninth clock, if master sent a NACK, no more data expected.
Module does not suspend clock and will generate an interrupt.
3 User software writes I2CxTRN with response data. TBF = 1 indicates that buffer is full.
Writing I2CxTRN sets D/A, indicating a data byte. 8 Slave recognizes Stop event, S and P bits set/clear accordingly.
4 User software sets SCLREL to release clock hold. Master resumes clocking and
slave transmits data byte.
Figure 7-16: Slave Message (Read Data from Slave: 10-Bit Address)
2007-2014 Microchip Technology Inc.
SCLx (Master) 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
SCxL (Slave)
I2CxTRN
TBF
RBF
ADD10
R/W
D/A
STREN
SCLREL
SI2CxIF
1 2 3 4 5 6 7 8 6 7 9 10
1 Slave recognizes Start event, S and P bits set/clear accordingly. 7 User software sets SCLREL to release clock hold. Master resumes clocking and
2 Slave receives first address byte. Write indicated. Slave Acknowledges and slave transmits data byte.
generates interrupt. User software reads I2CxRCV register. 8 At the end of ninth clock, if master sent ACK, module clears SCLREL to suspend
3 Slave receives address byte. Address matches. Slave Acknowledges and clock. Slave generates interrupt.
DS70000195F-page 59
5 Slave receives re-send of first address byte. User software reads I2CxRCV register. 10 Slave recognizes Stop event, S and P bits set/clear accordingly.
Read indicated. Slave suspends clock.
6 User software writes I2CxTRN with response data.
Figure 7-17: I2C™ Slave, 7-Bit Address, Reception (STREN = 1, AHEN = 1, DHEN = 1)
DS70000195F-page 60
ACK
SDAx A7 A6 A5 A4 A3 A2 A1 ACK D7 D6 D5 D4 D3 D2 D1 D0 ACK D7 D6 D5 D4 D3 D2 D1 D0
SI2CxIF
RBF
ACKDT
SCLREL
ACKTIM
7
1 2 3 4 5 6 8 9 10 11 12 13
2007-2014 Microchip Technology Inc.
1 Detecting Start bit, enables address detection, interrupt is set if SCEN is set. 7 Hardware stretches the clock after ACK (if STREN = 1).
2 User software clears the interrupt flag. 8 User software sets SCLREL to release clock hold.
I2CxRCV is loaded with I2CxRSR. RBF is set. If DHEN = 1, SCLREL is
9
3 Slave receives first address byte. Write Indicated. If AHEN = 1, SCLREL is cleared
cleared by hardware and ACKTIM is asserted.
by hardware. ACKTIM and interrupt are asserted.
10 User software sets SCLREL to release the clock hold. ACKTIM is cleared
4 User software clears the interrupt flag. by hardware. After Acknowledgment, hardware stretches the clock.
5 ACKDT is written with ACK by user software. 11 User software reads I2CxRCV, that clears the RBF flag.
12 NACK sent by master.
6 User software sets SCLREL to release the clock hold; ACKTIM is cleared by hardware.
13 Module recognizes the Stop event.
Inter-Integrated Circuit™ (I2C™)
8.0 CONNECTION CONSIDERATIONS FOR I2C BUS
Because the I2C bus is a wired-AND bus connection, pull-up resistors (RP) on the bus are
required, as illustrated in Figure 8-1. The series resistors (RS) are optional and are used to
improve the Electrostatic Discharge (ESD) susceptibility.
The values of the resistors, RP and RS, depend on the following parameters:
• Supply voltage
• Bus capacitance
• Number of connected devices (input current + leakage current)
• Input level selection (I2C or System Management Bus (SMBus))
Because the device must be able to pull the bus low against RP, current drawn by RP must be
greater than the I/O pin minimum sink current, IOL at VOLMAX, for the device output stage.
Equation 8-1 shows the formula for computing the minimum pull-up resistance.
(VDDMAX – VOLMAX)
RPMIN = IOL
In a 400 kHz system, a minimum rise time specification of 300 ns exists; in a 100 kHz system,
the specification is 1000 ns. Because RP must pull the bus up against the total capacitance, CB,
with a maximum rise time of 300 ns to (VDD – 0.7V), the maximum resistance for the pull-up
(RPMAX) is computed using the formula as shown in Equation 8-2.
– tR
CB * [ln(1 – (VDDMAX – VILMAX))]
The maximum value for RS is determined by the desired noise margin for the low level. RS cannot
drop enough voltage to make the device VOL and the voltage across RS more than the maximum
VIL. Equation 8-3 shows the formula for computing the maximum value for RS.
(VILMAX – VOLMAX)
RSMAX =
IOLMAX
Note: The SCLx clock input must have a minimum high and low time for proper operation.
Refer to the “Electrical Characteristics” chapter in the specific device data sheet
for more information on the high and low times of the I2C bus specification, and
requirements of the I2C module and I/O pins.
VDD + 10%
RP RP Device
RS RS
SDAx
SCLx
CB = 10-400 pF
Note: I2C™ devices with input levels related to VDD must have one common supply
line to which the pull-up resistor is also connected.
Constant-Current Source
ISRC1
M ISRC2
U
X ISRC3
ISRC4
ISRCEN OUTSEL<2:0>
Note: The constant-current source module is not available on all devices. Refer to the
specific device data sheet for availability.
Note: Other external resistor values may be used as required by the application. Using
tighter tolerance resistors and reducing the spacing between the values of the
resistors will allow more addresses to be encoded into each resistor in the
application circuit.
I2CxSTAT ACKSTAT TRSTAT ACKTIM(1) — — BCL GCSTAT ADD10 IWCOL I2COV D/A P S R/W RBF TBF 0000
I2CxADD — — — — — — I2Cx Address Register 0000
I2CxMSK — — — — — — I2Cx Address Mask 0000
ISRCCON ISRCEN — — — — OUTSEL2 OUTSEL1 OUTSEL0 — — ISRCCAL5 ISRCCAL4 ISRCCAL3 ISRCCAL2 ISRCCAL1 ISRCCAL0 0000
Legend: — = unimplemented, read as ‘0’. Reset values are shown in hexadecimal.
Note 1: These registers and/or bits are not available on all devices. Refer to the specific device data sheet for availability.
Inter-Integrated Circuit™ (I2C™)
14.0 DESIGN TIPS
Question 1: I am operating as a bus master and transmitting data. Why do slave and
receive interrupts keep occurring at the same time?
Answer: The master and slave circuits are independent. The slave will receive events from
the bus sent by the master.
Question 2: I am operating as a slave and I write data to the I2CxTRN register. Why is
the data not being transmitted?
Answer: The slave enters an automatic Wait when preparing to transmit. Ensure that you
set the SCLREL bit to release the I2C clock.
Question 4: Operating as a slave, I receive a byte while STREN = 0. What should the
user software do if it cannot process the byte before the next one is
received?
Answer: Because STREN was ‘0’, the module did not generate an automatic Wait on the
received byte. However, the user software may, at any time during the message,
set STREN and then clear SCLREL. This will cause a Wait on the next
opportunity to synchronize the SCLx clock.
Question 6: My I2C system is a multi-master system. How can I tell when it is okay to
begin a message?
Answer: Check the S status bit. If S = 0, the bus is Idle.
Question 7: I tried to send a Start condition on the bus, then transmit a byte by writing
to the I2CxTRN register. The byte did not get transmitted. Why?
Answer: You must wait for each event on the I2C bus to complete before starting the next
one. In this case, you should poll the SEN bit to determine when the Start event
completed or wait for the master I2C interrupt before data is written to the
I2CxTRN register.
Note: Please visit the Microchip web site (www.microchip.com) for additional application
notes and code examples for the dsPIC33/PIC24 family of devices.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
headquarters, design and wafer fabrication facilities in Chandler and
CERTIFIED BY DNV Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
== ISO/TS 16949 ==
are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.