cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 ADC+DMA+USB -> what is a reasonable speed?

S. Verdoold
Associate
Posted on May 11, 2018 at 00:41

I am trying to use a STM32F103 as a sampling device to sample a signal at a rate of 200-300kHz for multiple seconds. Using CubeMX the ADC conversion was configured and DMA using a circular buffer was applied. This all seems to work as expected. However the usb transfer speed is way to low (in the order of at most a few kilobytes per second).

I'm using the ST USB library in cdc mode and use the bulk transfer modes for the data transfer. Although the stm32F103 is not top-of-the-line  I expect the throughput should be higher than what I get so something must be wrong.

Because the HAL_ADC_ConvCpltCallback() and HAL_ADC_ConvHalfCpltCallback() functions are called as expected I think the DMA part is working. Inside these callbacks the CDC_Transmit_FS() is used to send half the buffer over usb, so it is called relatively frequently. Is this a problem in combinaton with the Bulk transfers I try to use? Is there maybe some way to call the transmit function once and use the buffer in a circular way?

2 REPLIES 2
QZhao
Associate

Hi, have you fixed this problem? I bet so. Would you mind sharing your code? I am new to everything here and going to have a project involving ADC (timer triggered, two channels) - DMA - USB. Thanks in advance!

Hi! Same situation! Mind if you could share how did you fix the problem? Many thanks!