cancel
Showing results for 
Search instead for 
Did you mean: 

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

bluenow1896
Associate III
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.
10 REPLIES 10
Pavel A.
Evangelist III
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

S.Ma
Principal
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....

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

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?

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.

Posted on December 24, 2017 at 00:01

It seems off the focus from the original question.

I had successfully configured and run I2C module at Fast Plus mode (aka 1M Hz clock) on STM32L476 board.

I do understand that when pushing the clock higher, it needs to pay more attention on the wire capacity, pull up resistor selection, driving current etc.  But these really not seems to be the reason causes can't support 400kHz I2C on STM32F4Discovery board.

I guess that the representative from ST could be better source for my original question.

-Andy

Posted on December 24, 2017 at 03:54

Yep. The data sheet for STM32F401xB/C says: (p. 3.20)

'I

2

C bus interfaces .....  support the standard (up to 100 kHz) and fast (up to 400 kHz) modes.

The I2C bus frequency can be increased up to 1 MHz. For more details about the complete solution,

please contact your local ST sales representative.

 '

-- pa

Posted on December 24, 2017 at 04:52

Oh boy. Thanks for checking datasheet, but I really was asked for STM32F4DISCOVERY board, which uses STM32F407VG.  I did checked the datasheet for STM32F407VG and it says support fast speed up 400kHz.

So my real question is what prevent me to configure I2C1 to be in fast mode on CubeMX? Something on the board causes the restriction or just a bug in CubeMX?

-Andy

Posted on December 24, 2017 at 06:08

My guess is cubemx visually show graphically the datashhet. It doesn t know the board other components limits, especially for end product customised boards. So if for example one of the slave specs says 400khz, going higher will be out of spec, at your own liability risk. Over 400khz, physical scheme should change. Some mems needs special command to switch to faster mode, it is not just slam the clock speed pedal.