Page 1 of 1

Reading from BMI055 on STM32F4 I2C2

Posted: Fri Aug 01, 2014 3:44 am
by hkerner
Hi there,

I am trying to read from gyro data on a bmi055 using an STM32F4. The gyro is on I2C2 and I have followed the example in testhal and pored over the troubleshooting guide but when I call i2cMasterTransmitTimeout() it always times out, and if I do just i2cMasterTransmit() it never returns.

Here is my setup:

Code: Select all

  palSetPadMode(GPIOF, 1, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN);   /* SCL */
  palSetPadMode(GPIOF, 0, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN);   /* SDA */
  i2cStart(&I2CD2, &i2cfg2);


with the config:

Code: Select all

/* I2C interface #2 */
static const I2CConfig i2cfg2 = {
    OPMODE_I2C,
    400000,
    FAST_DUTY_CYCLE_2,
};


I was previously implementing this with libopencm3 and I used 100KHz as the speed but when I use that here it just breaks.
Here is where I am doing the read:

Code: Select all

static uint8_t data_out[8];  // tx_buf
static uint8_t rx_buf[8];
static i2cflags_t errors = 0;
static const uint8_t id_register = 0x00;
#define bmi055_addr 0b1101001

  systime_t tmo = MS2ST(500);
  msg_t status;
  // Query GYRO "CHIP_ID" register
  data_out[0] = id_register;
  i2cAcquireBus(&I2CD2);
  status = i2cMasterTransmitTimeout(&I2CD2, bmi055_addr, data_out, 1, rx_buf, 1, tmo);
  i2cReleaseBus(&I2CD2);
  if (status != RDY_OK) {
    if (status == RDY_RESET) {
      errors = i2cGetErrors(&I2CD2);
    }
    if (status == RDY_TIMEOUT) {
      _printf("Timeout occurred");
      palTogglePad(GPIOA, 1);
    }
  }


Do you see anything I'm doing inherently wrong here? Thank you in advance.

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Fri Aug 01, 2014 7:11 am
by Giovanni
Hi,

The code looks OK.

Please follow this guide: http://www.chibios.org/dokuwiki/doku.ph ... e_shooting

Most common problems are explained there.

Giovanni

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Fri Aug 01, 2014 10:36 pm
by hkerner
Thanks, I have pored over that page actually and have made sure I'm doing all of those things correctly. I have things working fine with the Serial Driver. However I think the problem lies in the fact that I'm using the STM32F407-DISCOVERY board files for the STM32F417IG.

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Sat Aug 02, 2014 7:15 am
by Giovanni
hi,

Board files are highly specific, you need to create new ones.

ChibiStudio includes a board files generator that takes in input an XML description, see those .chcfg files in many board directories.

Giovanni

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Mon Aug 04, 2014 7:49 pm
by hkerner
Thank you! I will look at that. In the troubleshooting page it says "Ensure SDA/SCL lines not swapped." but I have not specified anywhere exactly what the SDA/SCL lines are, other than configuring the pins for them appropriately in the board.h file. Is there a particular place where I specify what those lines are?

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Mon Aug 04, 2014 8:15 pm
by Giovanni
It just means that you have to make sure that your device is connected properly.

Giovanni

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Tue Aug 05, 2014 12:39 am
by hkerner
Ok thanks. I am creating the board.h file using the .chcfg file, but I don't have ChibiStudio. Is there a way to generate the .h file without using ChibiStudio?

Re: Reading from BMI055 on STM32F4 I2C2

Posted: Tue Aug 05, 2014 8:18 am
by Giovanni
Currently not.

Giovanni