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.

TMDSCNCD2800157: Need some help making the I2C work on my TMDSCNCD2800157 controlCARD

Part Number: TMDSCNCD2800157
Other Parts Discussed in Thread: C2000WARE

Hi Experts,

Our customer needs some help making the I2C work on his TMDSCNCD2800157 controlCARD.
He followed the examples for I2C interface on the control card, but he is having limited success. He can transmit but not receive in I2CA
He has supporting source code and scope capture if it helps
CS1759715.zip

He tried I2CA and I2CB on different pins - still he can't read.
also tried with and without FIFO - this is the best he got so far
He has very short transactions and very few transactions - so no need to use interrupts. Code can manage the transaction and wait is fine.

Please help advise. Thank you.

Best regards,
Gerald

  • Gerald,

    What are you trying I2C to interface to? Is F280015x I2C controller or target? 

    I'm not able to view the image. Can you send it in png / jpeg format?

    Please provide the I2C frame format you are trying to achieve for both transmit and receive option?

    Regards,

    Manoj

  • Gerald,

    I managed to read the scopeshot. From the below scope shot, it does look like you are reading some value from the target? So, what is the problem. I'm not able to understand.

    Regards,

    Manoj

  • Hi Manoj,

    I forwarded your response to our customer and was not able to receive a response from him last week. Hence, I sent him a follow-up message last Thursday to check if his concern was already resolved. Please see our customer feedback below:

    My issue is not resolved.  I have a work around for now, but the status bits for I2CA are still not operational.

    I would like to use the status bits to control the flow of the I2C instead of using a time delay.  Without status bits, one cannot possibly know the status of the I2C and I would be guessing when to pick up the received data. This is a major problem than needs to be addressed. 

    We hope to receive further advice. Thank you.

    Best regards,
    Gerald

  • would like to use the status bits to control the flow of the I2C instead of using a time delay.  Without status bits, one cannot possibly know the status of the I2C and I would be guessing when to pick up the received data. This is a major problem than needs to be addressed. 

    I need more details to provide any meaningful inputs. Did he check the I2CSTR (I2C Status bits)? what time delay are they talking about? Are they doing byte byte communication (or) FIFO enabled transaction?

  • The CS1789715.zip includes a code snippet and the below scope capture.  I am able to work around the problem using the DEVICE_DELAY_US instead of using any kind of status bit.  Since I2C is a state driven feature, it should be controlled by states and not timing delays.  My major concern is when reading 10's of bytes using the delay method, some bytes will be duplicated or missed because I am using a time delay instead of the state.  All of your examples also use a time delay and only work with a few bytes, so they did not help.  

    I tried both with and without FIFO.  I was never able to get I2C_STS_RX_DATA_RDY or I2C_STS_RX_FULL to work.

  • I wrote a sample I2CWrite function which doesn't use delay function.

    void I2CWrite(uint32_t base, uint16_t targetAddr, uint16_t *pTXbuff, uint16_t byteCount, bool sendStopCondition)
    {

    //  I2C_enableInterrupt(base, I2C_INT_STOP_CONDITION | I2C_INT_NO_ACK | I2C_INT_ARB_LOST);

        //Disable and enable FIFO to flush any previous I2C transaction
        I2C_disableFIFO(base);
        //I2C_enableFIFO(base);

        I2C_setTargetAddress(base, targetAddr);
        //Controller Transmit mode + Repeat mode
        //I2CCNT register settings are ignored
        I2C_setConfig(base, I2C_CONTROLLER_SEND_MODE | I2C_REPEAT_MODE);

        I2C_sendStartCondition(base);

        uint16_t buff_pos = 0;

        uint16_t i;
        for(i=1; i<=byteCount; i++)
        {
            I2C_putData(base, pTXbuff[buff_pos++]);

            while(!(I2C_getStatus(base) & I2C_STS_TX_DATA_RDY)){}

            I2C_clearStatus(base, I2C_STS_REG_ACCESS_RDY);
        }

        if(sendStopCondition)
        {
            I2C_sendStopCondition(base);
            while(I2C_getStopConditionStatus(base));
        }
    }

  • That snippet is pretty much what I used for writing to the I2C.  My issue is READING from the I2C.  The I2C_STS_RX_DATA_RDY  status bit doesn't work.   Please read my post and review my code snippet.  Thanks.

  • Hello Brian, We will get back to you in couple of days.

  • Hi Brian,

    My issue is READING from the I2C.  The I2C_STS_RX_DATA_RDY  status bit doesn't work.   Please read my post and review my code snippet. 

    I2C_STS_RX_DATA_RDY register could be used when not in FIFO mode. In your code I see you clear the status register before reading out the data from I2CDRR. I don't think you should need to do this since reading the I2CDRR register should clear it by itself.

    For FIFO mode you could try the routine below from the 'i2c_ex4_eeprom_polling' example in C2000WARE.

        uint16_t i,count = 0,buff_pos=0;
        while(count < numofSixteenByte)
        {
            status = handleNACK(base);
            if(status)
            {
              return status;
            }
    
            count++;
    
            attemptCount = 1;
            while(!(I2C_getRxFIFOStatus(base) == I2C_FIFO_RXFULL) && attemptCount <= 9 * (I2C_FIFO_RXFULL + 2U))
            {
                DEVICE_DELAY_US(I2C_Params->Delay_us);
                attemptCount++;
            }
    
            for(i=0; i<I2C_FIFO_LEVEL; i++)
            {
                I2C_Params->pRX_MsgBuffer[buff_pos++] = I2C_getData(base);
            }
        }

    Best,

    Kevin