cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F100 I2C problem

michaelrst
Associate II
Posted on December 02, 2013 at 10:43

Hi

I have a board with an STM32F100 microcontroller communicating with an LSM303DLM accelerometer/magnetometer and an L3G4200D gyroscope. I have managed to get the communications working but in order to do this I have had to put a delay after each I2C command, and it only works if the microcontroller runs with the default 8MHz internal RC clock, regardless of the value of the APB1 peripheral clock feeding the I2C unit, and also independent of the I2C bus frequency.

Without these delays, or at other clock frequencies, the uC is unable to even send a START condition correctly.

The uC runs off 3.1V, the I2C lines are pulled up to the 2.7V of the sensors I/O supply with 10k resistors.

Does anybody have any idea why this is happening, and/or what I can do to enable the uC to run at full speed.

Regards

Michael Taylor

#stm32f1-i2c
4 REPLIES 4
suhas_sajjan
Associate II
Posted on December 02, 2013 at 11:30

Can you post the entire code which you have done for interfacing between microcontroller and other sensors....i want to have a look,den may be i can help you

michaelrst
Associate II
Posted on December 02, 2013 at 17:19

For 24 MHz operation you'd want to look carefully at the system_stm32f1xx.c code and how the PLL is being set up. That the project has the correct defines for HSE_VALUE and STM32F10X_MD_VL, USE_STDPERIPH_DRIVER

The VL parts don't need code to reconfigure the flash controller, or wait states.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
michaelrst
Associate II
Posted on December 03, 2013 at 09:45

I don't have any problems in getting the system to run at 24MHz, the problem is that the I2C bus stops working, everything else is fine. Even if I set the APB1 clock to 6MHz. Also running the system clock at 16MHz and the APB1 clock at 8MHz doesn't work, only running the system clock directly from the HSI oscillator allows the I2C bus to work.

Michael