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.

AM6442: M4F I2C not working on MCU+SDK 11.0.0.15

Part Number: AM6442
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello,

I am trying to use MCU_I2C0 on the M4F after upgrading to MCU+SDK 11.0.0.15. I am using the high-level driver and the I2C_transfer() function is always returning the status I2C_STS_ERR_TIMEOUT. Previously, I was using MCU+SDK 9.1.0.41, which had I2C working correctly. I should also note that the M4F is running FreeRTOS and communicating to the A53 (running Linux) using IPC RPMsg.

Here is my code to perform an I2C transfer on the M4F:

#define I2C_BUF_SIZE 16u
#define I2C_TIMEOUT_MS 100u

uint8_t i2c_rx_buf[I2C_BUF_SIZE] = {0u};
uint8_t i2c_tx_buf[I2C_BUF_SIZE] = {0u};
I2C_Handle i2c_handle;
I2C_Transaction i2c_transaction_handle;

static int32_t i2c_transfer_msg(uint8_t i2c_send_buf[], uint8_t send_buf_len, uint8_t i2c_recv_buf[], uint8_t recv_buf_len, uint8_t i2c_addr)
{
    if ((i2c_send_buf == NULL) || (i2c_recv_buf == NULL)) // Ensure the pointers aren't NULL
    {
        return I2C_STS_ERR;
    }
    
    memset(i2c_rx_buf, 0, I2C_BUF_SIZE); // Clear the I2C Rx buffer
    
    int32_t status;
    
    i2c_transaction_handle.targetAddress = i2c_addr;
    i2c_transaction_handle.writeBuf = i2c_send_buf;
    i2c_transaction_handle.writeCount = send_buf_len;
    i2c_transaction_handle.readBuf = i2c_recv_buf;
    i2c_transaction_handle.readCount = recv_buf_len;
    i2c_transaction_handle.timeout = I2C_TIMEOUT_MS;
    //i2c_transaction_handle.controllerMode = true;
    //i2c_transaction_handle.expandSA = false;
    
    status = I2C_transfer(i2c_handle, &i2c_transaction_handle);
    
    if (status != I2C_STS_SUCCESS)
    {
        status = I2C_recoverBus(gI2cHandle[CONFIG_I2C0], I2C_TIMEOUT_MS);
    }

    memset(i2c_tx_buf, 0, I2C_BUF_SIZE); // Clear the I2C Tx buffer

    return status;
}

Here is my sysconfig for I2C:

I should also note that MCU_I2C0 did not initialize correctly until I changed this line in the I2C_open() function found in ${MCU+SDK}/source/drivers/i2c/v0/i2c_v0.c.

I have I/O connected to I2C, and it would be really nice to get it working with this new MCU+SDK version.

Thanks for your help!

  • Hi Brycen,

    Thanks for reporting the above bug. Yes, the AddrTranslateP_getLocalAddr() API call is required to translate the RAT address configured for M4F core. 

    I will raise an internal Jira ticket to get it fixed by next release.

    Regards,

    Tushar

  • Hi Tushar -

    1) are we talking the release of MCU+SDK v11.1 to rectify?

    2) You may want to check if the AM62x MCU+SDK will have the same problem with their M4F core.

    later

    Jim

  • Hi Jim,

    1) are we talking the release of MCU+SDK v11.1 to rectify?

    Yes, you are correct.

    2) You may want to check if the AM62x MCU+SDK will have the same problem with their M4F core

    The AM62x SDK has correct implementation.

    Please refer below image.

    Regards,

    Tushar

  • Hi Tushar,

    Is there a way I get the M4's I2C to work with the new MCU+SDK? Or will it be fixed in the next release? After upgrading to MCU+SDK 11.0, whenever I initiate an I2C transfer, the I2C bus hangs and the message is never sent. This was not the case in MCU+SDK 9.1.

    I'm confused as to which of the two bugs I mentioned in my original post will be fixed in the next release.

    Thanks,

    Brycen

  • Hi Brycen

    Please refer the steps suggested at faq-processor-sdk-am64x-not-able-to-open-i2c-drivers-for-mcu-i2c.

    Regards,

    Tushar

  • Hi Tushar,

    I have tried this and I'm still unable to use the M4F I2C. Whenever I use the I2C_transfer() function, the data doesn't send and it returns with I2C_STS_ERR_TIMEOUT. I have verified that no data is being transferred on the I2C bus using a logic analyzer. This functionality worked for me previously on MCU+SDK 9.1, so I'm unsure why it doesn't work here.

    Thanks,

    Brycen

  • Hi Brycen,

    I have tested the example on my end and it is working as expected. Can you please confirm are you able to probe the I2C device using I2C_probe() API?

    Also please make sure the device is properly connected and powered.

    Regards,

    Tushar

  • Hi Tushar,

    Thanks for showing my the I2C_probe() API function. Using this in combination with the logic analyzer showed me that I2C is working on the M4F. My problem was that my timeout period was set to 100ms (this worked previously on the MCU+SDK 9.1 and is about 10x longer than the maximum response time of my I2C sensor). 

    Why is it that once a timeout occurs the I2C bus is unrecoverable? I was trying to recover it using this function:

    status = I2C_recoverBus(gI2cHandle[CONFIG_I2C0], I2C_TIMEOUT_MS);

    After removing the timeout set in i2c_transaction_handle (in my original code), then I2C worked. Can you show me how to properly using the I2C timeout to reset the I2C bus?

    Thanks for all your help,

    Brycen

  • Hi Brycen,

    Can you try configuring different values for the timeout?

    Below are the few macros which are used with I2C_recoverBus() API in the SDK. Please refer below image.

    Please try with the above values once and update the results.

    Regards,

    Tushar

  • Hi Tushar,

    I have tried the values you provided and they appear to function correctly. My I2C does not constantly return the I2C_STS_ERR_TIMEOUT status.

    Thanks for all of your help!

    Brycen