AnsweredAssumed Answered

CHIBIOS :STM32f3discovery - I2c interface with the MPL3115a2 sensor

Question asked by zaccone.giancarlo on Mar 28, 2014
Latest reply on Apr 2, 2014 by sung.chen_chung
Hi everybody,
for my first project i want to use the MPL3115a2 sensor with the stm32f3discovery with the i2c protocol After many attempts i see nothing..(the value of the pressure is always zero)...what's wrong with it?
the pin connections for the MPL21115a2 are :
PA10 for SDA i2c data
PA9  for SCL i2c clock
other pin to manage? (from the datasheet ...i think no)
for the i2c configuration i'm using the example of the lsm303dlhc sensor...
a code snippet is here :
//I2C Configuration Parameter.....from the lsm303dlhc example
static const I2CConfig i2cconfig = {
void padInit(void){
//PA10 is SDA
//PA9 is SCL
//miss something?
  palSetPadMode(GPIOA, GPIOA_PIN9 ,       /*  pad settings for I2CD1 SCL  */
  palSetPadMode(GPIOA, GPIOA_PIN10,       /*  pad settings for I2CD1 SDA  */
int main(void) {
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   * - Setting pin for gyroscope and accelerometer\magnetometer
   * Initializes a serial-over-USB CDC driver.
  sduStart(&SDU1, &serusbcfg);
   * Activates the USB driver and then the USB bus pull-up on D+.
   * Note, a delay is inserted in order to not have to disconnect the cable
   * after a reset.
  usbStart(serusbcfg.usbp, &usbcfg);
  int status;
  float pressure;
  while (TRUE) {
       palSetPad(GPIOE, GPIOE_LED3_RED);
       palClearPad(GPIOE, GPIOE_LED3_RED);
      //set active the power mode of the sensor...all the address are correct...
      status = SetPowerMode(&I2CD2, MPL3115A2_DEFAULT_ADDR, ACTIVE);
       i2cReleaseBus (&I2CD2);
      //read the pressure
       i2cStart(&I2CD2, &i2cconfig);
       ReadPressure(&I2CD2, MPL3115A2_DEFAULT_ADDR,&pressure);
       i2cReleaseBus (&I2CD2);
      chprintf(chp, "MPL3115A2 pressure = %d \n" , pressure);      
      //set in stanby the sensor
      SetPowerMode(&I2CD2, MPL3115A2_DEFAULT_ADDR, STANDBY);
      i2cReleaseBus (&I2CD2);

thanks for any suggestion