XMC4500 - USB VCOM speed limit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello,

I am using the USB VCOM app to transfer ADC data from the XMC4500 Relax kit to my PC (using Matlab). I measured the transfer time for a buffer of 3 bytes and get a result of around 120µs (around 8kHz), which is quite slow comparing to its max speed of 12Mbps. I would like to ask if this speed is fixed or there is any way to increase it ?

I already tried the following methods:
- Change the clock speed in the DAVE App Configuration of CLK001: speed unchanged
- Change the baud rate on PC: speed unchanged
- Send 3 bytes separately using USBD_VCOM_SendByte: transfer time reduced to around 10µs but only 1 or 2 bytes arrived to PC. I don't understand why.

My goal is to reduce the transfer time for 3 bytes of data to < 20µs. Here is my main:
int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs (toggle comment if required)
int8_t byte_received = 0;
uint16_t Bytes = 0;
char TxBuffer[3];
uint16_t i,j;

DAVE_Init(); // Initialization of DAVE Apps
USBD_VCOM_Init();

TxBuffer[0] = '+';
TxBuffer[1] = 'A';
TxBuffer[2] = 'B';

while(1)
{
/* Main USB management task */
CDC_Device_USBTask(&USBD_VCOM_CDCInterface);

/* Check if data received */
Bytes = USBD_VCOM_BytesReceived();
if (Bytes)
{
USBD_VCOM_ReceiveByte(&byte_received);
for(i=0;i<1000;i++)
{
/* The IO004 app connected to a LED output to measure the transfer time */
IO004_SetOutputValue(IO004_Handle0,1);
USBD_VCOM_SendData(TxBuffer,3); // Pulse of 120µs shown on oscilloscope
IO004_SetOutputValue(IO004_Handle0,0);
for(j=0;j<1000;j++); // Delay to distinguish the transfer time on oscilloscope
}
}
}
return 0;
}


Thank you in advance.
0 Likes
5 Replies
Not applicable
Hi Idkv,

The data transfer to PC via USB interface is not exactly 3 bytes but rather a whole USB frame.
As far as I known, the data transfer rate of USB is basically fixed (12Mbps) but when can the data get transferred is depending on the Host.
For USB VCOM, the XMC4500 is work as USB device and it has no control when the data can be send to the Host.
Host will be the one to request for the data and then Slave will transfer the data to the Host.
So, basically when you want to send the data, the data to be transferred is put into a buffer awaiting for the Host request.
By the time the Host request the data, the transferring of data to the host will be transfer at the speed of 12Mbps.
0 Likes
Not applicable
Hi Jackson,

Thank you for your explanation, I misunderstood the functioning of the USB protocol. So what I measured is the time to transfer data from ADC to the USB buffer, not the transfer time from USB to PC. However, my problem is still there, how can I reduce this period ?

For more details, my aim is to transfer data continuously and infinitely from ADC (with sampling rate at 20kHz) to Matlab on PC for further treatment (eg. draw a graph).

The ADC is configured manually as Background Scan Source in Autoscan mode. A PWM interrupt is created (using DAVE Apps) at the desired sampling rate (20kHz) to save the data (12 bit) from ADC result register and trigger the USB.

The USB (using USBD_VCOM DAVE apps) immediately sends new data (with 3 bytes: 1 byte identifier, 1 byte with 8 high bits, 1 byte with 8 low bits) to its buffer => also at frequency of 20kHz. So the delay of the USB must be smaller then 1/20kHz = 50µs.

On PC, Matlab is programmed in continuous asynchronous mode to receive data.


Do you think this is the right way to do ? If not, could you suggest me a better solution please ?
0 Likes
Not applicable
Hi ldkv,

I am having the same problem as you. Did you manage to find a solution to reduce the delay of the USB to under 1/20kHz = 50µs?

regards
0 Likes
Not applicable
RicardoWT wrote:
Hi ldkv,

I am having the same problem as you. Did you manage to find a solution to reduce the delay of the USB to under 1/20kHz = 50µs?

regards

Hi Ricardo,

After some research I found that the USB speed is fixed (at 12Mbps) and we cannot change it. However, the speed to send 1 byte is the same to send 15 bytes (or even more) at once (around 200µs). So I created a buffer to store 15 bytes then send them all at once (using USBD_VCOM_SendData function).

Another solution is to use the UART (UART001) communication, which is faster and easy to configure. You can buy a Serial TTL to USB converter cable to connect the pins to PC.

Hope this will help.

Regards
0 Likes
Not applicable
RicardoWT wrote:
Hi ldkv,

I am having the same problem as you. Did you manage to find a solution to reduce the delay of the USB to under 1/20kHz = 50µs?

regards

Hi Ricardo,

After some research I found that the USB speed is fixed (at 12Mbps) and we cannot change it. However, the speed to send 1 byte is the same to send 15 bytes (or even more) at once (around 200µs). So I created a buffer to store 15 bytes then send them all at once (using USBD_VCOM_SendData function).

Another solution is to use the UART (UART001) communication, which is faster and easy to configure. You can buy a Serial TTL to USB converter cable to connect the pins to PC.

Hope this will help.

Regards
0 Likes