Using Internal Addresses

Some I2C slave devices have fixed internal address setting. The internal address is the slave’s internal register. Possible internal addresses depend on the slave device. Some very simple devices do not have any, but most do.

To communicate with a certain register, after the I2C master addressed the slave device and received acknowledgement, it sends the internal address inside the slave where it wants to transmit data to or from.

Both read and write operations can use an internal address. When an internal address is set, the same address is used in every READ and WRITE operations that follows the previous operation.

Rating: 
Средняя: 5 (1 оценка)

WRITE Operation

To write to a slave device, the I2C master follows these steps:

  1. Sends the START (S) condition.

  2. Sends the I2C address of the slave device.

  3. Sends the WRITE (W) direction bit.

  4. Receives the acknowledgement (ACK) bit.

  5. Sends the internal address where it wants to write.

  6. Receives the acknowledgement (ACK) bit.

  7. Sends data bytes and receives the acknowledgement (ACK) bit after each byte.

  8. Sends the STOP (P) condition.

Write to internal address

To write data using internal address, call the DlnI2cMasterWrite() function. It requires the slave device address (the slaveDeviceAddress parameter), the length of the internal address (the memoryAddressLength parameter) and the internal address (the memoryAddress parameter).

Rating: 
Средняя: 4.5 (2 оценок)

READ Operation

Before reading data from the slave device, the master tells the slave which of the internal addresses it wants to read. Therefore, a read operation starts by writing to the slave.

To read from a slave device, the I2C master follows these steps:

  1. Sends a START (S) condition.

  2. Sends the I2C address of the slave device.

  3. Sends the WRITE (W) direction bit.

  4. Receives the acknowledgement (ACK) bit.

  5. Sends the internal address where it wants to read from.

  6. Receives the acknowledgement (ACK) bit.

  7. Sends the repeated START (Sr) condition.

  8. Sends the READ (R) direction bit.

  9. Receives the acknowledgement (ACK) bit.

  10. Receives data bytes and sends acknowledgement (ACK) bits to continue reading or a not acknowledgement (NACK) bit to stop reading.

  11. Sends the STOP (P) condition.

Read from internal address

To read data using internal address, call the DlnI2cMasterRead() function. It requires the slave device address (the slaveDeviceAddress parameter), the length of the internal address (the memoryAddressLength parameter) and the internal address (the memoryAddress parameter).

Rating: 
Средняя: 5 (1 оценка)