cancel
Showing results for 
Search instead for 
Did you mean: 

Usb otg conflict with i2c on stm32f4 board?

KGon
Associate

I have the stm32f429 discovery board and I'm experiencing a conflict between the usb otg hs and the i2c3. I use the cdc usb library which when initialized on it's own works fine as a virtual com port and I can communicate in windows. When any other communication peripheral is initialized such as I2C or USART, the usb vcp is still visible in windows but I cannot connect with putty or realterm. Here is the USB init and I2C init code. When I2C is commented out, the communication works fine:

void MX_USB_DEVICE_Init(void)
 
{
 
  /* Init Device Library, add supported class and start the library. */
 
  if (USBD_Init(&hUsbDeviceHS, &HS_Desc, DEVICE_HS) != USBD_OK)
  {
    Error_Handler();
  }
 
  if (USBD_RegisterClass(&hUsbDeviceHS, &USBD_CDC) != USBD_OK)
  {
    Error_Handler();
  }
 
  if (USBD_CDC_RegisterInterface(&hUsbDeviceHS, &USBD_Interface_fops_HS) != USBD_OK)
  {
    Error_Handler();
  }
 
  if (USBD_Start(&hUsbDeviceHS) != USBD_OK)
  {
    Error_Handler();
  }
 
}
 
static void MX_I2C3_Init(void)
{
 
  hi2c3.Instance = I2C3;
  hi2c3.Init.ClockSpeed = 100000;
  hi2c3.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c3.Init.OwnAddress1 = 0;
  hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c3.Init.OwnAddress2 = 0;
  hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
 
  if (HAL_I2C_Init(&hi2c3) != HAL_OK)
  {
    Error_Handler();
  }
 
  /** Configure Analogue filter 
  */
  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Digital filter 
  */
  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK)
  {
    Error_Handler();
  }
 
}

I though it was an ISR priority problem so I've played around with different ISR priorities for the 2 peripherals with no success. Plus I am not explicitly enabling ISR for the I2C peripheral. Something is going on in the HAL init routines but I haven't been able to understand what.

Has anyone else experienced this?

1 REPLY 1
Pavel A.
Evangelist III

This is a case for the CubeMX. Even if you don't use it generally. Create a quick project, and it will show if components have conflicting pins.

-- pa