AnsweredAssumed Answered

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

Question asked by S. Verdoold on May 11, 2018

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?

Outcomes