Hi AD Team,
We are using the MAX30102 sensor in one of our use cases and are encountering an issue while attempting to read continuous data from the sensor.
After the initial sensor configuration, we start reading data by first checking the FIFO sample count (register address 0x06) and the FIFO write pointer (register address 0x04). We then read the sensor data from the FIFO data register (0x07).
However, after successfully reading the first few samples, the sensor starts responding with NAK, and all subsequent register reads return 0x00 with proper ack after the NAK. It appears that something is going wrong during the continuous read operation.
Could you please help us understand if we are missing any required FIFO handling or if there are any known issues related to continuous data reads from the MAX30102?
Thank you for your support.
Best regards,
Jakir Hussain
Renesas India


here is initialization code:
max_config max30102_configuration = {
.INT_EN_1.A_FULL_EN = 1,
.INT_EN_1.PPG_RDY_EN = 1,
.INT_EN_1.ALC_OVF_EN = 0,
.INT_EN_1.PROX_INT_EN = 0,
.INT_EN_2.DIE_TEMP_RDY_EN = 0,
.FIFO_WRITE_PTR.FIFO_WR_PTR = 0,
.OVEF_COUNTER.OVF_COUNTER = 0,
.FIFO_READ_PTR.FIFO_RD_PTR = 0,
.FIFO_CONF.SMP_AVE = 0b010, //média de 4 valores
.FIFO_CONF.FIFO_ROLLOVER_EN = 0, //fifo rollover enable
.FIFO_CONF.FIFO_A_FULL = 0, //0
.MODE_CONF.SHDN = 0,
.MODE_CONF.RESET = 0,
.MODE_CONF.MODE = 0b011, //SPO2 mode
.SPO2_CONF.SPO2_ADC_RGE = 0b01, //16384 nA(Escala do DAC)
.SPO2_CONF.SPO2_SR = 0b000, //100 samples per second
.SPO2_CONF.LED_PW = 0b10, //pulso de 215 uS do led.
.LED1_PULSE_AMP.LED1_PA = 0x24, //CORRENTE DO LED1 25.4mA
.LED2_PULSE_AMP.LED2_PA = 0x24, //CORRENTE DO LED2 25.4mA
.PROX_LED_PULS_AMP.PILOT_PA = 0X7F,
.MULTI_LED_CONTROL1.SLOT2 = 0, //Desabilitado
.MULTI_LED_CONTROL1.SLOT1 = 0, //Desabilitado
.MULTI_LED_CONTROL2.SLOT4 = 0, //Desabilitado
.MULTI_LED_CONTROL2.SLOT3 = 0, //Desabilitado
};
void esp32_max30102_init(max_config *configuration)
{
uint8_t val=0;
read_max30102_reg(0,&val,1);// dummy read
read_max30102_reg(0,&val,1); // dummy read
write_max30102_reg(0x40, REG_MODE_CONFIG);
utils_delay_ms(300);
write_max30102_reg(0x80, REG_MODE_CONFIG);
utils_delay_ms(200);
write_max30102_reg(configuration->data2, REG_INTR_ENABLE_2);
write_max30102_reg(configuration->data3, REG_FIFO_WR_PTR);
write_max30102_reg(configuration->data4, REG_OVF_COUNTER);
write_max30102_reg(configuration->data5, REG_FIFO_RD_PTR);
write_max30102_reg(configuration->data6, REG_FIFO_CONFIG);
write_max30102_reg(configuration->data7, REG_MODE_CONFIG);
write_max30102_reg(configuration->data8, REG_SPO2_CONFIG);
write_max30102_reg(configuration->data9, REG_LED1_PA);
write_max30102_reg(configuration->data10, REG_LED2_PA);
write_max30102_reg(configuration->data11, REG_PILOT_PA);
write_max30102_reg(configuration->data12, REG_MULTI_LED_CTRL1);
write_max30102_reg(configuration->data13, REG_MULTI_LED_CTRL2);
write_max30102_reg(0x03, REG_MODE_CONFIG);
}
void fill_buffer_data(void)
{
static uint16_t readIndex=0;
uint8_t readPointer =0,status=0;
uint8_t writePointer=0;
read_max30102_reg(REG_FIFO_WR_PTR, &writePointer, 1);
read_max30102_reg(REG_FIFO_RD_PTR, &readPointer, 1);
read_max30102_reg(REG_INTR_STATUS_1, &status, 1);
int numberOfSamples = 0;
uint8_t activeLEDs = 2; //Red + IR
//Do we have new data?
if ((readPointer != writePointer) )
{
//Calculate the number of readings we need to get from sensor
numberOfSamples = writePointer - readPointer;
if (numberOfSamples < 0)
numberOfSamples += 32; //Wrap condition
//We now have the number of readings, now calc bytes to read
//For this example we are just doing Red and IR (3 bytes each)
int bytesLeftToRead = numberOfSamples * activeLEDs * 3;
while (bytesLeftToRead > 0)
{
read_max30102_fifo(&red_data, &ir_data);
ir_data_buffer[readIndex] = ir_data;
red_data_buffer[readIndex] = red_data;
//log_debug("IR:%d RD:%d\n", ir_data,red_data);
ir_data = 0;
red_data = 0;
bytesLeftToRead -= 6;
if(readIndex++ >= BUFFER_SIZE)
readIndex=0;
g_max30102_data_available = 1;
}
}
}