uint16_t i2c2_read2ByteRegister(uint8_t address, uint8_t reg)
{
uint16_t result;
I2C2_Initialize();
I2C2ADB1 = (uint8_t)(address<<1);
wait4BusFree();
I2C2CNT = 1;
I2C2CON0bits.RSEN = 1;
I2C2CON0bits.S = 1; //Start
wait4Start();
sendByte(reg);
wait4MDRSetcount(2);
address = (uint8_t)(address<<1);
I2C2ADB1 = (uint8_t)(address| 0x01); //Change the R/W bit for read
I2C2CON0bits.S = 1; //Start
I2C2CON0bits.RSEN = 0;
result = receiveByte();//read MSB of the 2byte register
result = result<<8;
result = result | receiveByte();//read LSB of the 2byte register
wait4Stop();
return result;
}