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.

Tiva i2c problem

Hello!

When using I2C on EK_TM4C1294XL , if i not insert the software delay after the end of the frame,
BUSY flag is reset before acknowledgment data Slave device,
the next frame transmission starts very early,
which leads to the distortion data.

This code is work properly on LM3S9B92.

Help, please.

Thanks.

  • Hello Serg,

    This is a known issue in the TM4C129 device. The correct solution will be to use interrupts instead of polling. However if polling still needs to be used then add a SysCtlDelay(100); (the number 100 is arbitrarily based on the system clock it takes for the master to get busy) and then poll for the I2CMasterBusy Flag.

    The same can be searched on the forum as this is known.

    Regards
    Amit
  • Hello.

    I tried to insert software delay 128 cycles (120MHz)- it does not help.
    Delay 1024 cycle solved the problem for the RTC DS1338, but not enough to eeprom. In general, the addition of delays is not very correct decision ...

    This need hardware flags.

    Best regard,

    Serg

  • Hello Serg,

    That is why I suggested using the Interrupt mechanism. Only when the interrupt is asserted for a command completion, does the CPU set a flag in the interrupt handler . Till then it waits in a while looping waiting for the flag ton get set.

    Regards
    Amit
  • Could you give an example with  the interruption to transmit and receive multiple frames

  • Hello Serg,

    I don't have a ready example for the same in TivaWare, but if you can start a basic code, I can help correct and get it working.

    Regards
    Amit
  • EK-TM4C123GHL has the same problem?



    Best regard,

    Serg
  • Hello Serg,

    I believe you may be right as some time back the forum had a post for the same on TM4C123. I have not been able to reproduce the same on my LaunchPad though.

    Regards
    Amit
  • Hello.
    Tell me, please, about using the Interrupt mechanism. I2cMaster Interrupt ? What do in this?

    Best regard,

    Serg
  • Hello Serg

    Did you check the TivaWare Peripheral User Guide? Do check it for exact syntax and parameters.

    1. Declare a global variable and init it to 0 in the main
    2. Enable the Data Interrupt IM bit
    3. Declare a I2C Interrupt function in the main code and add it to the vector table in the startup file to position corresponding to the I2C module instance
    4. After starting a transaction put a while loop waiting for the global variable to be 1.
    5. After every transaction, the interrupt will be asserted and CPU will branch to the Interrupt function. there check the source of interrupt, clear it if it is Data Interrupt, then set the global variable flag.
    6. The while loop will now be broken for the code to proceed. Do clear it before starting the next transaction.

    Regards
    Amit