Jump to content
  • 0

Reading I2C via script displays wrong data


alexpeck

Question

Device: Analog Discovery 2

Software: Waveforms 3.10.9 & 3.11.24 (beta) 

Host OS: Windows 10

 

Hi,

I have created a script that writes various sized I2C buffers to custom HW, and then reads the response.  The response size also varies. It works correctly for small buffer sizes of up to 8 bytes.

When buffers larger than 8 bytes are received and displayed via print(), the data displayed repeats periodically, each time growing 9 bytes longer. The repeated data looks correct, though it is truncated.  The number of bytes received always appears to be correct.

If I then do a read of the same size from the I2C protocol pane, the data is received and displayed correctly, regardless of the size.

I have compared the I2C signals from both working & non-working reads on a scope, and they are identical.  I2C commands and responses look correct.

Here's an example of a successful read from the protocol pane (in hex):
Start, h45 , h60, h00, hF9, h00, hB1, hFE, hFD, hFC, hFB, hFA, hF9, hF8, hF7, hF6, hF5, hF4, hF3, hF2, hF1, hF0, hEF, hEE, hED, hEC, hEB, hEA, hE9, hE8, hE7, hE6, hE5, hE4, hE3, hE2, hE1, hE0, hDF, hDE, hDD, hDC, hDB, hDA, hD9, hD8, hD7, hD6, hD5, hD4, hD3, hD2, hD1, hD0, hCF, hCE, hCD, hCC, hCB, hCA, hC9, hC8, hC7, hC6, hC5, hC4, hC3, hC2, hC1, hC0, hBF, hBE, hBD, hBC, hBB, hBA, hB9, hB8, hB7, hB6, hB5, hB4, hB3, hB2, hB1, hB0, hAF, hAE, hAD, hAC, hAB, hAA, hA9, hA8, hA7, hA6, hA5, hA4, hA3, hA2, hA1, hA0, h9F, h9E, h9D, h9C, h9B, h9A, h99, h98, h97, h96, h95, h94, h93, h92, h91, h90, h8F, h8E, h8D, h8C, h8B, h8A, h89, h88, h87, h86, h85, h84, h83, h82, h81, h80, h7F, h7E, h7D, h7C, h7B, h7A, h79, h78, h77, h76, h75, h74, h73, h72, h71, h70, h6F, h6E, h6D, h6C, h6B, h6A, h69, h68, h67, h66, h65, h64, h63, h62, h61, h60, h5F, h5E, h5D, h5C, h5B, h5A, h59, h58, h57, h56, h55, h54, h53, h52, h51, h50, h4F, h4E, h4D, h4C, h4B, h4A, h49, h48, h47, h46, h45, h44, h43, h42, h41, h40, h3F, h3E, h3D, h3C, h3B, h3A, h39, h38, h37, h36, h35, h34, h33, h32, h31, h30, h2F, h2E, h2D, h2C, h2B, h2A, h29, h28, h27, h26, h25, h24, h23, h22, h21, h20, h1F, h1E, h1D, h1C, h1B, h1A, h19, h18, h17, h16, h15, h14, h13, h12, h11, h10, h0F, h0E, h0D, h0C, h0B NAK, Stop
 
Here's a read showing the issue from the script pane (in decimal):
96,0,249,0,177,254,253,252,69,96,0,249,0,177,254,253,252,251,250,249,248,247,246,245,244,243,69,96,0,249,0,177,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,69,96,0,249,0,177,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,69,96,0,249,0,177,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,69,96,0,249,0,177,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,69,96,0,249,0,177,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,69,96,0,249,0,177,254,253

Here's a portion of the script. After initializing I2C, the script simply does a write, waits a few seconds, then does a read and prints the resulting buffer:

****************

var count = 249;

Protocol.I2C.Write(0x22, Buffer); 

wait(secondsToWait);

response = Protocol.I2C.Read(0x22, (count ));

print(response);

******************

 

Any Ideas?  Perhaps a buffer size needs to be updated?

 

Thanks,

-Alex

 

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...