AnsweredAssumed Answered

TWI/I2C in 16-bit Write Mode

Question asked by Laz on Oct 18, 2010
Latest reply on Oct 22, 2010 by DeepV

I've been using the TWI as I2C with no trouble, except for the Write 16-bit mode.  The following code should send 3 bytes: Address, Index, and Value.  According to my 'scope, it only sends Address and Value.  I think I'm missing something small but important.  I'm using a 21368.


VOID writeI2C (I2C_DEVICE_ID device, UINT index, UINT value)
UINT address;

// write the device address
address = I2C_ADDR[device];
*pTWIMADDR = address;


// write the index combined with the value
*pTXTWI16 = (value << 16) | index; // lower value is written first

*pTWIMCTL = (TWIMEN | (2 << 6));