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.

CC3220SF-LAUNCHXL: not able to read CHIP ID of BMM150 Sensor at Sensors Booster Pack?

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

Hi,

   When I try to read the CHIP ID of BMM150 I get the value 0xFF. The correct CHIP ID value is 0x32. Is there anything wrong with my I2C Code?

/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{
    unsigned int    i;

    int8_t MagX, MagY, MagZ;
    I2C_Handle      i2c;
    I2C_Params      i2cParams;

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

    /* Configure the LED pin */
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* 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 i2cbme280 example\n");

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

    // Init the BME280 API
    BMM150_init(i2c, 0x13);


    if (!BMM150_open())
    {
        Display_printf(display, 0, 0, "ERROR opening BMM150_open()\n"); //always go here
    }
    else
    {
        Display_printf(display, 0, 0, "BMM150 opened; polling every\r\n");

    }

#if 0
    /* Take 20 samples and print them out onto the console */
    for (i = 0; i < 50; i++)
    {
        // Read & interpret results, spitting to CIO console
        BMM150_ReadNew(&MagX, &MagY, &MagZ);

        sprintf(ubuf,
                "MagX: %d MagX: %d MagY: %d",
                (int16_t)MagX,
                (int16_t)MagY,
                (int16_t)MagZ);

        Display_printf(display, 0, 0, "%s", ubuf);

        /* Sleep for 1 second */
        sleep(1);
    }
#endif

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

    return (0);
}
bool BMM150_open(void)
{
    uint8_t readId;
    uint8_t reg_data;

    /* Power up the sensor from suspend to sleep mode */

    reg_data = BMM150_readReg(BMM150_POWER_CONTROL_ADDR); //0x4B
    reg_data = reg_data | BMM150_POWER_CNTRL_ENABLE; //0x01
    BMM150_writeReg(BMM150_POWER_CONTROL_ADDR, reg_data);

    // Start-up time delay of 3ms
    Task_sleep(BMM150_RESET_SETTLING_TIME);

    // Find Chip ID
    readId = BMM150_readReg(BMM150_CHIP_ID_ADDR); //0x40
    if (readId != BMM150_CHIP_ID) { // Not a BMM150? //0x32
        return false;
    }

    return true;
}
/// @brief Write a single 8-bit value to a specified memory address
void BMM150_writeReg(uint8_t memAddress, uint8_t value)
{
    I2C_Transaction txn;
    uint8_t wrBuf[2];

    txn.readBuf = NULL;
    txn.readCount = 0;
    txn.writeBuf = wrBuf;
    txn.writeCount = 2;
    txn.slaveAddress = i2cAddr;

    wrBuf[0] = memAddress;
    wrBuf[1] = value;

    I2C_transfer(i2cbus, &txn);
}

/// @brief Read a single 8-bit value from the specified memory address
uint8_t BMM150_readReg(uint8_t memAddress)
{
    I2C_Transaction txn;
    uint8_t regAddr = memAddress;
    uint8_t rdBuf;

    txn.readBuf = &rdBuf;
    txn.readCount = 1;
    txn.writeBuf = &regAddr;
    txn.writeCount = 1;
    txn.slaveAddress = i2cAddr;

    I2C_transfer(i2cbus, &txn);
    return rdBuf;
}

-kel

  • Hi Kel,

    It looks like you're opening your I2C peripheral with no index. You need to pass the I2C configuration from your board file to I2C_open().

    Best regards,
    Sarah

  • Hi Sarah,

    I modified the I2C code to this below and same results. 

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

    The problem is when I read the CHIP ID the value is 0xFF. The correct value is 0x32.

    bool BMM150_open(void)
    {
        uint8_t readId;
        uint8_t reg_data;
    
        /* Power up the sensor from suspend to sleep mode */
    
        reg_data = BMM150_readReg(BMM150_POWER_CONTROL_ADDR); //0x4B
        reg_data = reg_data | BMM150_POWER_CNTRL_ENABLE; //0x01
        BMM150_writeReg(BMM150_POWER_CONTROL_ADDR, reg_data);
    
        // Start-up time delay of 3ms
        Task_sleep(BMM150_RESET_SETTLING_TIME);
    
        // Find Chip ID
        readId = BMM150_readReg(BMM150_CHIP_ID_ADDR); //0x40
        if (readId != BMM150_CHIP_ID) { // Not a BMM150? //0x32
            return false;
        }
    
        return true;
    }

    -kel

  • Hi,

       I have tested the Sensors BoosterPack using the MSP-EXP432P401R SensorsGUI Example Program and I see the BMM150 working. I use a magnet to test if it works.

       Using the CC3220SF2 LP and Sensors Booster Pack I have communicated with TMP007 and BME280 sensors. But, communicating with BMM150 Geomagnetic sensor has some issues. 

       From the BMM150 datasheet, upon power up the device is in SUSPEND MODE. At SUSPEND MODE Power Control Register should be 0x00. To read the CHIP ID, need to set the BMM150 from SUSPEND MODE to SLEEP MODE by setting Power Control Register to 0x01. But upon power up I read Power Control Register value to be 0xFF, so there is already a problem there. Here is my test code below.

    void *mainThread(void *arg0)
    {
        //unsigned int    i;
        uint8_t         txBuffer[1];
        uint8_t         rxBuffer[2];
        uint8_t         wrBuf[2];
    
        //int8_t MagX, MagY, MagZ;
        I2C_Handle      i2c;
        I2C_Params      i2cParams;
        I2C_Transaction i2cTransaction;
    
        /* Call driver init functions */
        Display_init();
        GPIO_init();
        I2C_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* 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 i2cbmm150 example\n");
    
        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.transferMode = I2C_MODE_BLOCKING;
        i2cParams.transferCallbackFxn = NULL;
        i2cParams.bitRate = I2C_400kHz;
        i2c = I2C_open(Board_I2C0, &i2cParams);
        if (i2c == NULL) {
            Display_printf(display, 0, 0, "Error Initializing I2C\n");
            while (1);
        }
        else {
            Display_printf(display, 0, 0, "I2C Initialized!\n");
        }
    
        /* Point to the BMM150_POWER_CONTROL_ADDR and read its 2 bytes */
        txBuffer[0] = 0x4B;
        i2cTransaction.slaveAddress = 0x13;
        i2cTransaction.writeBuf = txBuffer;
        i2cTransaction.writeCount = 1;
        i2cTransaction.readBuf = rxBuffer;
        i2cTransaction.readCount = 1;
    
        I2C_transfer(i2c, &i2cTransaction);
    
        if(rxBuffer[0] == 0x00)
        {
            Display_printf(display, 0, 0,"BMM150 in SUSPEND MODE\n");
    
            wrBuf[0] = 0x4B;
            wrBuf[1] = rxBuffer[0] | 0x01;
    
            i2cTransaction.readBuf = rxBuffer;
            i2cTransaction.readCount = 2;
            i2cTransaction.writeBuf = wrBuf;
            i2cTransaction.writeCount = 1;
            i2cTransaction.slaveAddress = 0x13;
    
            I2C_transfer(i2c, &i2cTransaction);
    
            Display_printf(display, 0, 0,"BMM150 in SLEEP MODE\n");
    
            txBuffer[0] = 0x40;
            i2cTransaction.slaveAddress = 0x13;
            i2cTransaction.writeBuf = txBuffer;
            i2cTransaction.writeCount = 1;
            i2cTransaction.readBuf = rxBuffer;
            i2cTransaction.readCount = 2;
    
            I2C_transfer(i2c, &i2cTransaction);
    
            if (rxBuffer[0] == 0x32)
            {
                Display_printf(display, 0, 0,"CHIP ID is 0x32\n");
            }
            else
            {
                Display_printf(display, 0, 0,"CHIP ID is wrong");
            }
        }
        else
        {
            Display_printf(display, 0, 0,"BMM150 not in SUSPEND MODE\n");
        }
    
        I2C_close(i2c);
        Display_printf(display, 0, 0, "I2C closed!\n");
    
        return (0);
    }
    

    -kel

  • Mark -
    the BMM150 is connected only to the BMI160 on that board, and is accessed (indirectly) over I2C through the BM160 -
    see section three of the datasheet for the BM160, in regards to using the secondary interface
    ae-bst.resource.bosch.com/.../BST-BMI160-DS000-07.pdf, then please see the .c file here
    C:\Users\a0867749\Downloads\sail_1_20_00_02__all\sail_1_20_00_02\examples\rtos\CC3220SF_LAUNCHXL\sail\i2cbmi160, in which the BMM150 is supported.
  • Hi Josh,

    I tried the i2cbmi160_CC3220SF_LAUNCHXL_tirtos_ccs and it works. But, I need to change first the target config to CC3220SF_SWD.

    -kel
  • Hey Markel,

    Thanks for pointing out the bug. I develop SAIL plugin at TI, so i maybe able to help you.

    However, can you specify following things:

    1. Which version of SAIL and SDK are you using?
    2. Are you facing compilation or debugging issue?
    3. How were you able to resolve error?

    I tried to build the same project on CCS and i was able to compile it successfully.