Page 1 of 2

STM32F3DISCOVERY : using the I2C protocol

Posted: Mon Mar 31, 2014 1:04 pm
by giazax
Hi all,
i'm using the eval board STM32F3-DISCOVERY to interface a Humidity sensor (SI7020) with the i2c protocol (ICD1 BUS).
After many attempts...i see nothing, the status variable (after the i2cMasterTransmitTimeout command) is -2(?) and i'don't know why

..so my questions are :

The required PAL settings for the board (STM32F3-DISCOVERY) are : (i used the configuration in : http://www.chibios.org/dokuwiki/doku.php?id=chibios:community:guides:i2c_trouble_shooting....

Code: Select all

palSetPadMode(GPIOA, GPIOA_PIN9 , PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN) ;
  palSetPadMode(GPIOA, GPIOA_PIN10, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN) ;


where
PA9 is the SCL
PA10 is the SDA

2- the i2cconfig parameters are (i have no refereces about them...so i used the same configuration for the LSM303DLCH sensor) :

Code: Select all

static const I2CConfig i2cconfig = {
  STM32_TIMINGR_PRESC(8U)  | STM32_TIMINGR_SCLDEL(3U) | STM32_TIMINGR_SDADEL(3U) |
  STM32_TIMINGR_SCLH(3U)   | STM32_TIMINGR_SCLL(9U),
  0,
  0
};



i didn't find any referece about it....are these correct or not?

3 - my command sequence is :

Code: Select all

uint8_t rxbuf[6];
 uint8_t txbuf[6];
 SensorAddress = 0x40; //is correct

 txbuf[0] = myCommand; //is correct

  i2cAcquireBus(&I2CD1);
  i2cStart(&I2CD1, &i2cconfig);

  status = i2cMasterTransmitTimeout(&I2CD1, SensorAddress, txbuf, 1, rxbuf,0, TIME_INFINITE);
  chprintf(chp, "status =  %d \n" , status );
  i2cStop(&I2CD1);
  i2cReleaseBus (&I2CD1);



the status is always -1....and i have strange results with other commands.....

what's wrong with it?

any suggestions would be appreciated

thanks in advance

giancarlo

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Mon Mar 31, 2014 1:24 pm
by Giovanni
Hi,

That code does not tell me much. Do you have external pullup resistors? are wires short? are you looking at the bus with an analyser?
You may also try a lower speed, the settings are described in details in the Reference Manual.

Giovanni

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Mon Mar 31, 2014 2:39 pm
by giazax
Hi Giovanni,
i have not a logic analyser, the hardware is ok (...external pullup resistors and ... wires short)

i'lltry a lower speed

thanks

giancarlo

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Mon Mar 31, 2014 3:37 pm
by Giovanni
You may consider something cheap like this one: http://www.robot-italy.com/it/zeroplus- ... lyzer.html

It is what I use at home.

Giovanni

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Thu Apr 03, 2014 11:51 am
by giazax
hi,
in attachment the display from the logic analyser....i see nothing.
(the settings are correct, I tested the analyser with the lsm303dlhc sensor on board)


giancarlo


p.s
my configuration for the I2C2 I/O setup is :
palSetPadMode(GPIOA, GPIOA_PIN9 , PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN) ; //SCL
palSetPadMode(GPIOA, GPIOA_PIN10, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN) ; //SDA

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Thu Apr 03, 2014 12:40 pm
by Giovanni
Do you get a trigger? start the sampling just before the transmit operation (put a breakpoint there).
Also, try enlarging the samples buffer, it is set to 2k now, put it at 64k, may be we are not seeing anything because this.

Giovanni

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Thu Apr 03, 2014 1:34 pm
by giazax
hi giovanni,
the trigger is in default...i tried with 64 k...but nothing again....


thanks
giancarlo

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Thu Apr 03, 2014 2:12 pm
by giazax
hi giovanni,
in attach the display for the lsm sensor on board....it seems ok

is there any pins setup and/or other parameters i missed?

thanks for any suggestion

giancarlo

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Thu Apr 03, 2014 2:18 pm
by Giovanni
Put the buffer at 64K an try to read the whole sequence, then verify if all bytes are ACKed.

Giovanni

Re: STM32F3DISCOVERY : using the I2C protocol

Posted: Thu Apr 03, 2014 2:33 pm
by giazax
ok,
i'll try.....the max buffer is 32k

giancarlo