Skip to main content
anonymous.8
Senior II
Sep 4, 2019 11:21 AM UTC
Solved

Unable to setup I2C2 master clock to 1MHz on STM32F7xx?

Hello,

I'd like to connect EEPROM slave to I2C2 of STM32F767 MCU. EEPROM's supported clock is 1MHz. With 25 MHz HSE, I only managed to setup PCLK to 1.5625 MHz. Am I correct that it is imposible to setup I2C2 to 1 MHz with this setup?

Thanks!

This topic has been closed for replies.
Piranha
PiranhaBest answer
Principal III
Sep 4, 2019 7:35 PM UTC

You have to understand that peripheral bus clock is not I2C line clock. I2C has it's own prescaler and counters configurable in I2C_TIMINGR register. You can run PCLK1 at 54 MHz and I2C at 100 kHz, 400 kHz, 1 MHz or plenty of other frequencies and combinations in a wide range.

6 replies

waclawek.jan
Super User
Sep 4, 2019 6:13 PM UTC

> With 25 MHz HSE, I only managed to setup PCLK to 1.5625 MHz.

So, the 25MHz HSE is your AHB clock?

And you can't set the APB divider to less than 16? Is there any problem with writing 0 into the respective RCC_CFGR.PPREx?

JW

anonymous.8
Senior II
Sep 5, 2019 5:33 AM UTC

Setting PPREx to 0 makes "0xx: HCLK not divided", thus, making PCLK equal to HCLK. Not the 1MHz that my EEPROM requires.

waclawek.jan
Super User
Sep 5, 2019 8:22 AM UTC

Ah... I thought you are complaining that you can't set PCLK *fast* enough to achieve 1MHz on I2C (after using its prescalers)...

@Piranha​  has a much clearer crystal cube than me.

Glad you got it going.

JW

Piranha
PiranhaBest answer
Principal III
Sep 4, 2019 7:35 PM UTC

You have to understand that peripheral bus clock is not I2C line clock. I2C has it's own prescaler and counters configurable in I2C_TIMINGR register. You can run PCLK1 at 54 MHz and I2C at 100 kHz, 400 kHz, 1 MHz or plenty of other frequencies and combinations in a wide range.

anonymous.8
Senior II
Sep 5, 2019 6:07 AM UTC

I saw that tSCL = tSYNC1 + tSYNC2 + {[(SCLH+1) + (SCLL+1)] x (PRESC+1) x tI2CCLK}

so the requirement tPCLK < 4/3 tSCL

can be met.

Thanks again!