cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure I2C on STM32F0? How to get full StdPeriph lib for F0?

taraskorzh
Associate II
Posted on May 20, 2012 at 08:17

Hi, I'm trying to configure the I2C1 on STM32F0 Discovery board, and can't find any example. (The examples for other families like F1 and F4 are irrelevant because their I2C controllers are different) The StdPeriph library is included in the firmware package, but it seems to be stripped off any I2C examples. Also, the i2c header files mention some mysterious I2C_Timing_Config_Tool that should be used to configure the TIMING value, and this tool is nowhere to be found. It is also probably included in the full StdPeriph library package for F0, but I cannot find that full package for F0 anywhere on st.com.

Please help?...

#stm32f0-i2c
5 REPLIES 5
Mon2
Senior III
Posted on May 21, 2012 at 01:28

Hi. Looking for the same on this weekend to work with the STM32F0 Discovery board. Hope to get in the lab on Monday to test some ideas using our Beagle I2C logger. Ideally not wanting to move to bit-banging the I2C since this is present in h/w. If the tests are positive, will post the results. Also have you seen AN3078 and associated source code ? This is our starting base to conquer this complex beast. BTW - Which compiler are you using ? EWARM by IAR 32k version ? Thanks.

frankmeyer9
Associate II
Posted on May 21, 2012 at 15:55

If you watched closely, an updated version of the STM32F0x datasheet was released a few days ago. Lots of pages were added - all electrical data were missing before.

Obviously, the part is still in the process of being launched, so you might need some patience until a F0 implementation of the StdPeripheral Library is released.

Mon2
Senior III
Posted on May 21, 2012 at 23:03

Hi. Found some useful information (not tested yet but it should work). Spent better part of the afternoon stabilizing a new system to run the 32k version of the IAR EWARM compiler. This compiler is now running fine. Launch of the (IAR) compiler ->  select Example projects -> ST -> -> ->

I2C I2C examples using stm32f0xx_s  

Select Choose for the I2C examples -> the project will be imported and is the same as presented with the more advanced STM320518 toolkit (about $ 200 USD). The STM320518 is based on the STM32F0 core so it is applicable. We may consider moving to the above toolkit once we can get the basics operational. Please test and post your results. Will do the same, hopefully tomorrow or sooner using an external I2C eeprom & Beagle data logger. Thanks !

Mon2
Senior III
Posted on May 22, 2012 at 06:18

This posting is to confirm that we are able to read/write to an external 24C02 EEprom using the STM32F0 Discovery board.

I2C Bus I2C1 was used.

The above sample code maps the use PB7_I2C1_SDA and PB6_I2C1_SCL lines.

A few minor tweaks were required for our 24C02 testing:

1) To allow for use of the 24C02 EEprom, apply the #define for the 24C08 EEprom as follows:

/* Select which EEPROM will be used with this driver */

#define sEE_M24C08

inside the stm320518_eval_i2c_ee.h file.

2) The proper number of pages must be defined for the 24C02 density of EEprom as follows:

#if defined (sEE_M24C08)

    #define sEE_PAGESIZE           8

inside the same stm320518_eval_i2c_ee.h file.

3) Be sure the external EEprom is being powered 🙂 This issue killed some time due to some messy wiring.

4) Finally, the main.c code was changed to use the 2nd block of text which will fit inside the lower density 24C02 device = 0x80 bytes. The code upon boot will WRITE this 2nd block of text to the EEprom -> wait -> then READ back from the EEprom and perform a compare. If the compare matches, the code continues to repeat the same for another round. A total of 134 transactions = 132 written to the slave + 2 read from the slave (verified through the data logger) if the 2 code blocks are left to execute.

All is well other than the learning curve 🙂 Hope this helps.

frankmeyer9
Associate II
Posted on May 23, 2012 at 13:14

It's there now.

Check the Ressources tab of the STM32F0 page on www.st.com.

Obviously, it was added in the last days.