cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to work I2C fast mode(400KHz) and USB FS together in STM32F103VCT6

sruthi
Associate II
Posted on May 31, 2018 at 15:05

I want to use I2C fast mode(400KHz) and USB full speed mode in parallel. My controller is STM32F103VCT6. In reference manual I had read that for USB we must use 48MHz clock and also for I2C fast mode communication  i2c clock frequency must be a multiple of 10MHz . I'm not able to set a sysclk compactable for these two peripherals. Is there any solution for this? Please help...

8 REPLIES 8
T J
Lead
Posted on June 01, 2018 at 02:17

did you use the cubeMx ? it has a clock configuration visually, much easier to understand.

if you have a cube file, please send it over, I can check your clocks

sruthi
Associate II
Posted on June 01, 2018 at 12:56

Actually I'm working with Keiluv4. I'm not using cubeMx

In reference manual RM0008 they had written, for i2c fast mode operation i2c clock frequency must be a multiple of 10MHz. To achieve this I had set SYSCLK 40MHz (HSE: 8MHz and PLL :5). Configured Duty bit as 1(in I2C_CCR register,Actually I didn't understand yet the purpose of duty bit. I have attached the images from RM0008) . I had tested with this configuration and I was able to get fast mode I2C frequency(400KHz ).

But while integrating with USB full speed configuration I got stuck because USB

requires 

48MHz clk  frequency to work. Due to this I can only give sysclock 72MHz or 48MHz

to make USB working. By changing sysclk to 72MHz I2C clock becomes 36MHz(not a multiple of 10MHz). Using this clock configuration I tested I2C fast mode again. But now my I2C clock frequency changed from 400KHz to 480KHz(Data transfer is working normal) . But my requirement is 400KHz . I want use USB also.....

I believe that u are able to understand my problem now... Is there any solution for this....?

I tested with 48MHz sysclk and I couldn't acquire 400KHz

My requirement is I2C fast mode(400KHz) + USB full speed

0690X0000060L4QQAU.png0690X0000060L4LQAU.png
Posted on June 01, 2018 at 13:48

I made cube file for you...

I changed the crystal many times, there is no solution for 48MHz USB and x10MHz IIC

sruthi
Associate II
Posted on June 01, 2018 at 14:16

Then you are saying I2c fast mode and USB cannot use together using STM32F103VCT6.

Or is there any possibility to work i2c fast mode using 72MHz or 48MHz sysclk?

Thankyou

Posted on June 01, 2018 at 15:09

I think that fast mode can work at higher frequency above 400KHz on some IIC parts.

Some IIC peripherals will work and some will not.

Yes 8MHz  x9  /1.5 = 48MHz for USB, 72MHz for the processor HCLK and 36MHz for PCLK1.

Posted on June 01, 2018 at 15:14

Having 10MHz multiple at Pclk is only required to reach 400KHz exactly. Because the IIC in 16/9 duty mode requires 400Hz*(16+9)=10MHz input clock. Apparently the clock tree cannot generate that.

With another pclk speed, you can either run slower than 400KHz or change duty to 2/1. It will maybe run out of II2 fast mode spec but can be possibly supported by your slave device.

With 36MHz Pclk, duty 16/9, CCR=4, the speed should be 360KHz.

With 36MHz Pclk, duty 2/1, CCR=30, the speed should be 400KHz.

Posted on June 06, 2018 at 06:23

Thankyou... this is helpful ...I want to test using this configuration by updating I2C_CCR register.  So as per my understanding to reach exact 400KHz multiples of 10MHz need to use for I2C clk. By 36MHz I2C clk(pclk1) by adjusting CCR value we are able to reach around 400KHz not exact. Is this correct? 

And I'm sorry for the late reply...something personal

Thankyou

sruthi
Associate II
Posted on June 06, 2018 at 07:10

Thank you and sorry for the late reply

For 400KHz exact we should use I2C clk as a multiple of 10MHz. And to achieve around 400KHz( May a greater value or lesser value but near to 400KHz) by changing CCR values in I2C_CCR register (What

GONZALEZ.Laurent

said , see the below comment)

.

And now I,m going to calculate it and test. I'll let you know my results

Thank you