I2C Reset PSoC Creator 3.3

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

cross mob
CeGu_1509311
Level 2
Level 2
First like received

Hi everyone,

   

 

   

I had a similar situation to the topic posted here: http://www.cypress.com/forum/psoc-4-architecture/reset-i2c

   

I'm trying to communicate with an I2C device but sometimes the device is hung up, (SDA low), and it doesn't work until I turn off the power, I was trying to use teh directives of the previous post, but the new component doesn't include them.

   

 

   

    while(I2C_1_sda_Read() == 0) // SDA hang low
    {
        I2C_1_SET_I2C_SCL_HSIOM_SEL(I2C_1_HSIOM_GPIO_SEL); //Switch to GPIO    
        I2C_1_scl_Write(0);
        CyDelay(1);
        I2C_1_scl_Write(1);
        CyDelay(1);
        I2C_1_SET_I2C_SCL_HSIOM_SEL(I2C_1_HSIOM_I2C_SEL); //Switch to Component
    }
    I2C_1_I2CMasterSendStop();

   

 

   

Is there another way to reset the I2C bus and get out from the infinite loop (Waiting ACK or NACK) in case the device got hung in the middle of the program?

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

I have seen solutions to pull down the sda low for 9 or more clock cycles. This will be seen by "hanging" slaves as a lost arbitration and will release the bus cancelling current transmission. There is a generated file.h for the sda pin. Use those functions to access the pin directly.

   

When starting a master-slave communication, try to check the result from I2C_SendStart() and in case of error do no further access.

   

 

   

Bob

0 Likes