2017-12-22 06:07 PM
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.2017-12-22 06:22 PM
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
2017-12-22 10:58 PM
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....
2017-12-23 08:40 AM
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
2017-12-23 09:13 AM
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?
2017-12-23 09:43 AM
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.
2017-12-23 04:01 PM
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
2017-12-23 07:54 PM
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
2017-12-23 08:52 PM
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
2017-12-23 10:08 PM
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.