AnsweredAssumed Answered

LPI2C_MasterReceive always return with kStatus_LPI2C_FifoError

Question asked by claude-david gaudreault on Jun 7, 2020
Latest reply on Jun 20, 2020 by claude-david gaudreault

as from this function mainly copied from the lpi2c polling master example :

 

int8_t ucReadI2CSlaveLPI2C1( uint8_t ucSlave, uint8_t address,uint8_t ucDataReaded[], uint8_t ucByteToRead)
{
    status_t reVal        = kStatus_Fail;
    size_t txCount        = 0xFFU;
    if (kStatus_Success == LPI2C_MasterStart(((LPI2C_Type *)(LPI2C1_BASE)), ucSlave , kLPI2C_Write))
        {
            /* Check master tx FIFO empty or not */
            LPI2C_MasterGetFifoCounts(((LPI2C_Type *)(LPI2C1_BASE)), NULL, &txCount);
            while (txCount)
            {
                LPI2C_MasterGetFifoCounts(((LPI2C_Type *)(LPI2C1_BASE)), NULL, &txCount);
            }
            /* Check communicate with slave successful or not */
            while (LPI2C_MasterGetStatusFlags(((LPI2C_Type *)(LPI2C1_BASE))) & kLPI2C_MasterNackDetectFlag)
            {
            }

 

            reVal = LPI2C_MasterSend(((LPI2C_Type *)(LPI2C1_BASE)), &address, 1);
            if (reVal != kStatus_Success)
            {
                return -1;
            }

 

            reVal = LPI2C_MasterRepeatedStart(((LPI2C_Type *)(LPI2C1_BASE)), ucSlave, kLPI2C_Read);
            if (reVal != kStatus_Success)
            {
                return -1;
            }

 

            LPI2C_MasterReceive(((LPI2C_Type *)(LPI2C1_BASE)), &ucDataReaded, ucByteToRead - 1);
            if (reVal != kStatus_Success)
            {
                return -1;
            }

 

            reVal = LPI2C_MasterStop(((LPI2C_Type *)(LPI2C1_BASE)));
            if (reVal != kStatus_Success)
            {
                return -1;
            }
        }
    return 0xFF;
}

 

LPI2C_MasterReceive return with kStatus_LPI2C_FifoError and i dont get any data in ucDataReaded but when i look with a logic analyser the transaction with the slave is perfect. What is the problem here?

Outcomes