I2C read and write pointers overlap with databytes

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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?

0 Likes
5 Replies
Anonymous
Not applicable

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.

0 Likes
Anonymous
Not applicable

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.

0 Likes
Anonymous
Not applicable

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)

0 Likes
Anonymous
Not applicable

Were you able to sort out this problem? I'm working on a similar project and was wondering how you declare your I2C_1_I2CMasterSendStart(), I2C_1_I2CMasterWriteByte() and I2C_1_I2CMasterSendStop() functions? I've been having trouble with getting mine working. If possible could you elaborate on these functions? The problem could also be within them.

0 Likes
Anonymous
Not applicable

This project example demonstrates the I2C Master usage: http://www.cypress.com/documentation/code-examples/ce95363-i2c-master-using-serial-communication-blo...

This document has descriptions of the I2C components: http://www.cypress.com/file/130966/download

If you right-click the I2C component in the top level design page of your project, and select the "Open Datasheet" it should open a PDF similar to the document linked above, showing you datasheet information on the specific I2C component and version that you are using with descriptions of code examples, function usage, and configuration/setup.

0 Likes