Avoid I2C_MasterStatus() Continuous Polling on I2C

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

cross mob
Anonymous
Not applicable

Hi All,

   

     I am using Cypress PSoC 5LP for communicating with sensor over I2C Bus.

   

PSoC acts as master while sensor act as slave device.

   

PSoC sends read command to sensor. Sensor responds after 80ms with 3 Bytes reading.(Hold master SCK Line pull low)

   

I am getting the data properly without any error.

   

 

   

Stat = I2C_MasterReadBuf(DeviceAddress, pBuffer, NumBytes, I2C_MODE_COMPLETE_XFER);

   

if(Stat == I2C_MSTR_NO_ERROR)
{

   

             while (0u == (I2C_MasterStatus() & I2C_MSTAT_RD_CMPLT))
            {
                   /* Waits until master completes Read operation */
            }

   

}

   

As per the code snippet master polls in while loop for almost 80ms till data comes.

   

How can I avoid this polling?

   

Is there is any other API which tells when data is available now read it?

   

Thanks & Regards,

   

Pratik Pawar

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum, Patrik.

   

What do you want to do in that 80 ms? Go ahead and do it, then check again for transmission completed.

   

 

   

Bob

View solution in original post

0 Likes
2 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum, Patrik.

   

What do you want to do in that 80 ms? Go ahead and do it, then check again for transmission completed.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi,

   

Thanks Bob for Reply.
I was calling mentioned I2C API in an structured software functions. I was passing address of the local buffer to receive I2C message. Now I am going to implement with Global buffer. So that message will be stored & I can used it later point of time.

   

In that 80ms I want to listen messages on UART also. 

   

Thanks again 🙂

   

Pratik 

0 Likes