STM32F3DISCOVERY : using the I2C protocol
Posted: Mon Mar 31, 2014 1:04 pm
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....
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) :
i didn't find any referece about it....are these correct or not?
3 - my command sequence is :
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
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