Tool/software: TI-RTOS
Hi,
Im a new using TI products and CCS. Im trying to adapt a arduino's code, which reads data from a IMU (MPU-6050), to a MSP432P401 but i have some problems. If i tried to use the exactly code to Energia or CCS when reading the data from the IMU, i just get wrong data. This is the code that i have use:
//Prueba de lectura de la IMU
//Librerias que incluímos:
#include <Wire.h> //Librería para la comunicacion con la IMU por I2C
//Declaración de variables para almacenar los datos de la IMU
int gyro_x, gyro_y, gyro_z;
long acc_x, acc_y, acc_z;
int temperatura;
#define LED RED_LED
void setup(){
Serial.begin(57600); //Inicilaización del monitor serie
Wire.begin(); //Inicializamos el I2C
setup_IMU();
Lee_IMU();
pinMode(LED,OUTPUT);
digitalWrite(LED,HIGH);
}
void loop(){
}
void setup_IMU() {
//Función que se encarga de inicializar la IMU
Wire.beginTransmission(0x68);
Wire.write(0x6B);
Wire.write(0x00);
Wire.endTransmission();
//Configuración de la IMU
Wire.beginTransmission(0x68);
Wire.write(0x1C);
Wire.write(0x10);
Wire.endTransmission();
//Configuración del giroscopio
Wire.beginTransmission(0x68);
Wire.write(0x1B);
Wire.write(0x08);
Wire.endTransmission();
}
void Lee_IMU(){
//Subrutina que se utiliza para leer los datos de la IMU
Wire.beginTransmission(0x68);
Wire.write(0x3B);
Wire.endTransmission();
Wire.requestFrom(0x68,14);
while(Wire.available() <14); //Esperamos a haber leido los 14 datos
acc_x = Wire.read()<<8 |Wire.read();
acc_y = Wire.read()<<8 |Wire.read();
acc_z = Wire.read()<<8 |Wire.read();
temperatura = Wire.read()<<8 |Wire.read();
gyro_x = Wire.read()<<8 |Wire.read();
gyro_y = Wire.read()<<8 |Wire.read();
gyro_z = Wire.read()<<8 |Wire.read();
}
This is the code from Energia, i have tried something similar with Code Composer Studio using TI RTOS but i get the same wrong data.
I'm using pins 6.5 and 6.4 to connect to SCL and SDA, respectively (using the convenient pull up resistors).
Can someone help me?
Thanks you,
Luis.