5 Replies Latest reply on Apr 26, 2020 9:44 PM by cood_4686241

    How to read in multiple bytes on EZI2C?

    cood_4686241

      I am working on the challenge in the PSoC 101 tutorial video I2CReceive for the PSoC 4 pioneer kit.

      I am attempting to write a byte value to two different PWMs at different memory addresses to control the brightness of the on-board LED.

      However, I am only able to get a single PWM to work with the EZI2C receive module.

       

      This is my code with comments to explain what I did in attempt to control two PWMs:

       

      int main(void)

      {

          CyGlobalIntEnable; /* Enable global interrupts. */

        

          uint8 compare1 = 0;

          uint8 compare2 = 0;

      /*increased i2cbuf size to 2 to accept two bytes*/

          uint8 i2cbuf[2];

          i2cbuf[0] = 0;

          i2cbuf[1] = 0;

        

          PWM_Start();

      /*started second PWM module*/

          PWM_1_Start();

          I2C_Start();

       

      /*increased size of i2c buffer to 2*/

          I2C_EzI2CSetBuffer1( 2, 2, i2cbuf );

        

          for(;;)

          {

              if (compare1 != i2cbuf[0])

              {

                  compare1 = i2cbuf[0];

                  PWM_WriteCompare( compare1 );

              }

            

      /*added second compare statment to check if new data has been received*/

              if (compare2 != i2cbuf[1])

              {

                  compare2 = i2cbuf[1];

                  PWM_1_WriteCompare( compare2 );

              }

            

           

          }

      }

       

      In the bridge control panel, I send w 08 00 FF p and it works but when I send w 08 10 FF p (10 because that is the offset memory location) nothing happens.

      I have attached a picture of my TopDesign.cysch.