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:
I am using a 18F25k20 and the relevant parts of the code I have used to date is below:
Any help is appreciated!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
Thanks!
Dave




Bookmarks