3 Replies Latest reply on May 4, 2017 8:44 AM by e.pratt_1639216

    I2C read and write pointers overlap with databytes

    jponsa15_2282296

      I'm currently working on a sensor (MAX30105) connected to a PSoC 4200M via I2C that delivers data through an 18 bit ADC.

         

      The write and read registers are 5 bits, and I'm reading samples by taking the difference between the read and write pointers and reading that amount.

         

      Whenever I do this, it seems the read and write pointers are part of the data I'm sampling and sending through to my receiver.

         

      I cannot seem to see how this is happening.

         

      The image attached from top to bottom: IR_L, IR_M, IR_L, with a difference of 256, and the bottom increment is resetting at 31, which made me question if this was the pointers.

         

      Is this a normal problem, and how to remove it?

        • 1. Re: I2C read and write pointers overlap with databytes
          e.pratt_1639216

          Try clearing your read buffer after sending the I2C FIFODATA read command; At line 320/321 just before starting the FOR loop.

             

          Looking at your usage of the MAXIM I2C interface protocol, could it be that you have the MAXIM sensor misconfigured for behavior involving the FIFO buffer?

             

          Edit: Also, the documentation claims there are 3 channels of 3 data bytes each, so this would indicate that you need to read 3 times as many bytes to go through the FIFO data.

          • 2. Re: I2C read and write pointers overlap with databytes
            esmede14_2259266

            After sending read byte to the FIFODATA, is it not locked to read? In which case, sending a write byte to the read pointer would overrule the current read on the FIFODATA, so the read byte would not be from the FIFODATA any longer.

               

            It is possible that it is configured wrong about the FIFO buffer. We are not quite sure in that area, since this is a first time working with either PSoC, I2C or sensors. What usage are you talking about specifically?

               

            There are indeed 3 channels. However, in our case, 2 of the channels are turned off and only SLOT1 is active. At least it should be.

            • 3. Re: I2C read and write pointers overlap with databytes
              e.pratt_1639216

              After sending read byte to the FIFODATA, is it not locked to read?

                 

              Sorry esmede, I meant clear the PSoC 4200 buffere, not the read buffer on the maxim chip.

                 

              It is possible that it is configured wrong about the FIFO buffer. We are not quite sure in that area, since this is a first time working with either PSoC, I2C or sensors. What usage are you talking about specifically?

                 

              I am referring to the Maxim FIFO buffer. There are some configuration settings for the FIFO buffer on the Maxim sensor that allow various modes of operation depending on your need, and I would suggest reading through the datasheet on it to see if there are modes/settings that you need to make sure are configured before it will behave the way you want it to. The PSoC and I2C communications seemed fine to me (I didn't look very deep however), and thus I would suspect the issue is not with the communication to the Maxim sensor chip, but rather with the Maxim sensor chip not being set to respond the way you expect it to.

                 

              The Maxim datasheet here: https://www.maximintegrated.com/en/products/analog/sensors-and-sensor-interface/MAX30105.html contains pseudocode of how to read data from it, but looking at the code in your project, it seems to match up correctly :)

                 

              You could try checking the return value from the I2C functions you are calling in the PSoC to make sure they are passing ok (without error return values).

                 

              Is there a way you can verify that the data you are reading in from the I2C bus is valid for the data? (Either the Read/Write pointers of the FIFO data buffer, or the sensor ADC18 reading)