I2C communication with BMI088 IMU?


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    36

    Default I2C communication with BMI088 IMU?

    Has anyone played around with the BMI088 IMU? Or possibly a similar IMU from Bosch? I'm having trouble getting valid data using I2C from it. I've run some code to read the registers from both the accelerometer (address=$18) and the gyro (address=$68), but get back $20 (dec 32) for all registers.

    I have it configured for I2C with the following pins:

    Pin 5 (CSB2) - NC
    Pin 7 (PS) - VDD
    Pin 10 (SD02) - GND
    Pin 14 (CSB1) - VDD
    Pin 15 (SD01) - GND

    Section 6.2 of the datasheet (under the "I2C Read Access" heading at the bottom of page 50) along with figure 5 seems to indicate I need to perform an I2C write command to the relevant address to specify the starting register, then perform an I2C read command to the same address without specifying a register to get the data. Is my interpretation of this correct? I have posted Figure 5 for convenience below:
    Name:  i2c_figure5.jpg
Views: 520
Size:  83.5 KB

    I am using a 18F25k20 and the relevant parts of the code I have used to date is below:
    Code:
    #config  
    __CONFIG _CONFIG1H, _FOSC_HSPLL_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    __CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_OFF_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    #ENDCONFIG
    
    'serial comm pins
    PIN_OUT  var    PORTb.3
    PIN_IN   var    PORTb.2
    'BMI088 I2C pins
    MPUCLK   var    PORTa.4
    MPUSDA   var    PORTa.5
    
    'variables
    tmpbyte  var byte
    'MPU sensor variables
    mpu_aadr var byte
    mpu_gadr var byte
    mpu_areg var byte
    mpu_greg var byte
    
    ANSEL = %00000000     ' Configure unused analog inputs for digital I/O
    ANSELH = %00000000    ' Configure unused analog inputs for digital I/O
    
    TRISA = %00000011    ' set porta to digital output except push-button pins a.0 and a.1
    TRISB = %10000101    ' set portb to digital input or output (b.7=eeprom DQI=input; b.2=serin=input; b.0=ppm in=input)
    TRISC = %00000000    ' set portc to digital input or output
    
    'BMI088 constants
    GYROREAD	con	$68
    AXCELREAD	con	$18
    ACC_PWR_CNTL	con	$7D
    ACC_PWR_CNF	con	$7C
    STARTAX 	con	$12
    STARTGX 	con	$02
    
    'configure accel
    mpu_aadr=AXCELREAD
    mpu_gadr=GYROREAD
    mpu_areg=ACC_PWR_CNTL
    I2CWRITE MPUSDA,MPUCLK,mpu_aadr,mpu_areg,[4]
    pause 1
    mpu_areg=ACC_PWR_CNF
    I2CWRITE MPUSDA,MPUCLK,mpu_aadr,mpu_areg,[0]
    mpu_areg=STARTAX
    
    serout2 PIN_OUT,6,["MPU REGS",13,10]
    for mpu_areg=0 to 126
    I2CREAD MPUSDA,MPUCLK,mpu_aadr,mpu_areg,[tmpbyte]
    serout2 PIN_OUT,6,[dec mpu_aadr," ",dec mpu_areg," : ",DEC tmpbyte,13,10]
    pause 1
    next mpu_areg
    
    for mpu_greg=0 to 126
    I2CREAD MPUSDA,MPUCLK,mpu_gadr,mpu_greg,[tmpbyte]
    serout2 PIN_OUT,6,[dec mpu_gadr," ",dec mpu_greg," : ",DEC tmpbyte,13,10]
    pause 1
    next mpu_greg
    Any help is appreciated!

    Thanks!
    Dave

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,057


    Did you find this post helpful? Yes | No

    Default Re: I2C communication with BMI088 IMU?

    I think accelerometer is at address $30.

    Ioannis

  3. #3
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    36


    Did you find this post helpful? Yes | No

    Default Re: I2C communication with BMI088 IMU?

    Quote Originally Posted by Ioannis View Post
    I think accelerometer is at address $30.

    Ioannis
    I don't think that's correct. In the picture of figure 5 that I attached in my post, it shows the accelerometer address as "0x18". Also page 61 of the datasheet states:

    The default I2C addresses are:
    > Accelerometer:
    SD01 pin pulled to 'GND': 0011000b (0x018)
    SD01 pin pulled to 'VDDIO': 0011001b (0x019)
    > Gyroscope:
    SD02 pin pulled to 'GND': 1101000b (0x068)
    SD02 pin pulled to 'VDDIO': 1101001b (0x069)
    Is there a reason you think it is $30?

  4. #4
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    36


    Did you find this post helpful? Yes | No

    Default Re: I2C communication with BMI088 IMU?

    Quote Originally Posted by achilles03 View Post
    Is there a reason you think it is $30?
    Ah, yes, you think it should be $30 because I'm an idiot and it should be $30. :-) I always consolidate the R/W bit in the address and forget about it until the next new sensor I try to interface and have to remember it all over again. There's a small chance that one day I'll learn.

    Thanks!
    Dave

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,057


    Did you find this post helpful? Yes | No

    Default Re: I2C communication with BMI088 IMU?

    You are welcome!
    Ioannis

Similar Threads

  1. I2C Communication between PIC18F4550 and AS5600
    By soren7 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 5th August 2024, 11:00
  2. PIC18F I2C Communication with Arduino
    By picmilan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 14th July 2016, 22:38
  3. Replies: 11
    Last Post: - 5th March 2012, 21:40
  4. EEprom and MCP9801 I2C communication problems
    By aajgss in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 3rd September 2011, 22:45
  5. Replies: 2
    Last Post: - 10th June 2005, 03:34

Members who have read this thread : 6

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts