Hi,
I have a CC2650 with Debugger Devpack, and I use CCS Version 6.1.2.00015. I am trying to use the mpu9250 (built-in accelerometer), with some files from the SensorTag example source code, where the accelerometer is used. I already managed to initialize the accelerometer (calling sensorMpu9250Init()) and configure a callback for the interrupts, and also I am able to execute the code of the callback when I enable the Wake on Motion feature, using sensorMpu9250WomEnable(WOM_THR). However, when I read the data from the accelerometer I don't get coherent values.
I use the function sensorMpu9250AccRead((uint16_t*) &accData); defined in sensor_mpu9250.c, where accData is a uint8_t array of 6 length (this code has been extracted from the SensorTag example). Then, I set three int16_t variables (one for each axis) to convert the data of each axis, using sensorMpu9250AccConvert(accel_x); function. This is the portion of code I use to read the accelerometer data:
uint8_t accData[6];
int16_t accel_x, accel_y, accel_z;
uint8_t range;
float accelx, accely, accelz;
while(1){
sensorMpu9250AccRead((uint16_t*) &accData);
range = sensorMpu9250AccReadRange();
System_printf("Accelerometer Range: %u\n", range);
accel_x = (accData[0] << 8) + accData[1];
accel_y = (accData[2] << 8) + accData[3];
accel_z = (accData[4] << 8) + accData[5];
accelx = sensorMpu9250AccConvert(accel_x);
accely = sensorMpu9250AccConvert(accel_y);
accelz = sensorMpu9250AccConvert(accel_z);
System_printf("Accel data x: %1.2f\n", accelx);
System_printf("Accel data y: %1.2f\n", accely);
System_printf("Accel data z: %1.2f \n", accelz);
System_flush();
Task_sleep(5000 * (1000 / Clock_tickPeriod));
}
When I start the program, the SensorTag is static on my table, and the accelerometer is pointing upwards (with the TI logo pointing upwards), so I expect the output would be 0 for x and y axes, and 1 for z axis. However, the output of the console shows inaccurate and non-coherent data. This is the console output after some seconds of running the program:
Accelerometer Range: 2 Accel data x: -6.6894 Accel data y: 0.1237 Accel data z: -1.1220 Accelerometer Range: 2 Accel data x: -7.1894 Accel data y: 0.6237 Accel data z: -1.1220 Accelerometer Range: 2 Accel data x: -7.5019 Accel data y: 0.3737 Accel data z: -1.3720 Accelerometer Range: 2 Accel data x: -7.1269 Accel data y: 0.4362 Accel data z: -1.4345 Accelerometer Range: 2 Accel data x: -7.2519 Accel data y: 0.5612 Accel data z: -1.4970 Accelerometer Range: 2 Accel data x: -6.7519 Accel data y: 0.4362 Accel data z: -1.1220
I have tried changing the range of the accelerometer, and the same happens for all ranges, the results never exceed the range, but they are near to the maximum although the SensorTag remains static.
I may be missing something but I don't know what it is. ¿Anyone can help me on this?
Thank you in advance!
