Skip to main content
Visitor II
December 14, 2020
Question

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

  • December 14, 2020
  • 2 replies
  • 1185 views

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)

    This topic has been closed for replies.

    2 replies

    Graduate II
    December 14, 2020

    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.5Author
    Visitor II
    December 14, 2020

    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?