cancel
Showing results for 
Search instead for 
Did you mean: 

How to use USB Device and I2C at the same time? (STM32F401CE)

MJohn.5
Associate

Hello Community,

I can create projects with CubeMX and CubeIDE to transmit or transmit/receive USB Virtual Com data with a STM32F401CE.

As soon as the I2C peripheral is enabled, the USB fails. Commenting out the added lines indicates that this is the problem:

__HAL_RCC_GPIOB_CLK_ENABLE();

Some of the forum posts state that only one peripheral can be clocked from a PLL. The suggested code changes don't compile and the functions, structures, fields, and values are not present in my APIs. Apparently the API's have changed recently.

What is the solution to this problem?

Which document(s) explain how to resolve this?

Thank you,

Mark

  • STM32CubeMX (Version 6.1.0)
  • STM32CubeIDE (Version 1.5.0)

2 REPLIES 2
Uwe Bonnes
Principal III

USB and I2c can work at the same time, as long as they have no GPIO pin in common. HAL probably has an error, or youg usage of HAL. Solution is to get things right. Things are explained in thr reference manual.

MJohn.5
Associate

There is no I/O conflict:

USB Pins are PA11, PA12.

I2C Pins are PB6, PB7

The STM32F40x and STM32F41x Errata Sheet (ES0182 Rev 12) lists several I2C issues but none of them relate to the USB.

CubeMX indicates no clock errors.

The code builds without warnings.

The Reference Manual (RM0368) doesn't specifically say that USB and I2C can work together.

Google shows that many people have this problem. Has anyone gotten it to work?