Please share an example code for ADPD144RI read data from ESP32 or Arduino
ADPD144RI
Not Recommended for New Designs
The ADPD144RI is a highly integrated, photometric front end optimized for photoplethysmography (PPG) detection of blood oxygenation (SpO2) by synchronous...
Datasheet
ADPD144RI on Analog.com
Please share an example code for ADPD144RI read data from ESP32 or Arduino
Hi Subbu,
I would suggest two change, since your are not using driver API's.
AdpdDrvGetParameter() This API will give the available bytes in the FIFO. we need to ensure that required data's are accumulated in FIFO before reading it.
Regarding FIFO clear mechanism you can follow the data sheet sequence. In driver file we are following same sequence as mentioned in data sheet.
Regards,
Sathishkumar K
1.
The FIFO read API is modified to enable FIFO clock before reading
AdpdDrvRegWrite(0x0010, 0x0001);
AdpdDrvRegWrite(0x005f, 0x0001);
AdpdDrvRegWrite(0x005f, 0x0001);
AdpdDrvRegWrite(0x0010, 0x0002);
#define ADPDDrv_SUCCESS (0) #define ADPDDrv_ERROR (-1) #define ADPD_I2C_ADDRESS (0x64) #include <uart_debug.h> void main(void) { uint32_t LoopCnt = 0; uint8_t value[16] = {0}; uint16_t nAdpdFifoLevelSize = 64, nAdpdDataSetSize; uint16_t nLoopLim = 16; uint16_t nAdpdDataSetSize = 8; uint16_t nRetValue = 0; AdpdDrvInit(); while (1) { nRetValue = AdpdDrvReadFifoData(&value[0], nAdpdDataSetSize); if (nRetValue == ADPDDrv_SUCCESS) { for (LoopCnt = 0; LoopCnt < nLoopLim; LoopCnt += 2) { UART_Print("%u ", (value[LoopCnt] << 8) | value[LoopCnt + 1]); nAdpdFifoLevelSize = nAdpdFifoLevelSize - nAdpdDataSetSize; } } } } int16_t AdpdDrvReadFifoData(uint8_t *pnData, uint16_t nDataSetSize) { uint8_t nGetFifoData, nAddr; nAddr = 0x60; AdpdDrvRegWrite(0x0010, 0x0001); AdpdDrvRegWrite(0x005f, 0x0001); AdpdDrvRegWrite(0x005f, 0x0001); AdpdDrvRegWrite(0x0010, 0x0002); if (ADPD_I2C_TxRx((uint8_t *) &nAddr, pnData, nDataSetSize) != HAL_OK) return ADPDDrv_ERROR; return ADPDDrv_SUCCESS; } bool ADPD_I2C_TxRx(unsigned char* pTxData, unsigned char* pRxData, unsigned int Size) { HAL_I2C_Master_Transmit(&hi2c2, (uint16_t)(ADPD_I2C_ADDRESS << 1), (uint8_t *)pTxData, Size, 100); return (HAL_STATUS_t)HAL_I2C_Master_Receive(&hi2c2, (uint16_t)(ADPD_I2C_ADDRESS << 1), pRxData, Size, 100); } int16_t AdpdDrvRegWrite(uint16_t nAddr, uint16_t nRegValue) { uint8_t anI2cData[3]; anI2cData[0] = (uint8_t)nAddr; anI2cData[1] = (uint8_t)(nRegValue >> 8); anI2cData[2] = (uint8_t)(nRegValue); if (ADPD_I2C_Transmit((uint8_t *)anI2cData, 3) != ADI_HAL_OK) return ADPDDrv_ERROR; return ADPDDrv_SUCCESS; } AdpdDrvInit() { //Init code }
2.
I will add the API to check the available FIFO bytes before reading the FIFO data. I will update this code and share.
I was having indefinite loop to read the data. This code was shared above.
Now I have changed the indefinite loop - while (1) to read the fifo data, based on the bytes of data available to readdata size.
Now after adding this API - AdpdDrvGetParameter(), I could only get 128-bytes of data.
I could see only 4 reads and each read gets us 32 byte of Data (Total 128-BYTES) . After each read fifo reset is happening, but after the board is power cycled, We could still read the cached data and that is the same data we have received before power cycle.
Dear Glen,
Yes, We have set the register 0x10 to 0x0002 after the configuration is loaded. Although, We have done this, the LEDs are not glowing. I have measured the 3V, 1.8V supplies, They are fine.
Can you share the sample data that is expected when We load the suggested configuration both in open condition and when finger is placed over the device.
What is the maximum value of pulse width that we can set..?
Hi there,
I have updated the code and attached as main_v3.rft, can run this code to get the data from FIFO
Thank You Satish. I will test this and get back to you.
Satish, This started giving continuous data, but I still see the FIFO not getting cleared. Are there any more debugging points for me to debug? I have re-verified the init part again and please find attached the init code. Please do let me know, if this is correct.
Hi,
In the AdpdDrvInit() function AdpdDrvRegWrite(0x0010, 0x0002); sample mode register is set as running mode.
Just remove that line in AdpdDrvInit() function, this sample mode setting will take care in AdpdDrvSetOperationMode() API.
There is no need to clear the FIFO after putting device into sample mode, every FIFO read will clear the bytes which have read it out.