Jump to content

_Murphy_

Members
  • Content Count

    9
  • Joined

  • Last visited

About _Murphy_

  • Rank
    Noob Class

Profile Information

  • Gender
    Not Telling
  1. _Murphy_

    Need help with I2C using MSP430g2553

    Since you asked for more code via a Private message. I will share the project I used to test that the I2C was working using the MPU-6050. It has a printf script in it that someone on this forum created. MSP430_MPU6050.rar Just import this code and connect an MPU-6050 and you should be able to verify that your I2C lines are working through the printf.
  2. _Murphy_

    Need help with I2C using MSP430g2553

    I was able to get my code to work once I added some printf code to debug it. Thank you for posting that code though.
  3. _Murphy_

    Tiny printf() - C version

    Thank you. This makes debugging programs so much easier.
  4. _Murphy_

    Tiny printf() - C version

    Where exactly in CCS do you see the Printf text? I have the sample program running.
  5. _Murphy_

    Need help with I2C using MSP430g2553

    What I currently am using I have based it off of another persons code. It is able to compile but after stepping through the debugger I am not 100% certain that the IMU code is working properly. If anyone who may be in the process of doing something similar to this is able to improve upon this code or has another approach please post it. Attached Files: main.c I2C_MSP430.c I2C_MSP430.h MPU6050.h MSP430_MPU6050.c MSP430_MPU6050.h
  6. _Murphy_

    Need help with I2C using MSP430g2553

    I haven't been able to verify if the code I have works since It isn't displaying values correctly in the debugger.
  7. _Murphy_

    Need help with I2C using MSP430g2553

    The I2C code I have has been re-written and it may function correctly now. Once I complete testing on it I will know for sure. If I can verify my code to be working I will post it on this topic.
  8. _Murphy_

    Need help with I2C using MSP430g2553

    Ok. This is the code I have so far. I currently can verify that it is working up to the if statement that checks if the slave is present. I also have included an attachment of the Read sequence that is in the data sheet. All comments are welcome. #include "msp430g2553.h" #include "TI_USCI_I2C_master.h" #define MPU6050_I2C_ADDRESS 0x68 // Confirmed correct address + communication #define prescale 0x14 // 400kHz #define MPU6050_PWR_MGMT_1 0x6B // Power management register: write 0x00 to wake the device #define MPU6050_ACCEL_XOUT_H 0x3B // Read #define MPU6050_ACCEL_YOUT_H 0x3D // Read #define MPU6050_ACCEL_YOUT_L 0x3E // Read #define MPU6050_ACCEL_ZOUT_H 0x3F // Read #define MPU6050_ACCEL_ZOUT_L 0x40 // Read #define MPU6050_TEMP_OUT_H 0x41 // Read #define MPU6050_TEMP_OUT_L 0x42 // Read #define MPU6050_GYRO_XOUT_H 0x43 // Read #define MPU6050_GYRO_XOUT_L 0x44 // Read #define MPU6050_GYRO_YOUT_H 0x45 // Read #define MPU6050_GYRO_YOUT_L 0x46 // Read #define MPU6050_GYRO_ZOUT_H 0x47 // Read #define MPU6050_GYRO_ZOUT_L 0x48 // Read #define MPU6050_AD_R 0xD1 #define MPU6050_AD_W 0xD0 unsigned char timercounter; unsigned char array[20] = { MPU6050_PWR_MGMT_1, 0x0}; unsigned char array2[20] = { MPU6050_AD_W, MPU6050_GYRO_XOUT_L}; unsigned char store[40] = { 0}; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer. This line of code is needed at the beginning of most MSP430 projects. // This line of code turns off the watchdog timer, which can reset the device after a certain period of time. BCSCTL1 = CALBC1_8MHZ; // Set clock calibration to 8 MHz DCOCTL = CALDCO_8MHZ; // Internal oscillator to 8 MHz _EINT(); /* initialization of the I2C with the slave */ TI_USCI_I2C_transmitinit(MPU6050_I2C_ADDRESS,prescale); // init transmitting with USCI while ( TI_USCI_I2C_notready() ); // wait for bus to be free if ( TI_USCI_I2C_slave_present(MPU6050_I2C_ADDRESS) ) // Allow communication if slave was present at address { TI_USCI_I2C_transmitinit(MPU6050_I2C_ADDRESS,prescale); // Start initialization of the transmission using slave address and frequency using USCI while ( TI_USCI_I2C_notready() ); // wait for bus to be free TI_USCI_I2C_transmit(4,array); // start transmitting while ( TI_USCI_I2C_notready() ); // wait for bus to be free between each different connection TI_USCI_I2C_transmitinit(MPU6050_I2C_ADDRESS,prescale); // Start initialization of the transmission using slave address and frequency using USCI while ( TI_USCI_I2C_notready() ); // wait for bus to be free TI_USCI_I2C_transmit(4,array2); // start transmitting while ( TI_USCI_I2C_notready() ); // wait for bus to be free between each different connection TI_USCI_I2C_receiveinit(MPU6050_I2C_ADDRESS,prescale); // Start initialization of the receiving using slave address and frequency using USCI while ( TI_USCI_I2C_notready() ); // wait for bus to be free TI_USCI_I2C_receive(2,store); } LPM3; }
  9. Over the past week I have been attempting to get my MSP430g2553 to act as the master and talk to an MPU-6050 which is the slave. I have so far only been able to get it to receive an ACK to the slave, and the code indicates that it is present and listening. My attempts at writing and reading from the slave have produced no results. Does anyone have any advice or recommendations on how to proceed with this?
×