Skip to main content
Visitor II
August 23, 2021
Solved

How fast is ADC able to work with USB?

  • August 23, 2021
  • 5 replies
  • 3460 views

Hello, I am trying to send ADC data (12 bit) to pc with USB as fast as possible. Now I am using STM32F405 and configured ADC like picture below. Those data of ADC is transfered to the pc by interrupt of DMA which is cirucular mode. And the data transfer rate is around 10k bps. Is this reasonable value? Is there better way to transfer faster than this ?

    This topic has been closed for replies.
    Best answer by TDK

    ADC stores either uint8_t or uint16_t values, depending on resolution. A buffer of uint32_t values isn't useful here.

    Otherwise, the code is correct.

    5 replies

    Super User
    August 23, 2021

    You'll need a buffer on the STM32 side to handle latency in the USB stream. Max FS USB data rate is going to be something near 8Mbit/s. Sending larger buffers over DMA will yield higher throughput.

    ADC and USB are independent. I would transfer ADC data into a separate buffer and send that over USB as fast as possible.

    SShir.2Author
    Visitor II
    August 23, 2021

    Thank you. I have another question. In cirucular mode, how can I change the buffer for DMA? Is code below accurate?

    uint32_t buffer[100];

    HAL_ADC_Start_DMA(&hadc1, (uint32_t *)buffer, sizeof(buffer)/sizeof(buffer[0]));

    TDKAnswer
    Super User
    August 23, 2021

    ADC stores either uint8_t or uint16_t values, depending on resolution. A buffer of uint32_t values isn't useful here.

    Otherwise, the code is correct.

    SShir.2Author
    Visitor II
    August 23, 2021

    Thank you for your help.

    I will try.

    Visitor II
    July 10, 2023

    Can you please tell me how were you able to make USB and DMA working together? I am using the same clock configuration as you even the parameter setting for the DMA are same. When I disable the Continuous Conversion mode the USB port shows up but when I enable it; it doesn't show up.

    AKhot1_0-1688991796731.png

     

    PS: I am able to send a string when the ADC and DMA were disabled.