5.1.2 I2C_Write Command and its Response

The I2C_Write command (0x44) initiates an I2C write transaction. The command writes wWrDtLen bytes of the data, vDatPac to the I2C client device addressed by bAddress.

This command is sent through Endpoint 0x03 (OUT). The response is read through Endpoint 0x83 (IN).

If the write data length exceeds the payload capacity of a single USB packet, multiple packets are used. The first packet contains up to 60 data bytes, and each additional continuation packets contains up to 62 data bytes.

A response is provided after the initial command packet, after each continuation packet, and after the write transaction completes or is aborted.

Table 5-4. I2C_Write - Command
Serial No.Byte IndexCommandDescription
100x44Command codeInitiates the I2C write transaction
21bAddressI2C client address7-bit I2C client address
32L(wWrDtLen)Write data length (lower byte)Number of data bytes; maximum length: 65,535 bytes
43H(wWrDtLen)Write data length (upper byte)
54b0(vDatPac)First data byteThe first 60 data bytes
65b1(vDatPac)Second data byte
7-63Additional data bytes
6463b59(vDatPac)60th data byte
65Wait for the first response from the MCP2222 to determine whether the command is accepted.

If the data length is more than 60 bytes, continue writing.

6600x44Repeat the command codeWrite is continued
6710xA0Write is continued
682b60(vDatPac)The 61st data byteThe next 62 data bytes
69-126Additional data bytes
12763b121(vDatPac)The 122nd data byte
128Wait for the next response
129If all data bytes have not been written, continue writing by repeating the above steps from serial number 66 to 128 until all data bytes are written. The final packet may contain fewer than 62 data bytes.
130Continue polling for the write-completion response
Table 5-5. I2C_Write - First Response
Byte IndexFirst ResponseDescription
00x44Return command codeReturns whether the I2C Write command was accepted or rejected
10x22Accepted - initiatedThe command is accepted, and an I2C write transaction is initiated
0x60Rejected - wrong parametersThe command is rejected because the parameters are invalid
0x64Rejected - I2C is busyThe command is rejected because the I2C module is busy
Table 5-6. I2C_Write - Subsequent Response
Byte IndexSubsequent ResponsesDescription
00x44Return command code The I2C write is continued.
1

0x22

Accepted - write continued

0x68

Rejected - buffer full

The Write buffer is full. Retry sending the same packet until it is accepted.

0x80

Failure - address NACK

An address NACK was received. Verify the I2C client address.

0x84

Failure - data NACK

A data NACK was received. Verify the client device requirements and the data length.

0x88

Failure - clock-stretch timeout

A clock-stretch timeout occurred. Recover the bus and retry, if required.

0x8C

Failure - arbitration lost

Bus arbitration was lost; another I2C host may be using the bus.

0x20

Success – write completed

The I2C_Write transaction is completed.

0x90

Failure - bus errorAn I2C bus error occurred.