Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMA 456 not getting acceleration data using I2C.

    BMA 456 not getting acceleration data using I2C.

    RoyceThomas
    New Poster

    Hi,

    I'm currently developing a system that collects accelerometer data and uploads it to cloud and I'm using a BMA456 connected to a Quectel BC66-NA NB-IoT module communicating over i2c. I was able to initialize and configure the accelerometer sensor but when trying to read the data, there is no data coming in the registers.Also the sensor returns no error.

    Can anyone please tell me what I'm missing? Below is my code.

    void proc_main_task(s32 taskId)
    {
        s32 ret;    
        i2c_init();
        i2c_config();
    
        uint16_t rslt = BMA4_OK;
        
        /* Declare an instance of the BMA456 device */
        struct bma4_dev dev;
        
        /* Modify the parameters */
        dev.dev_addr = BMA4_I2C_ADDR_PRIMARY;
        dev.interface = BMA4_I2C_INTERFACE;
        dev.bus_read = USER_i2c_read;
        dev.bus_write = USER_i2c_write;
        dev.delay = Ql_Sleep;
        dev.read_write_len = 8;
    
        APP_DEBUG("\r\n<--Initializing BMA 456-->\r\n");
        /* Initialize the instance */
        rslt |= bma456_init(&dev);
        APP_DEBUG("\r\n<--bma456_init--> rslt = %d-->\r\n", rslt);
        if (rslt != BMA4_OK){
                APP_DEBUG("\r\n<--Accelerometer Initialization Failed--> rslt = %d-->\r\n", rslt);
                return rslt;
            }
        if (rslt == BMA4_OK){
            APP_DEBUG("\r\n<--Accelerometer Initialization Success--> rslt = %d-->\r\n", rslt);
        }
        APP_DEBUG("\r\n<--Enabling the Accelerometer Sensor-->\r\n");
    
        /* Enable the accelerometer */
        bma4_set_accel_enable(BMA4_ACCEL_ENABLE_MSK, &dev);
    
        APP_DEBUG("\r\n<--Configuring the Accelerometer Sensor-->\r\n");
        
        /* Declare an accelerometer configuration structure */
        struct bma4_accel_config accel_conf;
        
        /* Assign the desired settings */
        accel_conf.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
        accel_conf.perf_mode = BMA4_CONTINUOUS_MODE;
        accel_conf.range = BMA4_ACCEL_RANGE_4G;
        accel_conf.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
        
        /* Set the configuration */
        rslt |= bma4_set_accel_config(&accel_conf, &dev);
        APP_DEBUG("\r\n<--bma4_set_accel_config--> rslt = %d-->\r\n", rslt);
        if (rslt != BMA4_OK){
                APP_DEBUG("\r\n<--Accelerometer Configuration Failed--> rslt = %d-->\r\n", rslt);
                return rslt;
            }
        if (rslt == BMA4_OK){
            APP_DEBUG("\r\n<--Accelerometer Configuration Success--> rslt = %d-->\r\n", rslt);
        }
    
        /* Declare an instance of the sensor data structure */
        struct bma4_accel sens_data;
    
        /* Loop forever */
        while (1) {
            /* Read the sensor data into the sensor data instance */
            rslt |= bma4_read_accel_xyz(&sens_data, &dev);
            APP_DEBUG("\r\n<--bma4_read_accel_xyz--> rslt = %d-->\r\n", rslt);
            
            /* Exit the program in case of a failure */
            if (rslt != BMA4_OK){
                APP_DEBUG("\r\n<--Accelerometer Read Failed--> rslt = %d-->\r\n", rslt);
                return rslt;
            }
            
            /* Use the data */
            APP_DEBUG("<--X: %d, Y: %d, Z: %d-->\r\n", sens_data.x, sens_data.y, sens_data.z);
           
            /* Pause for 10ms, 100Hz output data rate */
            Ql_Sleep(10);
        }
    }
    2 REPLIES 2

    shellywang
    Occasional Contributor

    Could you provide more detail information ?

    1. Does BMA456 directly use NB-IOT module internal i2c interface, Quectel supplier should provide special hw/sw to enable i2c function.

    2、Can chip ID be read?

    3、Checked the code, i2c driven is not included in the main function, if necessary, upload complete code.

    4、during code running, rather use logic analyzer capture I2C waveform and VDD power supply for further analysis

    BSTRobin
    Community Moderator
    Community Moderator

    Since there was no feedback for a long time, we close this topic first. You could update feedback in the future if you have.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist