Skip to main content
bluenow1896
Associate III
December 23, 2017
Question

Can I configure I2C1 work in full speed mode (400kHz) on STM32F4Discovery board?

Posted on December 23, 2017 at 03:07

I have a STM32F4 Discovery board and I try to using STM32CubeMX to start a initial project.

One issue I have is that I can't select the I2C1 to work on full speed mode, the mode other than standard was grayed out.

As I know the standard mode is quite slow as 100kHz, and even the full speed mode is at 400kHz, not really fast.

The I2C specification defined fast mode with the clock to 1MHz and even high speed on 3.4M. I can't believe that it can't support full speed mode (400kHz) on I2C module on STM32F4Discovery board. What's wrong?

Note: this post was migrated and contained many threaded conversations, some content may be missing.
    This topic has been closed for replies.

    10 replies

    Pavel A.
    December 23, 2017
    Posted on December 23, 2017 at 03:22

    Have you tweaked other settings before the I2C1?

    I cannot reproduce this. Opened Cube, created new project based on (randomly picked) STM32F401C-DISCO.

    The I2C1 can be changed to fast 400KHz mode.

    -- pa

    bluenow1896
    Associate III
    December 23, 2017
    Posted on December 23, 2017 at 16:40

    Hi,

      Please select the board of STM32F4DISCOVERY to reproduce.  

      I tried STM32F401C-DISCO and it can do the I2C clock on 400kHz. (aka. full speed mode, but in the CubeMX it called Fast mode, which is confused as the I2C specification name the Fast mode to be 1M Hz clock.)

      I started the configuration from scratch by new the board of STM32F4DISCOVERY; I noticed there are 2 of STM32F4DISCOVERY in the list, I heard that MB997 comes to revisions to have little difference on hardware, but that part should not impact my application.

      The CubeMX version is 4.23.0, and STM32CubeF4 Firmware Package V1.18.0 is selected.

      Any other information do you need? let me know, thanks.

    -Andy

    S.Ma
    Principal
    December 23, 2017
    Posted on December 23, 2017 at 07:58

    You still can hack the I2C HW control registers and clock prescalers if needed.

    On the physical side, I guess the I2C bus can do it, provided:

    1. All the slave devices can run 400kHz (the highest clock speed is driven by the slowest slave on the bus)

    2. The pull-up resistors are low enough to have a rise edge on the signals that are fast enough. Otherwise, you get a sawtooth on the oscilloscope....

    bluenow1896
    Associate III
    December 23, 2017
    Posted on December 23, 2017 at 17:13

    Hi,

      I'm not sure what resolution you suggest.

      As I mentioned, 400kHz is not a speed looks extreme, the I2C specification defined 1M, 3.4M Hz etc.

      The problem is that I can't choose 400kHz for I2C1 from CubeMx for board of STM32F4DISCOVERY. If I'm going  tweak the generated code directly, should it changing 'hi2c1.Init.ClockSpeed = 100000;' to 'hi2c1.Init.ClockSpeed = 400000;' to be all set?  I'm wondering anything else needed?

    S.Ma
    Principal
    December 23, 2017
    Posted on December 23, 2017 at 17:43

    400 kHz is fast for open drain signals. Check the reference manual.

    When going beyond 400kHz, many slave devices won't work. Be careful.

    Want faster speed? Use SPI as push pull 4 wire interface...

    Faster? Have a look at signal integrity and EMI.