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.

AM2612: example for I2C_MODE_CALLBACK transferMode

Part Number: AM2612

Tool/software:

Hi, experts,

In SDK, the I2C examples are working in I2C_MODE_BLOCKING mode, that after calling I2C_Transfer(), the execution is blocked and only run out of I2C_Transfer() after transfer completed. Then, the application code can read the received data and prepare new data for sending.

Now, my customer need to use I2C in I2C_MODE_CALLBACK mode, that the execution is not blocked. The application code is notified by callback when the I2C transfer completed. Customer tried to call I2C_Transfer() to trigger the next I2C transfer in the callback but the execution stuck. Then customer tried to set a flag in the callback and polling this flag in main loop. If the flag is set, then call I2C_Transfer() to start the next transfer. It works in this way, but polling in main loop is too inefficiency.

Can you help to share an I2C example for I2C_MODE_CALLBACK transferMode? What is the suggested way to trigger the next I2C transfer when the previous one completed?

AM2612 I2C is working in target mode. 

gI2cPeripheralTransaction.controllerMode  = false;

Thanks.

  • Hi Fan,

    If I understand correctly, the request here is to have an I2C Callback example with the AM261x I2C in slave mode and non-blocking calls, in which the next I2C_Transfer() is ready to start (currently, you do not see this happen). Can you please share what the I2C Master here is?

    I believe if you are having an I2C transaction between 2 addresses (am261x slave and other I2C master), if you initiate another transaction before the previous one has finished, it will cause issues. I hope that is not the requirement here. Since there is only a single Data bus and Clock

    Regards,
    Shaunak

  • Hi, Shaunak,

    Yes, customer is asking for a I2C CALLBACK example in slave mode. As the callback is used to notify the completion of I2C transfer, so if it already runs into the callback, the previous I2C transfer is already finished, right? Customer want to know what is the suggested way/timing to start the next I2C transfer after the callback is called. He tried to call I2C_Transfer() in callback, but get stuck.

    In BLOCKING mode, the I2C transfer is finished when the execution runs out of I2C_Transfer(), and user can update gI2cPeripheralTransaction and call I2C_Transfer() again to start the next transfer.

    But in CALLBACK mode, the execution is not blocked, and user just get notified by callback function, the most efficient way is to start the next transfer in callback, but it seems not working.

  • Hi Fan,

    Can you please refer to the I2C_MEMORY_READ_INTERRUPT_LLD application from the SDK? This uses callbacks and semaphores to properly ensure the subsequent communications are started only when the Hardware controller is actually available to start a new transaction.

    Regarding the I2C Callback example in slave mode,

    He tried to call I2C_Transfer() in callback, but get stuck.

    1. By default all transactions and handle have been marked in controller mode (I2C_Transaction.controllerMode = true in HLD and I2CLLD_Handle.I2CLLD_Message.controllerMode=true in case of HLD). Before starting I2C transactions with AM261x in slave mode, you will have to set this controllerMode flag as False.

    2. Can you share details about the customer setup for testing am261x in slave mode? 

    Regards,
    Shaunak