cancel
Showing results for 
Search instead for 
Did you mean: 

How fast is ADC able to work with USB?

SShir.2
Associate II

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

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

View solution in original post

5 REPLIES 5
TDK
Guru

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.

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

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]));

TDK
Guru

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.

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

Thank you for your help.

I will try.

AKhot.1
Senior

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.