Jump to content

ryseek

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. ryseek

    Msp430g2231 i2c mpu6050 issue

    Hi everyone! I need to connect mpu6050 to msp430g2231 and i've read article http://www.kerrywong...aster-examples/ My code : #include <msp430.h> #include <msp430g2231.h> #include "i2c.h" int AcX,AcY,AcZ; unsigned char i2cAddress = 0x68; int accel; int count; unsigned char high; unsigned char low; void initMPU() { i2c_start();// i2c_write8(i2cAddress << 1);/// begin tarmition i2c_write8(0x68); i2c_write8(0); i2c_stop(); } void main(void) { WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; i2c_init(); initMPU(); while(1){ i2c_start();// i2c_write8(i2cAddress << 1);/// begin tarmiti i2c_write8(0x3B); i2c_stop(); i2c_start(); i2c_write8(i2cAddress<< 1 | 1); AcX=i2c_read8(0x0)<<8|i2c_read8(0x0); i2c_stop(); } } The debugger show the value of AcX=-1, sometimes=-4,but very rare real values of axis. Need help!
×