I²C Current Address Read
Just tell me what you have where you are right now…
I²C current address reads are used to read one byte from the current address. The current address will be one beyond the address that was last acted upon.
EEPROM Current Address Read Procedure
- Send start condition - wait for it to complete
- Send control byte
- Check for bus idle
- Read in one byte
- Send NACK, wait until ACK sequence complete
- Send stop condition - wait for it to complete
Example Code (PIC18)
Specific I²C function names and parameters may differ depending on your target device, compiler and/or peripheral library.
StartI2C(); while (SSPCON2bits.SEN); |
// Initiate START condition // Wait until START condition is over |
WriteI2C(0xA1); | // Write 1 byte - R/W bit should be 1 for read |
IdleI2C(); | // Ensure module is idle |
getsI2C(&dataOut, 1); | // Read in one byte |
NotAckI2C(); while (SSPCON2bits.ACKEN); |
// Send NACK condition // Wait until ACK sequence is over |
StopI2C(); while (SSPCON2bits.PEN); |
// Send STOP condition // Wait until STOP condition is over |