TMS320F2800157: I2C STT getting set unexpectedly by driverlib in conner case

Part Number: TMS320F2800157

Hi Experts,

We just find out the i2c driverlib function might cause the STT to be set unexpectly in some conner causes.

The typicle i2c examples uses the below sequence:

image.png

An interrupt may arrives between send start condition and send stop condition. which will delays the send stop condition a little bit.

In the I2C_sendStopCondition(I2CA_BASE);

 image.png

The |= operand is used, which would first read the MDR, calculate the logic OR. and then writes MDR.

in the mean time the I2C would clear the STT bit when the start condition has been sent, if this action happens to be between the |= operand, the STT bit would set unexpectedly.

Here's an example.

  1.  read MDR = (STT=1, STP=0) into temp reg, temp reg  = (STT=1, STP=0) 
  2.   STT get cleard by hardward MDR = (STT=0, STP=0)
  3.  Logic OR with STP bit, temp reg =  (STT=1, STP=1)
  4.  write MDR with temp reg, MDR =  (STT=1, STP=1)

A workaround is applyed by combining the the STT and STP set into a single writes, such that interrupt can't not come in.

Could you please check how this should be solved in the driberlib?

Regards,

Hang

 

  • Hi Hang,

    Can you confirm if the I2C controller has FIFO and repeat mode enabled? If so, you can try the following sequence: 

    Best Regards,

    Aishwarya

  • Hi Aishwarya,

    Sorry for missing some info. I met this case with repeat mode disabled. 

    Regards,

    Hang

  • Hang,

    Can you try the above solution and see if that helps with this case?

    In addition, before setting the stop condition, can you make sure that the start condition is properly set by polling for it? Which interrupt source is being taken in that interrupt you are referring to?

    Best Regards,

    Aishwarya

  • Hi Aishwarya,

    I think the solution is for repeat mode, right? I am using the non-repeat mode.

    Either way, I think the above solution so not for my issue because the error would occur when calling send stop condition, which is the very first step of the solution.

    The below four steps all happens within the I2C_sendStopCondition(I2CA_BASE);

    1.  read MDR = (STT=1, STP=0) into temp reg, temp reg  = (STT=1, STP=0) 
    2.   STT get cleard by hardward MDR = (STT=0, STP=0)
    3.  Logic OR with STP bit, temp reg =  (STT=1, STP=1)
    4.  write MDR with temp reg, MDR =  (STT=1, STP=1)

    The I2C_sendStopCondition(I2CA_BASE) function supposed to be setting STP without touching STT, however it toggles the STT in the process, that's the problem. 

    For the rest of your questions:

    STT is properly set properly for sure, otherwise this issue would not happen.

    The interrupt sources can be any interrupt in this case because the purpose of it is just bringing in some delay. I am not using interrupt for I2C function itself. Everything related to I2C is in back ground.

    Regards,

    Hang

  • Hi, 

    The expert is currently out of office until early next week. Please expect a response once they return to office. 

    Kind regards,

    AJ Favela