Hello there,
i configured the I2C with FiFO and it worked successfully. that is my code below, it is a simple code that writes three values at ISL29023's registers and reads it back to make sure that the communication works successfully
ISL29023 Address is 0x44
and the register address is 0x04
uint8_t ui8I2CTransmitData[4] = {0x04, 2 , 250 ,4 }; //register address + 3 values
uint8_t ui8I2CReceiveData[3] = {0x00, 0x00, 0x00};
uint32_t ui32SysClock;
uint32_t ui32Index;
ui32SysClock = SysCtlClockFreqSet(SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ | SYSCTL_CFG_VCO_480, 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlDelay(10);
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
//
// Configure The I2C Master
//100 kbps
I2CMasterInitExpClk(I2C0_BASE, ui32SysClock, false);
I2CTxFIFOConfigSet(I2C0_BASE,(I2C_FIFO_CFG_TX_MASTER|I2C_FIFO_CFG_TX_TRIG_1));
I2CRxFIFOConfigSet(I2C0_BASE,(I2C_FIFO_CFG_RX_MASTER|I2C_FIFO_CFG_RX_TRIG_3));
I2CTxFIFOFlush(I2C0_BASE);
I2CRxFIFOFlush(I2C0_BASE);
//writing data at the sensor register using FiFO
I2CMasterBurstLengthSet(I2C0_BASE,0x4);
I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
for(ui32Index=0;ui32Index<4;ui32Index++)
{
I2CFIFODataPut(I2C0_BASE, ui8I2CTransmitData[ui32Index]);
}
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE);
while(!I2CMasterBusy(I2C0_BASE));
while(I2CMasterBusy(I2C0_BASE));
//writing the register address that i will read from it
I2CMasterBurstLengthSet(I2C0_BASE,0x1);
I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
for(ui32Index=0;ui32Index<1;ui32Index++)
{
I2CFIFODataPut(I2C0_BASE, ui8I2CTransmitData[ui32Index]);
}
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE);
//check stop condition
while(!I2CMasterBusy(I2C0_BASE));
while(I2CMasterBusy(I2C0_BASE));
//reading the 3 values from the sensor
I2CMasterBurstLengthSet(I2C0_BASE,0x3);
I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE);
for(ui32Index=0;ui32Index<3;ui32Index++)
{
ui8I2CReceiveData[ui32Index] = I2CFIFODataGet(I2C0_BASE);
}
but every time i read the three values i must wait at "I2CFIFODataGet(I2C0_BASE);" to catch every new data. so i have to wait three times(N times) to read the three values(N values).
So my simple question is :
is there any possible way to read the whole values after just one wait or one check instead of waiting at every new byte?
thanks.