2 Replies Latest reply on Oct 18, 2018 11:33 PM by zzz_3221081

    How to access similar components in a loop by indexing?

      4 similar I2C-Components on my PSOC4 are polling sensors.

      The I2C components are named  I2C_1, I2C_2, I2C_3, I2C_4.

      Today i do something like this:

      poll I2C_1;

      poll I2C_2;

      poll I2C_3;

      poll I2C_4;


      in detail:


      i2cstatus_1 = I2C_1_I2CMasterSendStart(a,0,100);

      i2cstatus_2 = I2C_2_I2CMasterSendStart(a,0,100);

      i2cstatus_3 = I2C_3_I2CMasterSendStart(a,0,100);

      i2cstatus_4 = I2C_4_I2CMasterSendStart(a,0,100);


      but i want to do in a loop:


      for (componentnumber = 1; componentnumber <= 4; componentnumber ++)


        i2cstatus_componentnumber = I2C_componentnumber _I2CMasterSendStart(i,0,100);




      How can i put the named component into an indexed access?