AnsweredAssumed Answered

TWI/I2C 8-bit transfer

Question asked by mlau on Jan 4, 2011
Latest reply on Jan 7, 2011 by jeyanthi.jegadeesan

Hi,

 

I have connected a 21489 Ez Kit to a LCD display over TWI/I2c.  I'm trying to send 3 bytes of data to set the contrast and I'm having problems.  I'm able to send 2 bytes of data with no problems.  I'm also not using any interrupts.  I've included my code below and any insight would be appreciated.

 

#define TWIDCNT2 BIT_7

#define TWIDCNT3 (3* BIT_6)

void Init_I2C_Device(void)
{
*pTWIMITR = 20|TWIEN;
*pTWIDIV = 0x3232;
*pTWIMADDR = 0x28;
*pTWIFIFOCTL = TWIBHD;
*pTWIIMASK = 0;

}

void i2c_write_register2(int address, int data1, int data2)

{

int temp;

while(*pTWIMSTAT & TWIMPROG);

*pTXTWI8 = address;

*pTWIFIFOCTL = TWIBHD;

*pTWIMCTL = TWIDCNT3 | TWIMEN;

while(*pTWIMSTAT & TWIMPROG);

*pTXTWI8 = data1;

while(*pTWIMSTAT & TWIMPROG);

*pTXTWI8 = data2;

}

int main()

{

Init_I2C_Device();

i2c_write_register(0xFE, 0x52, 0x10);

return 0;

}

 

 

Thanks,

Matt

Outcomes