1.3.1 The I2C Start and/or Stop Flags May Be Set When I2C Is Enabled
When I2C is enabled, erroneous Start and/or Stop conditions may be detected. This can generate erroneous I2C interrupts if enabled.
Work around
Use the following procedure to correctly detect the Start and Stop conditions:
- Disable the Start and Stop conditions interrupt functions.
- Enable the I2C module.
- Wait 250 ns + six instructions cycles (FOSC/4).
- Clear the Start and Stop conditions interrupt flags.
- Enable the Start and Stop conditions interrupt functions if used.
I2CxPIEbits.SCIE = 0; // Disable Start condition interrupt
I2CxPIEbits.PCIE = 0; // Disable Stop condition interrupt
I2CxCON0bits.EN = 1; // Enable I2C
Delay(); // Wait for 250 ns + 6 instruction cycles (FOSC/4)
I2CxPIRbits.SCIF = 0; // Clear the Start condition interrupt flags
I2CxPIRbits.PCIF = 0; // Clear the Stop condition interrupt flags
I2CxPIEbits.SCIE = 1; // Enable Start condition interrupt if used
I2CxPIEbits.PCIE = 1; // Enable Stop condition interrupt if used
Affected Silicon Revisions
D1 | D3 | E0 |
X |