1 Reply Latest reply on Oct 17, 2019 5:47 AM by EktaN_26

    I2C Slave write busy and write complete

    SaGh_4441651

      I am trying to implement my SCB block as a I2C slave. I need to check 2 conditions and set certain flags. The two conditions are - I2C_1_I2C_SSTAT_WR_BUSY and I2C_1_I2C_SSTAT_WR_CMPLT

       

      I am using the callback api - I2C_1_I2C_ISR_ExitCallback() and in this function I check the slave status using the function I2C_1_I2CSlaveStatus(). The debug session hits the breakpoint in the I2C_1_I2C_SSTAT_WR_BUSY check, but it never hits the break point for I2C_1_I2C_SSTAT_WR_CMPLT flag.

       

      Can anyone tell me if I am doing anything wrong here? Also is the api callback - I2C_1_I2C_SlaveCompleteCallback() a better way to check if the slave write was complete?

       

      I also found that I could use I2C_1_SetSlaveInterruptMode(I2C_1_INTR_SLAVE_I2C_WRITE_STOP) - What is the difference between the usage of all these fucntions? Which one is the best to be used in my case?

        • 1. Re: I2C Slave write busy and write complete
          EktaN_26

          Hello,

           

          1. I have created a small code example for checking these two conditions. In the example I am using LED's to determine whether the I2C_1_I2C_SSTAT_WR_BUSY (Blue led) and I2C_1_I2C_SSTAT_WR_CMPLT (Red led) conditions are are triggered. I am setting a flag in the I2C_1_I2C_ISR_ExitCallback() function. Depending whether the flag is set or not the I2C_1_I2C_SSTAT_WR_CMPLT or the I2C_1_I2C_SSTAT_WR_BUSY status is checked in the main loop.

           

          I have used the Bridge control panel to send data, and I can see both the LED's glow, i.e. the Red led followed by Blue led.

           

          Please have a look at the project, in case you still face an issue, please attach your project so that we can have a look at it and try to recreate the issue at our side.

           

          2.  The I2C_1_I2C_SlaveCompleteCallback() will be called when the master completes read/write operation on the slave. You can use it, if you want to do any processing when this event occurs.

           

          3. The I2C_1_I2C_SetSlaveInterruptMode() can be used to configures which bits from Slave interrupt request register will trigger an interrupt event.

           

          The I2C_1_I2C_ISR_ExitCallback() can be used in your case to check 2 conditions and set certain flags.

          Best Regards

          Ekta