Page 18 of 35
Re: I2C implementation for STM32
Posted: Thu Oct 06, 2011 12:29 pm
by barthess
Can you provide additional info? Are you correctly setup pins and select appropriate I2C bus?
Re: I2C implementation for STM32
Posted: Sun Oct 09, 2011 10:35 pm
by Cyrille
barthess wrote:Hi Cyrille,
Driver works fine with my BMP085 sensor. Also, I can submit my code communicates with it. The sensor is a bit tricky.
Hi Barthess,
I don't see in your code where you initialize the i2c port with i2CConfig, i2Cinit, i2cstart ?
So how do you initialize it ?
thanks
Cyrille
Re: I2C implementation for STM32
Posted: Sun Oct 09, 2011 11:20 pm
by barthess
It is pretty ease
Code: Select all
#include "ch.h"
#include "hal.h"
#include "i2c_pns.h"
#include "main.h"
#include "lis3.h"
#include "tmp75.h"
#include "eeprom.h"
#include "max1236.h"
#include "bmp085.h"
/* interface #1 */
static const I2CConfig i2cfg1 = {
OPMODE_I2C,
200000, //100000, //
FAST_DUTY_CYCLE_16_9, //STD_DUTY_CYCLE, //
0,
0,
0,
0,
};
/* interface #2 */
static const I2CConfig i2cfg2 = {
OPMODE_I2C,
200000, //100000, //
FAST_DUTY_CYCLE_16_9, //STD_DUTY_CYCLE, //
0,
0,
0,
0,
};
inline void I2CInit_pns(void){
i2cInit();
i2cStart(&I2CD1, &i2cfg1);
i2cStart(&I2CD2, &i2cfg2);
/* tune ports for I2C1*/
palSetPadMode(IOPORT2, 6, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
palSetPadMode(IOPORT2, 7, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
/* tune ports for I2C2*/
palSetPadMode(IOPORT2, 10, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
palSetPadMode(IOPORT2, 11, PAL_MODE_STM32_ALTERNATE_OPENDRAIN);
/* startups */
init_eeprom();
init_bmp085();
init_tmp75();
init_max1236();
init_lis3();
}
Re: I2C implementation for STM32
Posted: Sun Oct 16, 2011 11:31 pm
by Cyrille
Hi Barthess,
I have tried your code to communicate with BMP085 via the i2c driver, and I think that my calibration coeff are wrong : the first coeff is equal to 0 and the other are very similar (0; -1055; -1055; 33570; 33570; 22539; 22539; 54; 54; -11075; -11075) . As you have a good experience with the BMP085, do you think that is a i2c driver problem (speed, thread priority, delay between reads, offset...) ?
Thanks
Re: I2C implementation for STM32
Posted: Mon Oct 17, 2011 7:23 am
by barthess
Strange. I had no such problem with my bmp085. Try to slow down bus speed. Also, coefficients in sensor are not write protected. Are you sure they are not overwritten?
Re: I2C implementation for STM32
Posted: Tue Oct 25, 2011 5:41 pm
by DrunkenDonkey
Too few people bug barthess/Giovanni these days, that must be corrected

It turned out I won't be using STM32F103, but the STM32L1. Deleting some big flash-related parts of my code and switching over I saw that I2C is not supported on it. According to some "Migrating from STM32F1" document, the I2C is pinout and software identical on both devices, so I just added:
${CHIBIOS}/os/hal/platforms/STM32/i2c_lld.c \
to the platform.mk file, but wondering about the reason it is not there (don't have the cpu/kit yet, can't test)
Re: I2C implementation for STM32
Posted: Tue Oct 25, 2011 6:02 pm
by Giovanni
Hi,
It is not there because it hasn't been tested on STM32L yet, there is no reason it shouldn't work. Please let me know your results

Giovanni
Re: I2C implementation for STM32
Posted: Tue Oct 25, 2011 8:01 pm
by barthess
Hi there.
If anybody wants I2C support in STM32F2xx but do not want to develop it by himself, than he (or she) cant present me MCU (not a board) from F2 series in LQFP-100 package. I will replace STM32F103 in my almost done board with that one and will port software to it.
P.S. I know they are not too expensive, but economical fuckup happens in my country.
Re: I2C implementation for STM32
Posted: Tue Oct 25, 2011 8:31 pm
by Giovanni
Hi Barthess,
These days economical fuckup is everywhere apparently.
The open source project received some donations and there is also some income because advertising (3 clicks per week on average

), it will pay for the web hosting and there is still enough for the F2s (or even the F4s if already available), if you have a paypal account I could route you some of the donations in order to purchase those chips and do the testing.
Giovanni
Re: I2C implementation for STM32
Posted: Tue Oct 25, 2011 8:52 pm
by barthess
PayPal does not work with my insane country at all (not for the sending nor for receiving of payments). Also, for example, Digikey wants 100USD for shipping to my country. Also, I embarrassed to take money, real hardware is better.