1 Reply Latest reply on Nov 19, 2018 9:55 PM by ShanmathiN_06

    i2C SCB v4.0 not working the same as older component versions?

      I'm pulling my hair out.  The following code to get the 8 bytes of data from a I2C real time clock was working perfectly with an older I2C creator component with a pSOC4 pioneer kit.  Once I upgraded to the latest component, it no longer returns data.  Has anyone had similar issues and solved it?

       

      Get_Time();    

          /* Converting the received current time into string to display on the hyperterminal */   

             

              for(int8 index = 0; index < 8; index += 3)

              {

                  str_time[index] = ((Current_time[2 - (index/3)] & 0xF0) >> 4) + 0x30;

                  str_time[index + 1] = ((Current_time[2 - (index/3)] & 0x0F) + 0x30);

                  str_time[index + 2] = ':'; 

              }

              str_time[8]='\0';

             

                  str_date[0] = ((Current_time[5] & 0xF0) >> 4) + 0x30;

                  str_date[1] = ((Current_time[5] & 0x0F) + 0x30);

                  str_date[2] = '-';

                  str_date[3] = ((Current_time[3] & 0xF0) >> 4) + 0x30;

                  str_date[4] = ((Current_time[3] & 0x0F) + 0x30);

                  str_date[5] = '-';

                  str_date[6] = ((Current_time[6] & 0xF0) >> 4) + 0x30;

                  str_date[7] = ((Current_time[6] & 0x0F) + 0x30);     

              str_date[8]='\0';

             

                  UART_PutString(str_time);

                  UART_PutString("    ");

                  UART_PutString(str_date);

                  UART_PutChar('\n');

                  UART_PutChar('\r');

       

       

      void Get_Time(void){
         
        I2C_I2CMasterSendStart(I2C_ADDRESS, I2C_I2C_WRITE_XFER_MODE,40);
      I2C_I2CMasterWriteByte(SECOND, 40);
      I2C_I2CMasterReadBuf(I2C_ADDRESS, Current_time, NO_OF_BYTES, (I2C_I2C_MODE_REPEAT_START | I2C_I2C_MODE_COMPLETE_XFER));

      }

        • 1. Re: i2C SCB v4.0 not working the same as older component versions?
          ShanmathiN_06

          Hello,

           

          I see that you have used manual low-level API for write operation and buffer high-level APIs for read operation.

          It is not an expected use case to mix manual and buffer APIs.

          It is strictly recommended not to mix low level (byte) and high level (buffer) APIs.

          Buffer APIs check the state of I2C; If I2C state is not idle or halt, the API does nothing because it assumes that the master is busy.

           

          In SCB v3.20, the I2C state after using byte access APIs is idle or halt state.

          In SCB v4, the I2C state is read or write. This state could not be recognized by high level (buffer) APIs. That is the reason for the above piece of code to work in older versions.

           

          However, as this not an expected use case, you could use one of the following two methods in your application.

           

          1) Using low-level APIs

          I2CMasterSendStart

          I2CMasterWriteByte

          I2CMasterSendRestart

          I2CMasterReadByte

           

          2) Using high-level APIs

          I2CMasterWriteBuf

          while ((I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_WR_CMPLT) == 0u);

          I2CM_I2CMasterReadBuf

          while ((I2CM_I2CMasterStatus() & I2CM_I2C_MSTAT_RD_CMPLT) == 0u);

           

          Thanks,
          Shanmathi