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.

I2C on AFE4400SPO2EVM

Other Parts Discussed in Thread: AFE4400SPO2EVM

Thanx for the source code for firmware 1.3 of AFE4400SPO2EVM.

As mentioned from my previous posts, I have managed to solder MPU9150 on EVM and somehow got it perfectly working with my I2C code.
But however whenever I flash the Firmware 1.3 through CCS everything works fine, But when I try to Integrate the I2C code with the firmware I face some difficulties.

When I flash the new code the COM port of AFE4400SPO2EVM (COM95 in my case) dissapears, also there are no unknown devices in that list. Thus I cant have access to the EVM.

Do I have to make changes in the driver or anything else to get I2C working with EVM.

  • Hello Atul,

    You do not see the COM port description when the USB stack is not properly initialized.

    It looks like the code is getting stuck in a loop.

    Did you try debugging your code stepping through functions using JTAG?

    If you move the I2C init function after USB_handleVbusOnEvent() function is called, then you might see the COM port getting initialized.

    Does it go all the way through your code until it reaches a state where it is waiting for any USB event?

    Can you provide your project to check for any issues?

  • Hello Praveen,

    You were right if I move the I2C init after the USB function then it shows the COM port.
    However when I try to access the EVM from MATLAB using serial interface then the I am not able to receive any data.

    However the same I2C code works fine if i use it alone.

    I am attaching the project, plz go though it.

    1157.HRM_EVM.rar

  • A kindly reminder for reply.

    I have checked for debugging from my side, and came to an understanding that I2C init function  function is working, however the I2c read function is not working.

    The same code works fine when used without the firmware code.

    Maybe there is some clash with the firmware code. Plz look into the function and suggest some changes.

    Thanx.

  • Atul,

    I noticed two issues which may be potential cause of failure.

    1. I2C clock was set to 8MHz instead of 400KHz.

    2. CLKSEL bits are set to external clock source.

    Replace the initMPU function in your project with the one below and let me know if it works.

    void initMPU(void)

    {
    P3SEL |=0x03; //set port 3.0 and 3.1
    unsigned char configData=0x00;
    P3SEL |=0x03;
    UCB0_MasterI2C_init (I2C_7bit_addr, I2C_CLK_SMCLK, 40);

    UCB0_I2C_read (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_WHO_AM_I, &configData, 1);
    // wake up sensor
    configData = 0x01; //0x04;
    UCB0_I2C_write (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_PWR_MGMT_1, &configData, 1);
    //set acc sensitivity to 2G
    configData = 0x00;
    UCB0_I2C_write (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_ACCEL_CONFIG, &configData, 1);
    //set DLPF to 21 Hz
    configData = 0x04; //0x01;
    UCB0_I2C_write (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_CONFIG, &configData, 1);
    //set sampling to 1KHz // 62.5 Hz
    configData = 0x00; //0x0F;
    UCB0_I2C_write (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_SMPLRT_DIV, &configData, 1);
    //Configure int
    configData = 0x30;
    UCB0_I2C_write (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_PIN_CFG, &configData, 1);
    //Enable data ready int
    //configData = 0x01;
    //UCB0_I2C_write (MPU6050_DEFAULT_ADDRESS, MPU6050_RA_INT_ENABLE, &configData, 1);

    }

    Regards

    Praveen.

  • Thanx for your reply,

    The code is out of the loop but the data is coming 0. Here is a sample of data we recieved byte by byte in matlab.

    01
    02
    78
    42
    01
    BC
    D6
    FF
    35
    DB
    02
    DD
    D5
    FF
    BC
    6B
    01
    58
    05
    03
    00
    00
    00
    00
    00
    00
    00
    00
    00
    03
    0D

    The last 9 bytes contain the acceleration data of 3 axis each containing 3 bytes. however making those same changes in mpu standalone code didnt affect any data...

  • Atul,

    You may have to revisit the MPU9150 Init function to check for the accelerometer register settings.

    I may not be able to help with the MPU9150 register settings.

     

    Regards

    Praveen.

  • Hello,

    Thank you for your valuable reply. I was finally able to get the mpu data from standalone + firmware code.
    I debugged using breakpoints and found some problems in the variables. Now we have both the AFE and MPU data simultaneously, so now we can move forward with motion cancellation.

    Thanks for all you help.

    Regards
    Atul