Hi,
I am using LM3S9B96 Dev board to interface with my device through I2C. I need to use 8 bit address and 16 bit data. Its working fine but at some instance it's missing some data while write process. My code is
Write Function:
void Write(uint8_t Reg_Addr, usint16_t data) {
I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_START); /* I2C Start */
I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, Slave_Adress, I2C_SEND ); /* Slave Address Transfer */
I2CMasterDataPut( I2C1_MASTER_BASE, Reg_Addr); /* Register Address Transfer */
while( I2CMasterBusy(I2C1_MASTER_BASE)); /* Waiting for BusIdle */
I2CMasterDataPut( I2C1_MASTER_BASE, (data >> 8) & 0xFF ); /* Hr Byte data transfer */
I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_CONT);
while( I2CMasterBusy(I2C1_MASTER_BASE)); /* Waiting for BusIdle */
I2CMasterDataPut( I2C1_MASTER_BASE, (data & 0xFF) ); /* Lr Byte data transfer */
while( I2CMasterBusy(I2C1_MASTER_BASE)); /* Waiting for BusIdle */
I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH ); /* I2C Stop */
}
Read Function:
void Read(uint8_t Reg_Addr) {
I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_START); /* I2C Start */
I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, Slave_Adress, I2C_SEND ); /* Slave Address Transfer Enable*/
I2CMasterDataPut( I2C1_MASTER_BASE, Reg_Addr); /* Register Address Transfer */
while( I2CMasterBusy(I2C1_MASTER_BASE)); /* Waiting for BusIdle */
I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, Slave_Adress, I2C_RECEIVE ); /* I2C Data Receive Enable */
I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START); /* I2C Restart */
while( I2CMasterBusy(I2C1_MASTER_BASE)); /* Waiting for BusIdle */
rec[0] = I2CMasterDataGet(I2C1_MASTER_BASE); /* Hr Byte data Read */
I2CMasterControl(I2C1_MASTER_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH); /* I2C Stop */
while( I2CMasterBusy(I2C1_MASTER_BASE)); /* Waiting for BusIdle */
rec[1] = I2CMasterDataGet(I2C1_MASTER_BASE); /* Lr Byte data Read */
}
Thanks in advance...