cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7A3 STM32H7A3ZIT6Q CDC_Transmit_HS Speed limit about to 600.000 Octets/second

Marius CO
Associate III

I have an ADC+DMA read that can performs at 4Mbytes/second.

The conv is 12 bit, clock division is 1_of5. On the callback DMS interrupts

I send half data's to USB using CDC_Transmit_HS.

The ADC buffer is 1K. I Also tried 2, 4, 8, 16k. I played with the clock division for ADC and

conversion cycles to tweak the ADC speed up to the point the . CDC_Transmit_HS returns USB_BUSY. The maximum rate I could achieve was 592896 bytes /second, (no send errors) I guess with division 1 and 3conv_5 cycles. The host was Linux and Windows (same cutt of speed)

My target is 1M bytes/second as the USB can go up to 40Mbits /second -> 3Mbytes/second.

Where I am wrong here ?

void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
  if(pcdHandle->Instance==USB_OTG_HS)
  {
  /* USER CODE BEGIN USB_OTG_HS_MspInit 0 */
 
  /* USER CODE END USB_OTG_HS_MspInit 0 */
 
  /** Initializes the peripherals clock
  */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB;
    PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
    {
      Error_Handler();
    }
 
  /** Enable USB Voltage detector
  */
    HAL_PWREx_EnableUSBVoltageDetector();
 
    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**USB_OTG_HS GPIO Configuration
    PA8     ------> USB_OTG_HS_SOF
    PA9     ------> USB_OTG_HS_VBUS
    PA10     ------> USB_OTG_HS_ID
    PA11     ------> USB_OTG_HS_DM
    PA12     ------> USB_OTG_HS_DP
    */
    GPIO_InitStruct.Pin = GPIO_PIN_8|USB_FS_ID_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; // GPIO_SPEED_FREQ_LOW; // mco-
    GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_HS;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = USB_FS_VBUS_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(USB_FS_VBUS_GPIO_Port, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = USB_FS_N_Pin|USB_FS_P_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;// GPIO_SPEED_FREQ_LOW; // mco-
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    /* Peripheral clock enable */
    __HAL_RCC_USB_OTG_HS_CLK_ENABLE();
 
    /* Peripheral interrupt init */
    HAL_NVIC_SetPriority(OTG_HS_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
  /* USER CODE BEGIN USB_OTG_HS_MspInit 1 */
 
  /* USER CODE END USB_OTG_HS_MspInit 1 */
  }
}

Thank you.

1 REPLY 1
AScha.3
Chief III

> Where I am wrong here ?

  1. USB full speed has 12 Mbit .
  2. max. data load depends on overhead and use by other members
  3. i got about 1 MB/s (with CDC) , what is close to maximum in real world, i suppose.

so your 0,6MB is quite good.

If you feel a post has answered your question, please click "Accept as Solution".