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/BOOSTXL-SENSHUB: Setting the sampling rate of the accelerometer sensor at compdcm_mpu9150

Part Number: BOOSTXL-SENSHUB

Tool/software: Code Composer Studio

Helo,

I managed to get the mpu9150 Accel/gyro/mag sensor with the tm4c123 - with the provided sample code. (compdcm_mpu9150). I have simplified the code a bit, taking out led driver, and serial output in order to measure the speed that the data is sampled at from the sensor.

Instead of measuring sample rate programmatically, I have attached a scope to GPIOB PIN 2, and I am able to see the interrupt happening from the sensor, and it looks like 20ms each reading approximately.

I tried to find relevant parts of the code, but I could not find where to adjust the sample rate.

    // Write application specific sensor configuration such as filter settings
    // and sensor range settings.
    g_sMPU9150Inst.pui8Data[0] = MPU9150_CONFIG_DLPF_CFG_94_98;
    //g_sMPU9150Inst.pui8Data[0] = MPU9150_CONFIG_DLPF_CFG_184_188;
    g_sMPU9150Inst.pui8Data[1] = MPU9150_GYRO_CONFIG_FS_SEL_250;
    g_sMPU9150Inst.pui8Data[2] = (MPU9150_ACCEL_CONFIG_ACCEL_HPF_5HZ | MPU9150_ACCEL_CONFIG_AFS_SEL_2G);

I tried to change MPU_CONFIG_DLPF_CFG_94_98 to MPU9150_CONFIG_DLPF_CFG_184_188, as defined at the hw_mpu9150.h file, but that did not had an effect at the sample rate measured by the scope.

Any ideas/recomendations/help greatly appreciated.

Best regards,

Can

  • In this example the sample rate is set to 50 Hz. See lines 248-271 of mpu9150.c.

            //
            // Change to power mode complete, device is ready for configuration.
            //
            case MPU9150_STATE_INIT_USER_CTRL:
            {
                //
                // Load index 0 with the sample rate register number.
                //
                psInst->uCommand.pui8Buffer[0] = MPU9150_O_SMPLRT_DIV;
    
                //
                // Set sample rate to 50 hertz.  1000 hz / (1 + 19)
                //
                psInst->uCommand.pui8Buffer[1] = 19;
    
                I2CMWrite(psInst->psI2CInst, psInst->ui8Addr,
                          psInst->uCommand.pui8Buffer, 2, MPU9150Callback, psInst);
    
                //
                // update state to show are in process of configuring sensors.
                //
                psInst->ui8State = MPU9150_STATE_INIT_SAMPLE_RATE_CFG;
                break;
            }