This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
1. I cannot read data more than 8 bytes
2. if I use I2CFIFODataGet() that will hug up sometimes.
Is any one can help me to solve the program?
void I2C0_FIFO_Read(uint16_t u16Len)
{
I2CMasterBurstLengthSet(I2C5_BASE, u16Len);
I2CMasterSlaveAddrSet(I2C5_BASE, I2C_SLAVE_ADDR, 1);
I2CMasterControl(I2C5_BASE, I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH);
}
void I2C5Interrupt(void)
{
uint8_t i, au8Data[8];
for (i = 0 ; i < 8; ++i)
{
//au8Data[i]=I2CFIFODataGet(I2C5_BASE);
I2CFIFODataGetNonBlocking(I2C5_BASE, au8Data);
}
#if 0
g_u32FIFOReadLen+=8;
if(g_u32FIFOReadLen < g_u32FIFOReadTotal)
{
I2CMasterBurstLengthSet(I2C5_BASE, 8);
I2CMasterControl(I2C5_BASE, I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE);
}
#endif
I2CMasterIntClear(I2C5_BASE);
}
Hello Will,
Welcome to this forum.
The I2C modules have an 8-byte FIFO. You can do burst requests, reads or writes, of more than 8 bytes by using interrupts to keep the FIFOs full (TX) or empty (RX). For example, you can set the RX FIFO to give you an interrupt whenever 4 or more bytes have been received by calling:
I2CRxFIFOConfigSet(I2C5_BASE, I2C_FIFO_CFG_RX_TRIG_4);
In the interrupt routine, you can use I2CFIFODataGetNonBlocking() to read the data, but you must check the return value to verify that there was valid data to read. (A return of 1, means it read one byte, a return of 0 means the FIFO is now empty.) The FIFO may contain more than four elements if your interrupt routine was delayed.