cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding the Data in the MAX30102 FIFO Buffer

chai2145
Associate III

Hi, 

SofLit  @PGump.1 @

When reading the FIFO buffer through I2C read command, we typically retrieve 6 bytes of data: 3 bytes for the Red LED value and 3 bytes for the IR LED value.

The question is: how is the data arranged in the 6-byte buffer?

Is it organized such that bytes 0 to 2 represent the Red LED data, and bytes 3 to 5 represent the IR LED data?

I also noticed that some  MAX30102 firmware driver using bytes 0 to 2 represent the raw IR LED data, 3 to 5 represent LED raw data and vice versa.

I'm a bit confused about how the data is arranged when reading multiple bytes. Could you clarify the orientation of the data in the buffer?

chai2145_1-1734075824085.png

 

void MAX301ReadFifoNew(void)
{
	uint32_t irBuff[32];
	uint32_t redBuff[32];
	
	// Get 32 samples of data
	for (int8_t i = 0; i < 32; i++)
	{
		uint8_t address;
		uint8_t buf[6];
		uint8_t numBytes = 6;  // Buffer for IR (3 bytes) + RED (3 bytes)
		
		I2C_HandleTypeDef i2cHandle = GetI2cHandle(MAX301_I2C_NUM);
		
		buf[0] = FIFO_DATA;
		address = (I2C_SLAVE_ID | I2C_WRITE);
		
		HAL_I2C_Master_Transmit(&i2cHandle, address, buf, 1, HAL_MAX_DELAY);
		
		address = (I2C_SLAVE_ID | I2C_READ);
		HAL_I2C_Master_Receive(&i2cHandle, address, buf, numBytes, HAL_MAX_DELAY);
		
//		uint32_t irSample = ((uint32_t)(buf[0] << 16) | (uint32_t)(buf[1] <<  | (uint32_t)(buf[2])) & 0x3ffff;
//		uint32_t redSample = ((uint32_t)(buf[3] << 16) | (uint32_t)(buf[4] <<  | (uint32_t)(buf[5])) & 0x3ffff;
		
		uint32_t redSample = ((uint32_t)(buf[0] << 16) | (uint32_t)(buf[1] <<  | (uint32_t)(buf[2])) & 0x3ffff;
		uint32_t irSample = ((uint32_t)(buf[3] << 16) | (uint32_t)(buf[4] <<  | (uint32_t)(buf[5])) & 0x3ffff;
		
		irBuff[i] = irSample;
		redBuff[i] = redSample;
	}
	DEBUG_PRINTF("Read FIFO end...");
}

 

 

3 REPLIES 3

@chai2145 wrote:

The question is: how is the data arranged in the 6-byte buffer?


That's a question for the chip manufacturer - Analog Devices - nothing to do with ST or STM32:

https://www.analog.com/en/products/max30102.html

https://www.analog.com/en/support.html

https://ez.analog.com/search?engineerzone%5Bquery%5D=max30102

https://ez.analog.com/other-products

https://ez.analog.com/optical_sensing/

Ok. To understand the behavior of I2C when reading multiple byte, is the first byte received is stored in buf[0], the second byte in buf[1], and the third byte in buf[2]?

Yes.