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.

RTOS/AM3354: I2C write issue

Part Number: AM3354


Tool/software: TI-RTOS

Hi all:
I am using the am3354 with the I2C bus, when I write my data to the device like this :
0xFE, 0x00, 0x09, 0x10, 0x00, 0xF0, 0x00, 0x00 0x08, 0xC9, 0x99
(0xFE00 is the regAddr , the other is the data)
But when I wathc the bus with my oscilloscope the data were sent like this:
0xF0, 0x00, 0x00 0x08, 0xC9, 0x99, 0xFE, 0x00, 0x09, 0x10, 0x00

It seems like some of the data are buffered by the FIFO or something.
The 6 ~ 11 bytes are sent first, the 1 ~ 5 bytes are sent after;
PS: I print the data write to the I2C_DATA in the ISR the sequence is alright;
Why would this happen ? My I2C_BUF Register is the default setting, which means the FIFO is disabled.

This is my code. Anyone Help me ?

ERROR_CODE I2CDevReg16AddrMultWrite(uint32_t index, uint8_t devAddr, uint16_t regAddr, uint8_t *buf, uint32_t length)
{
    I2CMasterSlaveAddrSet(i2cContext[index].baseAddr, devAddr);
    i2cContext[index].slaveTData[0] = (regAddr >> 8) & 0xFF;
    i2cContext[index].slaveTData[1] = regAddr & 0xFF;
    for(i = 0; i < length ; i++)
    {
        i2cContext[index].slaveTData[i + 2] = buf[i];
    }

    i2cContext[index].txCompFlag = 0;
    i2cContext[index].rxCompFlag = 1;
    i2cContext[index].dataIdx = 0;    
    i2cContext[index].dataMaxT = length + 2;
 
    I2CSetDataCount(i2cContext[index].baseAddr, length + 2);

    I2CMasterControl(i2cContext[index].baseAddr, I2C_CFG_MST_TX | I2C_CFG_STOP);

    I2CMasterIntEnableEx(i2cContext[index].baseAddr, I2C_INT_TRANSMIT_READY | I2C_INT_NO_ACK);

    I2CMasterStart(i2cContext[index].baseAddr);
}

void I2C2Isr(void)
{
    uint32_t status;

    status = I2CMasterIntStatus(i2cContext[2].baseAddr);
    I2CMasterIntClearEx(i2cContext[2].baseAddr,(status & ~(I2C_INT_RECV_READY | 
        I2C_INT_TRANSMIT_READY )));

    if (status & I2C_INT_TRANSMIT_READY)
    {
         I2CMasterDataPut(i2cContext[2].baseAddr, i2cContext[2].slaveTData[i2cContext[2].dataIdx]);
         I2CMasterIntClearEx(i2cContext[2].baseAddr, I2C_INT_TRANSMIT_READY);
         i2cContext[2].dataIdx++;
 
         if(i2cContext[2].dataMaxT == i2cContext[2].dataIdx)
         {
              I2CMasterIntDisableEx(i2cContext[2].baseAddr, I2C_INT_TRANSMIT_READY);
              i2cContext[2].txCompFlag = 1;
         }
    }
}