This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/SIMPLELINK-CC2640R2-SDK: interfacing High-Sensitivity Pulse Oximeter and Heart-Rate Sensor MAXREFDES117

Part Number: LAUNCHXL-CC2640R2
Other Parts Discussed in Thread: CC2640R2F

Tool/software: Code Composer Studio

HI,

i am unable to get the data from the IR sensor led (0x0d) and RED led (0x0c). i want to read the data from that registers .

and i am not getting the interrupt pin in the board then which code i will write to make any pin to interrupt pin.

my code is :-

*/
#include <stdint.h>
#include <stddef.h>
#include <unistd.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/I2C.h>
#include <ti/display/Display.h>

/* Example/Board Header files */
#include "Board.h"

#define I2C_WRITE_ADDR 0xAE
#define I2C_READ_ADDR 0xAF

//register addresses
#define REG_INTR_STATUS_1 0x00
#define REG_INTR_STATUS_2 0x01
#define REG_INTR_ENABLE_1 0x02
#define REG_INTR_ENABLE_2 0x03
#define REG_FIFO_WR_PTR 0x04
#define REG_OVF_COUNTER 0x05
#define REG_FIFO_RD_PTR 0x06
#define REG_FIFO_DATA 0x07
#define REG_FIFO_CONFIG 0x08
#define REG_MODE_CONFIG 0x09
#define REG_SPO2_CONFIG 0x0A
#define REG_LED1_PA 0x0C
#define REG_LED2_PA 0x0D
#define REG_PILOT_PA 0x10
#define REG_MULTI_LED_CTRL1 0x11
#define REG_MULTI_LED_CTRL2 0x12
#define REG_TEMP_INTR 0x1F
#define REG_TEMP_FRAC 0x20
#define REG_TEMP_CONFIG 0x21
#define REG_PROX_INT_THRESH 0x30
#define REG_REV_ID 0xFE
#define REG_PART_ID 0xFF


#define true 1
#define false 0
#define FS 25 //sampling frequency
#define BUFFER_SIZE (FS* 4)
#define MA4_SIZE 4 // DONOT CHANGE
#define min(x,y) ((x) < (y) ? (x) : (y))

//uch_spo2_table is approximated as -45.060*ratioAverage* ratioAverage + 30.354 *ratioAverage + 94.845 ;
const uint8_t uch_spo2_table[184]={ 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99,
99, 99, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97,
97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91,
90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 82, 82, 81, 81,
80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 74, 73, 72, 72, 71, 70, 69, 69, 68, 67,
66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50,
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29,
28, 27, 26, 25, 23, 22, 21, 20, 19, 17, 16, 15, 14, 12, 11, 10, 9, 7, 6, 5,
3, 2, 1 } ;


static Display_Handle display;

/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{

uint8_t txBuffer[3];
uint8_t rxBuffer[2];
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;

/* Call driver init functions */
Display_init();
GPIO_init();
I2C_init();

/* Open the HOST display for output */
display = Display_open(Display_Type_UART, NULL);
if (display == NULL) {
while (1);
}

/* Turn on user LED */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
Display_printf(display, 0, 0, "Starting the i2ctmp007 example\n");

/* Create I2C for usage */
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2c = I2C_open(Board_I2C_TMP, &i2cParams);
if (i2c == NULL) {
Display_printf(display, 0, 0, "Error Initializing I2C\n");
while (1);
}
else {
Display_printf(display, 0, 0, "I2C Initialized!\n");
}
while(1)
{


/* INTR_ENABLE 1*/

txBuffer[0] = REG_INTR_ENABLE_1; /* 0x02 */
txBuffer[1]=0xc0; /* write data 0xc0 into interrupt enable 1 */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;

/* INTR_ENABLE 2*/

txBuffer[0] = REG_INTR_ENABLE_2; /*0x03 */
txBuffer[1]=0x00; /* write data 0x00 into interrupt enable 2 */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;


/* FIFO WRITE POINTER*/

txBuffer[0] = REG_FIFO_WR_PTR; /* 0x04*/
txBuffer[1]=0x00; /* write data 0x00 into fifo write pointer */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;

/* FIFO OVERFLOW COUNTER*/

txBuffer[0] = REG_OVF_COUNTER; /* 0x05*/
txBuffer[1]=0x00; /* write data 0x00 into fifo over flow counter */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;

/* FIFO read POINTER*/

txBuffer[0] = REG_FIFO_RD_PTR; /* 0x06*/
txBuffer[1]=0x00; /* write data 0x00 into fifo write pointer */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;

/* FIFO CONFIGURATION*/

txBuffer[0] = REG_FIFO_CONFIG; /* 0x08*/
txBuffer[1]=0x4F; /* write data 0x00 into fifo write pointer */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;


/* mode configuration */
txBuffer[0] = REG_MODE_CONFIG; /* mode configuration address 0x09 */
txBuffer[1]=0x03; /* Configuration of HR mode by write data 0xc2 in mode config*/
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;


/* spo2 configuration*/
txBuffer[0] = REG_SPO2_CONFIG; /* 0x0A*/
txBuffer[1]=0x27; /* write data 0x00 into SPO2 CONFIGURATION */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;

/* PILOT MODE*/

txBuffer[0] =REG_PILOT_PA ;/*0x10*/
txBuffer[1] =0x7F ; /* WRITE 0X7F INTO PILOT */
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;


/* LED 1 enable */
txBuffer[0] = REG_LED1_PA ; /* 0x0c*/
txBuffer[1] =0x24 ; /* write 0x24 into led 1*/
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;
i2cTransaction.readBuf = rxBuffer; /* read led 1 data */
i2cTransaction.readCount =2;

if (I2C_transfer(i2c, &i2cTransaction)) {


Display_printf(display, 0, 0, "led1 %x _%x (C)\n", txBuffer[0],txBuffer[1]);
Display_printf(display, 0, 0, "rled1 %x _ %x (C)\n", rxBuffer[0],rxBuffer[1]);
}


/* LED 2 enable */
txBuffer[0] =REG_LED2_PA ; /* 0x0d*/
txBuffer[1] =0x24 ; /* write 0x24 into led 2*/
i2cTransaction.slaveAddress = 0x57;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 2;
i2cTransaction.readBuf = rxBuffer; /* read led 2 data */
i2cTransaction.readCount =2;

if (I2C_transfer(i2c, &i2cTransaction)) {


Display_printf(display, 0, 0, "led2 %x _ %x (C)\n", txBuffer[0],txBuffer[1]);
Display_printf(display, 0, 0, "rled2 %x _ %x (C)\n", rxBuffer[0],rxBuffer[1]);
}


else {
Display_printf(display, 0, 0, "I2C Bus fault\n");
}

sleep(1);

}

/* Deinitialized I2C */
I2C_close(i2c);
Display_printf(display, 0, 0, "I2C closed!\n");

return (NULL);
}

 

and the display output is 

  • Part Number: LAUNCHXL-CC2640R2

    Tool/software: Code Composer Studio

    HELLO,

    My task is to read the heart rate and pulse oximeter using maxrefdes117 (max30102) and the interfacing address is 0x57. I am facing various problems in writing the coding into ccs. 

    These problems are as:

     1. Which pin of CC2640R2F is Interrupt pin and if there is no interrupt pin then how i will define interrupt pin.

     2. From which register i will read data ,which code is missing and how i complete it.

     3.how i calculate HR and Spo2

    please check my code and suggest what problem i done in it and what should i add in it

    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>

    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/I2C.h>
    #include <ti/display/Display.h>

    /* Example/Board Header files */
    #include "Board.h"

    #define I2C_WRITE_ADDR 0xAE
    #define I2C_READ_ADDR 0xAF

    //register addresses
    #define REG_INTR_STATUS_1 0x00
    #define REG_INTR_STATUS_2 0x01
    #define REG_INTR_ENABLE_1 0x02
    #define REG_INTR_ENABLE_2 0x03
    #define REG_FIFO_WR_PTR 0x04
    #define REG_OVF_COUNTER 0x05
    #define REG_FIFO_RD_PTR 0x06
    #define REG_FIFO_DATA 0x07
    #define REG_FIFO_CONFIG 0x08
    #define REG_MODE_CONFIG 0x09
    #define REG_SPO2_CONFIG 0x0A
    #define REG_LED1_PA 0x0C
    #define REG_LED2_PA 0x0D
    #define REG_PILOT_PA 0x10
    #define REG_MULTI_LED_CTRL1 0x11
    #define REG_MULTI_LED_CTRL2 0x12
    #define REG_TEMP_INTR 0x1F
    #define REG_TEMP_FRAC 0x20
    #define REG_TEMP_CONFIG 0x21
    #define REG_PROX_INT_THRESH 0x30
    #define REG_REV_ID 0xFE
    #define REG_PART_ID 0xFF


    #define true 1
    #define false 0
    #define FS 25 //sampling frequency
    #define BUFFER_SIZE (FS* 4)
    #define MA4_SIZE 4 // DONOT CHANGE
    #define min(x,y) ((x) < (y) ? (x) : (y))

    //uch_spo2_table is approximated as -45.060*ratioAverage* ratioAverage + 30.354 *ratioAverage + 94.845 ;
    const uint8_t uch_spo2_table[184]={ 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99,
    99, 99, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
    100, 100, 100, 100, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97,
    97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91,
    90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 82, 82, 81, 81,
    80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 74, 73, 72, 72, 71, 70, 69, 69, 68, 67,
    66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50,
    49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29,
    28, 27, 26, 25, 23, 22, 21, 20, 19, 17, 16, 15, 14, 12, 11, 10, 9, 7, 6, 5,
    3, 2, 1 } ;


    static Display_Handle display;

    /*
    * ======== mainThread ========
    */
    void *mainThread(void *arg0)
    {

    uint8_t txBuffer[3];
    uint8_t rxBuffer[2];
    I2C_Handle i2c;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction;

    /* Call driver init functions */
    Display_init();
    GPIO_init();
    I2C_init();

    /* Open the HOST display for output */
    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
    while (1);
    }

    /* Turn on user LED */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    Display_printf(display, 0, 0, "Starting the i2ctmp007 example\n");

    /* Create I2C for usage */
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_400kHz;
    i2c = I2C_open(Board_I2C_TMP, &i2cParams);
    if (i2c == NULL) {
    Display_printf(display, 0, 0, "Error Initializing I2C\n");
    while (1);
    }
    else {
    Display_printf(display, 0, 0, "I2C Initialized!\n");
    }
    while(1)
    {


    /* INTR_ENABLE 1*/

    txBuffer[0] = REG_INTR_ENABLE_1; /* 0x02 */
    txBuffer[1]=0xc0; /* write data 0xc0 into interrupt enable 1 */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* INTR_ENABLE 2*/

    txBuffer[0] = REG_INTR_ENABLE_2; /*0x03 */
    txBuffer[1]=0x00; /* write data 0x00 into interrupt enable 2 */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* FIFO WRITE POINTER*/

    txBuffer[0] = REG_FIFO_WR_PTR; /* 0x04*/
    txBuffer[1]=0x00; /* write data 0x00 into fifo write pointer */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO OVERFLOW COUNTER*/

    txBuffer[0] = REG_OVF_COUNTER; /* 0x05*/
    txBuffer[1]=0x00; /* write data 0x00 into fifo over flow counter */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO read POINTER*/

    txBuffer[0] = REG_FIFO_RD_PTR; /* 0x06*/
    txBuffer[1]=0x00; /* write data 0x00 into fifo write pointer */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO CONFIGURATION*/

    txBuffer[0] = REG_FIFO_CONFIG; /* 0x08*/
    txBuffer[1]=0x4F; /* write data 0x00 into fifo write pointer */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* mode configuration */
    txBuffer[0] = REG_MODE_CONFIG; /* mode configuration address 0x09 */
    txBuffer[1]=0x03; /* Configuration of HR mode by write data 0xc2 in mode config*/
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* spo2 configuration*/
    txBuffer[0] = REG_SPO2_CONFIG; /* 0x0A*/
    txBuffer[1]=0x27; /* write data 0x00 into SPO2 CONFIGURATION */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* PILOT MODE*/

    txBuffer[0] =REG_PILOT_PA ;/*0x10*/
    txBuffer[1] =0x7F ; /* WRITE 0X7F INTO PILOT */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* LED 1 enable */
    txBuffer[0] = REG_LED1_PA ; /* 0x0c*/
    txBuffer[1] =0x24 ; /* write 0x24 into led 1*/
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;
    i2cTransaction.readBuf = rxBuffer; /* read led 1 data */
    i2cTransaction.readCount =2;

    if (I2C_transfer(i2c, &i2cTransaction)) {


    Display_printf(display, 0, 0, "led1 %x _%x (C)\n", txBuffer[0],txBuffer[1]);
    Display_printf(display, 0, 0, "rled1 %x _ %x (C)\n", rxBuffer[0],rxBuffer[1]);
    }


    /* LED 2 enable */
    txBuffer[0] =REG_LED2_PA ; /* 0x0d*/
    txBuffer[1] =0x24 ; /* write 0x24 into led 2*/
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;
    i2cTransaction.readBuf = rxBuffer; /* read led 2 data */
    i2cTransaction.readCount =2;

    if (I2C_transfer(i2c, &i2cTransaction)) {


    Display_printf(display, 0, 0, "led2 %x _ %x (C)\n", txBuffer[0],txBuffer[1]);
    Display_printf(display, 0, 0, "rled2 %x _ %x (C)\n", rxBuffer[0],rxBuffer[1]);
    }


    else {
    Display_printf(display, 0, 0, "I2C Bus fault\n");
    }

    sleep(1);

    }

    /* Deinitialized I2C */
    I2C_close(i2c);
    Display_printf(display, 0, 0, "I2C closed!\n");

    return (NULL);
    }

        

    the output of this program is 

  • Hi,

    For your first question, any IO can be used for pin interrupt. We have pin interrupt examples for all our CC26xx/CC13xx devices and package.

    For other questions related to sensor, I would recommend you to post on the product forum or to contact the support for the sensor module.

  • Merging the thread since it's the same question.

    For the pin interrupt, please see the examples we have provided in our software package.

    For the I2C problem, can you provide logic analyzer trace so we can know if there is actual data flowing between the 2 devices.
  • hello,

    pin interrupt problem is solve by using led 0 as a interrupt pin.

    My next problem is that , i am  unable  to read data from red led and IR Led sensor . i2c is already done and the logic analyzer ouput is 

    my update code is give below

    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>

    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/I2C.h>
    #include <ti/display/Display.h>

    /* Example/Board Header files */
    #include "Board.h"

    #define I2C_WRITE_ADDR 0xAE
    #define I2C_READ_ADDR 0xAF
    #define I2C_SLAVE_ADDR 0x57
    //register addresses
    #define REG_INTR_STATUS_1 0x00
    #define REG_INTR_STATUS_2 0x01
    #define REG_INTR_ENABLE_1 0x02
    #define REG_INTR_ENABLE_2 0x03
    #define REG_FIFO_WR_PTR 0x04
    #define REG_OVF_COUNTER 0x05
    #define REG_FIFO_RD_PTR 0x06
    #define REG_FIFO_DATA 0x07
    #define REG_FIFO_CONFIG 0x08
    #define REG_MODE_CONFIG 0x09
    #define REG_SPO2_CONFIG 0x0A
    #define REG_LED1_PA 0x0C
    #define REG_LED2_PA 0x0D
    #define REG_PILOT_PA 0x10
    #define REG_MULTI_LED_CTRL1 0x11
    #define REG_MULTI_LED_CTRL2 0x12
    #define REG_TEMP_INTR 0x1F
    #define REG_TEMP_FRAC 0x20
    #define REG_TEMP_CONFIG 0x21
    #define REG_PROX_INT_THRESH 0x30
    #define REG_REV_ID 0xFE
    #define REG_PART_ID 0xFF


    static Display_Handle display;

    /*
    * ======== mainThread ========
    */
    void *mainThread(void *arg0)
    {

    uint8_t txBuffer[3];
    uint8_t rxBuffer[2];
    I2C_Handle i2c;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction;

    /* Call driver init functions */
    Display_init();
    GPIO_init();
    I2C_init();

    /* Open the HOST display for output */
    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
    while (1);
    }

    /* Turn on user LED AND make LED pin to interrupt */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    Display_printf(display, 0, 0, "Starting the i2ctmp007 example\n");
    GPIO_enableInt(Board_GPIO_LED0); /* led 0 is a interrupt pin*/

    /* Create I2C for usage */
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_400kHz;
    i2c = I2C_open(Board_I2C_TMP, &i2cParams);
    if (i2c == NULL) {
    Display_printf(display, 0, 0, "Error Initializing I2C\n");
    while (1);
    }
    else {
    Display_printf(display, 0, 0, "I2C Initialized!\n");
    }


    while(1)
    {


    /* INTR_ENABLE 1*/

    txBuffer[0] = REG_INTR_ENABLE_1; /* 0x02 */
    txBuffer[1]=0xf1; /* write data 0xc0 into interrupt enable 1 */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* INTR_ENABLE 2*/

    txBuffer[0] = REG_INTR_ENABLE_2; /*0x03 */
    txBuffer[1]=0x01; /* write data 0x00 into interrupt enable 2 */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO WRITE POINTER*/

    txBuffer[0] = REG_FIFO_WR_PTR; /* 0x04*/
    txBuffer[1]=0x00; /* write data 0x00 into fifo write pointer */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO OVERFLOW COUNTER*/

    txBuffer[0] = REG_OVF_COUNTER; /* 0x05*/
    txBuffer[1]=0x00; /* write data 0x00 into fifo over flow counter */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO read POINTER*/

    txBuffer[0] = REG_FIFO_RD_PTR; /* 0x06*/
    txBuffer[1]=0x00; /* write data 0x00 into fifo write pointer */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* FIFO CONFIGURATION*/

    txBuffer[0] = REG_FIFO_CONFIG; /* 0x08*/
    txBuffer[1]=0x5F; /* write data 0x00 into fifo write pointer */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* mode configuration */
    txBuffer[0] = REG_MODE_CONFIG; /* mode configuration address 0x09 */
    txBuffer[1]=0xc3; /* Configuration of spo2 mode by write data 0xc2 in mode config*/
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* spo2 configuration*/
    txBuffer[0] = REG_SPO2_CONFIG; /* 0x0A*/
    txBuffer[1]=0x23; /* write data 0x00 into SPO2 CONFIGURATION */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;

    /* PILOT MODE*/

    txBuffer[0] =REG_PILOT_PA ;/*0x10*/
    txBuffer[1] =0x7F ; /* WRITE 0X7F INTO PILOT */
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;


    /* LED 1 enable */
    txBuffer[0] = REG_LED1_PA ; /* 0x0c*/
    txBuffer[1] =0x03 ; /* write 0x03 into led 1*/
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;
    i2cTransaction.readBuf = txBuffer; /* read led 1 data */
    i2cTransaction.readCount =2;

    if (I2C_transfer(i2c, &i2cTransaction)) {


    Display_printf(display, 0, 0, "led1 %x _%x (C)\n", txBuffer[0],txBuffer[1]);

    }


    /* LED 2 enable */
    txBuffer[0] =REG_LED2_PA ; /* 0x0d*/
    txBuffer[1] =0x03 ; /* write 0x03 into led 2*/
    i2cTransaction.slaveAddress = 0x57;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 2;
    i2cTransaction.readBuf = txBuffer; /* read led 2 data */
    i2cTransaction.readCount =2;

    if (I2C_transfer(i2c, &i2cTransaction)) {


    Display_printf(display, 0, 0, "led2 %x _ %x (C)\n", txBuffer[0],txBuffer[1]);

    }


    else {
    Display_printf(display, 0, 0, "I2C Bus fault\n");
    }

    // sleep(1);

    }

    /* Deinitialized I2C */
    I2C_close(i2c);
    Display_printf(display, 0, 0, "I2C closed!\n");

    return (NULL);
    }

    i am not getting the data from registers plz check my code and give the solution to my problem 

  • Hi,

    First can you post the schematic of the design you are using and also the connection you made from CC2640R2F to the other board?

    The signal you captured using oscilloscope does not look right to me, can you take a picture of the setup and post it here.

    If you CC2640R2F is already sending the correct signal and there is no response, then you need to contact whoever made the sensors to get the support.
  • hello ,

    1. I am able to read the device temperature.

    2. I am able to read the FIFO DATA REGISTERS (0x07)  and the data of the register is changes when some obstacle come near to the device or we can say that the red and ir led is on and work as a proximity sensor .

    in my coding i used spo2 mode by putting 0x03 into the mode configuration (0x09) and my problem is that how will i differenciate the ir and red led data from reading the FIFO DATA REGISTER(0X07).

    what will be my further steps to differenciate the the ir data and red led data out of these 6 buffers data

    the my code and display data is given below and please check my code by reading max30102 datsheet.

    #include <stdint.h>

    #include <stddef.h>

    #include <unistd.h>

    /* Driver Header files */

    #include <ti/drivers/GPIO.h>

    #include <ti/drivers/I2C.h>

    #include <ti/display/Display.h>

    /* Example/Board Header files */

    #include "Board.h"

    #define I2C_WRITE_ADDR 0xAE

    #define I2C_READ_ADDR 0xAF

    #define I2C_SLAVE_ADDR 0x57

    //register addresses

    #define REG_INTR_STATUS_1 0x00

    #define REG_INTR_STATUS_2 0x01

    #define REG_INTR_ENABLE_1 0x02

    #define REG_INTR_ENABLE_2 0x03

    #define REG_FIFO_WR_PTR 0x04

    #define REG_OVF_COUNTER 0x05

    #define REG_FIFO_RD_PTR 0x06

    #define REG_FIFO_DATA 0x07

    #define REG_FIFO_CONFIG 0x08

    #define REG_MODE_CONFIG 0x09

    #define REG_SPO2_CONFIG 0x0A

    #define REG_LED1_PA 0x0C

    #define REG_LED2_PA 0x0D

    #define REG_PILOT_PA 0x10

    #define REG_MULTI_LED_CTRL1 0x11

    #define REG_MULTI_LED_CTRL2 0x12

    #define REG_TEMP_INTR 0x1F

    #define REG_TEMP_FRAC 0x20

    #define REG_TEMP_CONFIG 0x21

    #define REG_PROX_INT_THRESH 0x30

    #define REG_REV_ID 0xFE

    #define REG_PART_ID 0xFF

    static Display_Handle display;

    /*

    *  ======== mainThread ========

    */

    void *mainThread(void *arg0)

    {

       uint8_t         txBuffer[9];

       uint8_t         rxBuffer[3];

       I2C_Handle      i2c;

       I2C_Params      i2cParams;

       I2C_Transaction i2cTransaction;

       /* Call driver init functions */

       Display_init();

       GPIO_init();

       I2C_init();

       /* Open the HOST display for output */

       display = Display_open(Display_Type_UART, NULL);

       if (display == NULL) {

           while (1);

       }

       /* Turn on user LED AND make  LED pin to interrupt */

       GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);

       Display_printf(display, 0, 0, "Starting the i2ctmp007 example\n");

       GPIO_enableInt(Board_GPIO_LED0); /* led 0 is a interrupt pin*/

       /* Create I2C for usage */

       I2C_Params_init(&i2cParams);

       i2cParams.bitRate = I2C_400kHz;

       i2c = I2C_open(Board_I2C_TMP, &i2cParams);

       if (i2c == NULL) {

           Display_printf(display, 0, 0, "Error Initializing I2C\n");

           while (1);

       }

       else {

           Display_printf(display, 0, 0, "I2C Initialized!\n");

       }

       while(1)

                                                           {

           /* interrupt enable 1 */

                          txBuffer[0] = 0x02 ; /* 0x02*/

                          txBuffer[1] =0xc0 ;   /* write 0xc0 into interrupt enable 1*/

                          i2cTransaction.slaveAddress = 0x57;

                          i2cTransaction.writeBuf = txBuffer;

                          i2cTransaction.writeCount = 2;

                          i2cTransaction.readBuf = txBuffer; /* read  data */

                          i2cTransaction.readCount =2;

                          if (I2C_transfer(i2c, &i2cTransaction)) {

                                                                  }

                          /* INTERRUPT ENABLE 2 */

                                         txBuffer[0] = 0x03 ; /* 0x03*/

                                         txBuffer[1] =0x00 ;   /* write 0x00 into INTERRUPT ENABLE 2*/

                                         i2cTransaction.slaveAddress = 0x57;

                                         i2cTransaction.writeBuf = txBuffer;

                                         i2cTransaction.writeCount = 2;

                                         i2cTransaction.readBuf = txBuffer; /* read  data */

                                         i2cTransaction.readCount =2;

                                         if (I2C_transfer(i2c, &i2cTransaction)) {  }

                                         /* FIFO write pointer */

                   txBuffer[0] = 0x04 ; /* 0x04*/

                   txBuffer[1] =0x00 ;   /* write 0x00 into FIFO WRITE POINTER*/

                   i2cTransaction.slaveAddress = 0x57;

                   i2cTransaction.writeBuf = txBuffer;

                   i2cTransaction.writeCount = 2;

                   i2cTransaction.readBuf = txBuffer; /* read  data */

                   i2cTransaction.readCount =1;

                   if (I2C_transfer(i2c, &i2cTransaction)) {

                                                                                                              }

                   /* FIFO OVERFLOW*/

                      txBuffer[0] = 0x05 ; /* 0x05*/

                      txBuffer[1] =0x00 ;   /* write 0x00 into FIFO OVERFLOW*/

                      i2cTransaction.slaveAddress = 0x57;

                      i2cTransaction.writeBuf = txBuffer;

                      i2cTransaction.writeCount = 2;

                      i2cTransaction.readBuf = txBuffer; /* read  data */

                      i2cTransaction.readCount =1;

                      if (I2C_transfer(i2c, &i2cTransaction)) {

                                                           }

                           /* FIFO CONFIG */

                                                txBuffer[0] = 0x08 ; /* 0x04*/

                                                txBuffer[1] =0x1f ;   /* write 0x00 into FIFO CONFIG*/

                                                i2cTransaction.slaveAddress = 0x57;

                                                i2cTransaction.writeBuf = txBuffer;

                                                i2cTransaction.writeCount = 2;

                                                i2cTransaction.readBuf = txBuffer; /* read  data */

                                                i2cTransaction.readCount =1;

                                                if (I2C_transfer(i2c, &i2cTransaction)) {

                                                                                    }

                           /*  mode configuration */

          txBuffer[0] = REG_MODE_CONFIG; /* mode  configuration address 0x09 */

          txBuffer[1]=0x03;                 /* Configuration of spo2 mode by write data 0x03 in mode config*/

          i2cTransaction.slaveAddress = 0x57;

          i2cTransaction.writeBuf = txBuffer;

          i2cTransaction.writeCount = 2;

          i2cTransaction.readBuf = txBuffer;

          i2cTransaction.readCount =1;

          if (I2C_transfer(i2c, &i2cTransaction)) {

          }

          /* spo2 configuration*/

                    txBuffer[0] = REG_SPO2_CONFIG; /* 0x0A*/

                    txBuffer[1]=0x27;                 /* write data 0x27 into SPO2 CONFIGURATION */

                    i2cTransaction.slaveAddress = 0x57;

                    i2cTransaction.writeBuf = txBuffer;

                    i2cTransaction.writeCount = 2;

                    i2cTransaction.readBuf = txBuffer;

                    i2cTransaction.readCount =1;

                    if (I2C_transfer(i2c, &i2cTransaction)) {

                    }

                    /* LED 1 enable */

                txBuffer[0] = 0x0c ; /* 0x0c*/

                txBuffer[1] =0x24 ;   /* write 0x03 into led 1*/

                i2cTransaction.slaveAddress = 0x57;

                i2cTransaction.writeBuf = txBuffer;

                i2cTransaction.writeCount = 2;

                i2cTransaction.readBuf = txBuffer; /* read led 1 data */

                i2cTransaction.readCount =1;

                if (I2C_transfer(i2c, &i2cTransaction)) {

                                }

                /* pilot mode */

                                txBuffer[0] =0x10 ; /* 0x0d*/

                                txBuffer[1] =0x7f ; /* write 0x03 into led 2*/

                                i2cTransaction.slaveAddress = 0x57;

                                i2cTransaction.writeBuf = txBuffer;

                                i2cTransaction.writeCount = 2;

                                i2cTransaction.readBuf =rxBuffer; /* read led 2 data */

                                i2cTransaction.readCount =1;

                                if (I2C_transfer(i2c, &i2cTransaction)) {

                                                }

                     /* LED 2 enable */

                    txBuffer[0] =0x0d ; /* 0x0d*/

                    txBuffer[1] =0x28 ; /* write 0x03 into led 2*/

                    i2cTransaction.slaveAddress = 0x57;

                    i2cTransaction.writeBuf = txBuffer;

                    i2cTransaction.writeCount = 2;

                    i2cTransaction.readBuf =rxBuffer; /* read led 2 data */

                    i2cTransaction.readCount =1;

                    if (I2C_transfer(i2c, &i2cTransaction)) {

                                    }

                    /* FIFO READ pointer */

                             txBuffer[0] = 0x06 ; /* 0x06*/

                             i2cTransaction.slaveAddress = 0x57;

                             i2cTransaction.writeBuf = txBuffer;

                             i2cTransaction.writeCount = 1;

                             i2cTransaction.readBuf = txBuffer; /* read  data */

                             i2cTransaction.readCount =1;

                             if (I2C_transfer(i2c, &i2cTransaction)) {

                                                                  }

                    /* FIFO DATA REGISTER */

                                          txBuffer[0] = 0x07 ; /* 0x04*/

                                          i2cTransaction.slaveAddress = 0x57;

                                          i2cTransaction.writeBuf = txBuffer;

                                          i2cTransaction.writeCount = 1;

                                          i2cTransaction.readBuf = txBuffer; /* read  data */

                                          i2cTransaction.readCount =9;

                                          if (I2C_transfer(i2c, &i2cTransaction)) {

                                                                            Display_printf(display, 0, 0, "data=%x  %x  %x %x  %x  %x ", txBuffer[0],txBuffer[1],txBuffer[2], txBuffer[3],txBuffer[4],txBuffer[5]);

                                                                               }

    sleep(1);

                    /* temperature config*/

                    txBuffer[0] =REG_TEMP_CONFIG;

                    txBuffer[1]=0x01; /* enable the temperature sensor 0x01 in tempconfig*/

                    i2cTransaction.slaveAddress = 0x57;

                    i2cTransaction.writeBuf = txBuffer;

                    i2cTransaction.writeCount = 2;

                    i2cTransaction.readBuf = txBuffer; /* read config register data */

                    i2cTransaction.readCount =2;

                    if (I2C_transfer(i2c, &i2cTransaction)) {

                                             }

                    /* temperature measurement*/

    txBuffer[0] = REG_TEMP_INTR;

    i2cTransaction.slaveAddress = 0x57;

    i2cTransaction.writeBuf = txBuffer;

    i2cTransaction.writeCount = 1;

    i2cTransaction.readBuf = txBuffer; /* read the temperature in integer form data */

    i2cTransaction.readCount =2;

    if (I2C_transfer(i2c, &i2cTransaction)) {

    Display_printf(display, 0, 0, "temp=%d", txBuffer[0]);

    }

           else {

               Display_printf(display, 0, 0, "I2C Bus fault\n");

                }

                  //    sleep(1);

    }

       /* Deinitialized I2C */

       I2C_close(i2c);

       Display_printf(display, 0, 0, "I2C closed!\n");

       return (NULL);

    }

  • The question you have posted does not relate to our device. You need to contact the support group for the sensor you are using.
    There is no more we can do for you at this point. I am closing this thread.
  • Part Number: LAUNCHXL-CC2640R2

    Tool/software: Code Composer Studio

     HELLO,
    I  am unable to calculate the heart rate and SPO2 by using ir and red led data. i am using maxrefdes117 and interfacing with cc2640r2f board .
    give the algorithm or calculation steps to solve the  heart rate and spo2 from led datas.
    the output display is given below


    this is simply  the led data which is directly read from the register and after that what i will do
    thanks