Use the following code can not get a byte form MPU-6500,the code genarated by the halcogen,can anybody tell me the reason?
/* i2c initialization */
i2cInit();
WaitforMPU6500Start();
/* set i2c slave address */
i2cSetSlaveAdd(i2cREG1,0x68);
/////////////////////////////////////////////////////////////////////////
/* Set direction to Transmitter */
/* Note: Optional - It is done in Init */
i2cSetDirection(i2cREG1, I2C_TRANSMITTER);
i2cSetCount(i2cREG1, 1);
/* Set mode as Master */
i2cSetMode(i2cREG1, I2C_MASTER);
/* Set Stop after programmed Count */
i2cSetStop(i2cREG1);
/* Transmit Start Condition */
i2cSetStart(i2cREG1);
/* Tranmit DATA_COUNT number of data in Polling mode */
i2cSend(i2cREG1, 1, &Txbuf);
/* Wait until Bus Busy is cleared */
while(i2cIsBusBusy(i2cREG1) == true);
/* set i2c slave address */
i2cSetSlaveAdd(i2cREG1,0x80|0x68);
/* Set direction to Transmitter */
/* Note: Optional - It is done in Init */
i2cSetDirection(i2cREG1, I2C_RECEIVER);
/* Transmit Start Condition */
i2cSetStart(i2cREG1);
/* Tranmit DATA_COUNT number of data in Polling mode */
i2cReceive(i2cREG1, 1, &DeviceID);
/* Wait until Stop is detected */
while(i2cIsStopDetected(i2cREG1) == 0);
/* Clear the Stop condition */
i2cClearSCD(i2cREG1);
/* wait for ever */
This is the specification defined in mpu6500 datasheet: