nonNoise / PyMCP2221A

MCP2221 & MCP2221A work in Python.
MIT License
36 stars 21 forks source link

Long I2C reads ( greater than 8 bytes ) #5

Closed mrpackethead closed 4 years ago

mrpackethead commented 5 years ago

I am having an issue with Long I2C Reads.

Using the Microchip MCP2221 I2C Terminal Program i am able to read 0x23 ( 35 ) bytes with no problem, so i'm pretty sure that my hardware is ok.

When I try to read 0x23 bytes with PYMy2221A I can not read any more than 8 bytes before it crashes, SCL remains low. ( it is the MCP2221 that is holding it down ).

mcp2221.I2C_Read(0x60,0x23)

Fails

I can read all teh data if i do make three reads of 8 bytes, and one of 3 bytes, and join them together later. However i have to put small pauses otherwise it crashes as well.

This works

r1 = mcp2221.I2C_Read(0x60,0x08)
sleep(.02)
r2 = mcp2221.I2C_Read(0x60,0x08)
sleep(.02)
r3 = mcp2221.I2C_Read(0x60,0x08)
sleep(.02)
r4 = mcp2221.I2C_Read(0x60,0x08)
sleep(.02)

data = r1 + r2 + r3 + r4

Is this by design, or is this a bug?

nonNoise commented 4 years ago

This is the correct answer to experience the time difference because USB is sometimes fast. Not a bug.