Following the I2C example code for the F28027 i2c_eeprom example, I setup my I2C , as a master in a multi master system, to use the Tx FIFO to transmit 3 data bytes and interrupt, when finished, on ARDY.
But I am unsure what the sequence of events will be when a NACK or loss of arbitration occurs during addressing or data transmission.
- Will the STOP be automatically sent?
- Will the ARDY interrupt still occur?
- What will the state of the FIFOs be after?
- If they still have data remaining in them, what is the best method of clearing them?
- What is the best method of determining if a receiver has legally NACKed the last byte, rather than NACKed some preceding byte?
Currently my message start code is as follows:
i2c->I2CMDR &= (~I2C_I2CMDR_IRS_BIT); /* Put I2C into reset. */
i2c->I2CMDR |= I2C_I2CMDR_FREE_BIT; /* Stop free run on breakpoint. */
i2c->I2CMDR &= ~I2C_I2CMDR_BC_BITS; /* Set bit count to 8 bits per byte. */
i2c->I2CMDR |= I2C_I2CMDR_MST_BIT; /* Select master mode. */
i2c->I2CEMDR = 0x0U; /* Disable backwards compatibility mode. */
i2c->I2COAR = addr; /* Set device address. */
i2c->I2CPSC = 0x04U & I2C_I2CPSC_IPSC_BITS; /* Setup clock. */
i2c->I2CCLKL = 0x37U;
i2c->I2CCLKH = 0x37U;
i2c->I2CSTR = 0xFFFFU; /* Clear the I2C status register. */
i2c->I2CIER = 0; /* Clear past interrupt scheme. */
/* Enable interrupts ARDY, NACK, AL. */
i2c->I2CIER = (uint16_t) (I2C_IntEn_NACK | I2C_IntEn_Arb_Lost
| I2C_IntEn_Reg_Rdy);
/* Enable FIFO and Tx FIFO. */
i2c->I2CFFTX = I2C_I2CFFTX_FFEN_BIT | I2C_I2CFFTX_TXFFRST_BIT;
i2c->I2CMDR |= I2C_I2CMDR_IRS_BIT; /* Release I2C from reset. */
/* Configure I2C interrupt. */
PIE_registerPieIntHandler(pie, PIE_GroupNumber_8,
PIE_SubGroupNumber_1, (intVec_t)&i2c_isr);
PIE_enableInt(pie, PIE_GroupNumber_8, PIE_InterruptSource_I2CA1);
CPU_enableInt(cpu, CPU_IntNumber_8);
i2c->I2CSAR = 0x10U; /* Set slave address. */
i2c->I2CCNT = 3U; /* Specify 3 data bytes. */
i2c->I2CDXR = value1; /* Set data bytes to data. */
i2c->I2CDXR = value2;
i2c->I2CDXR = value3;
i2c->I2CMDR |= I2C_I2CMDR_STP_BIT; /* Finish with STOP condition. */
i2c->I2CMDR |= I2C_I2CMDR_TRX_BIT; /* Put device in transmitter mode. */
i2c->I2CMDR |= I2C_I2CMDR_STT_BIT; /* Begin with START condition. */