Why is used in I2CMasterSendStop() infinite loop

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PeGu_352656
Level 2
Level 2

I use I2CMasterSendStop() function, but from time to time (not always) my program hangs in this infinite (for any reason) loop:

........

        while(!SHT_CHECK_INTR_MASTER(SHT_INTR_MASTER_I2C_STOP     |

                                                  SHT_INTR_MASTER_I2C_ARB_LOST |

                                                  SHT_INTR_MASTER_I2C_BUS_ERROR))

        {

            /* Wait until Stop has been generated */

        }

.........

What is the reason to have such a while ?

How can I avoid this problem?

Thank you

P

0 Likes
2 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

Do you have the I2C slave connected when the issue is happening? Which is your I2C slave?

Thanks,

Hima

0 Likes

Hi,

Yes, I have. It is SHT31 (humidity sensor). The problem I see is that SCL line stays low and I do not know who does pull down.

When I communicate with *ReadBuf* , it is working, but when I try with separate start, read, stop functions, something is wrong and it hangs. My problem is not that something is wrong, my problem is that the driver is written in such a way, that it hangs and I am not sure if I have to use cypress drivers and systems, because I do not know in how many places they have used this so "bright" idea to place infinite while.

Thank you

0 Likes