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/EK-TM4C123GXL: Frequency Read of the SensHub with the TM4C123G

Part Number: EK-TM4C123GXL

Tool/software: Code Composer Studio

Hey,

So quick question in regards to the compdcm_mpu9150 example found in TivaWare_C_Series-2.1.4.178  Sensor Examples. In the initialization there is a line that is 

    //
    // Initialize the DCM system. 50 hz sample rate.
    // accel weight = .2, gyro weight = .8, mag weight = .2
    //
    CompDCMInit(&g_sCompDCMInst, 1.0f/50.0f, 0.2f, 0.8f, 0.2f);

Which indicates in the data sheet for the MPU-9150 it shows that the sample rate could be increased to 1kHz and still capture both accelerometer and gyroscope data. 

I've tried to change the sample rate with the second called value but when I scope PB2, the interrupt pin on the TM4C123G, I still can only seem to get 50 Hz and I can't find information on this function. What I've tried is:

CompDCMInit(&g_sCompDCMInst, 1.0f/900.0f, 0.2f, 0.8f, 0.2f);


CompDCMInit(&g_sCompDCMInst, 900.0f, 0.2f, 0.8f, 0.2f);


CompDCMInit(&g_sCompDCMInst, 1.0f, 0.2f, 0.8f, 0.2f);

etc. 

Has anyone played around with this example or could give a hint in regards to what I'm doing wrong? Or where I can read more about it.

Thank  you in advance for any help,

Kala

  • Kala Mccomb said:
    I've tried to change the sample rate with the second called value but when I scope PB2, the interrupt pin on the TM4C123G, I still can only seem to get 50 Hz and I can't find information on this function.

    The source code for CompDCMInit() is inside the TivaWare sensorlib/comp_dcm.c TivaWare file. CompDCMInit() sets the *expected* output data rate used to filter the sensor outputs, and doesn't configure the *actual* output data rate from the MPU9150.

    It is the following code in the MPU9150Callback() function in the TivaWare sensorlib/mpu9150.c file which sets the actual output data rate from the MPU9150:

            //
            // 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;
            }

    Looking at the TivaWare sensorlib source code I can't see any existing API to allow the output sample rate to be changed, but you could maybe add a modified version of sensorlib to your project.

  • Awesome, I couldn't find this for the life of me. Probably the not sleeping.
    I've uped it to 500 Hz and it works so much better.

    Thank you so much,
    Kala