unsigned char data[10];
int datasize;
int index=0;
data[0]=0xDE;
data[1]=0x00;
data[2]=0x20;
data[3]=0x21;
data[4]=0x80;
// data[5]=0x81;
// data[6]=0x27;
// data[7]=0x01;
// data[8]=0x15;
datasize=9;
StartI2C1();//Send the Start Bit
IdleI2C1();//Wait to complete
while(datasize)
{
k=MasterWriteI2C1(data[index]);
IdleI2C1();//Wait to complete
datasize--;
index++;
if( I2C1STATbits.ACKSTAT )
break;
}
// k= MasterputsI2C1(data);
StopI2C1();//Send the Stop condition
IdleI2C1();//Wait to complete
StartI2C1();//Send the Start Bit
IdleI2C1();//Wait to complete
k=MasterWriteI2C1(0xDE);
IdleI2C1();//Wait to complete
k=MasterWriteI2C1(0x00);
IdleI2C1();//Wait to complete
RestartI2C1();//Send the Stop condition
IdleI2C1();//Wait to complete
k=MasterWriteI2C1(0xDF);
IdleI2C1();//Wait to complete
getvalue=MasterReadI2C1();
StopI2C1();//Send the Stop condition
IdleI2C1();//Wait to complete