Hello,
I have to send one (1) byte (0xAA) via I2C and then get 2 bytes in response. The code is:
//-------------------------------------- INIT -------------------------------------------------------------
I2CMasterInitExpClk (I2C6_BASE, SysCtrlClockGet (), false);
I2CMasterEnable (I2C6_BASE);
//-------------------------------------- SEND ----------------------------------------------------------
I2CMasterSlaveAddrSet (I2C6_BASE, 0x48, false); //set slave address to 0x48, initiating write
I2CMasterDataPut (I2C6_BASE, 0xAA); //Put 0xAA in the FIFO
I2CMasterControl (I2C6_BASE, I2C_MASTER_CMD_SINGLE_SEND); //Send
while (I2CMasterBusy(I2C6_BASE)); //Wait till end of transaction
//-------------------------------------- RECEIVE ----------------------------------------------------------
I2CMasterSlaveAddrSet (I2C6_BASE, 0x48, true); //set slave address to 0x48, initiating read
I2CMasterControl (I2C6_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); //Receive
while (I2CMasterBusy(I2C6_BASE)); //Wait till end of transaction
Byte1 = I2CMasterDataGet (I2C6_BASE); //Read from FIFO
I2CMasterControl (I2C6_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); //Receive
while (I2CMasterBusy(I2C6_BASE)); //Wait till end of transaction
Byte2 = I2CMasterDataGet (I2C6_BASE); //Read from FIFO
//-------------------------------------------------------------------------------------------------------------------------------
Is this the right sequence ?
Before this code I set the pinout with code created with the Pinmux utility
Thanks,
Zvika