USB virtual serial port error at high transfer rates?

01 Jul 2012

Hi,

I am using the USB virtual serial port interface of the mbed, however, an error occured:

I have the following code

#include "mbed.h"
#include "USBSerial.h"

//Virtual serial port over USB
USBSerial serial;

int main(void) {

    while(1)
    {
        serial.printf("I am a virtual serial port!\r\n");
        wait(0.005);
    }
}

However, If I connect the mbed with my serial port, it stops working. Changing the wait command to values of around 0.1 sec works fine. What is the problem here? To high transfer rate?

Thank everybody for helpfull comments,

Tobias

02 Jul 2012

never mind

02 Jul 2012

Why use USBSerial? I always just use the standard: Serial pc(USBTX, USBRX);

Never had any problems with it, including with datarates approaching 1mbit/s.

03 Jul 2012

Thank you for your reply.

It is my understanding that the Serial pc() option simply establishes a virtual com port which is bound to a certain baud rate, which as well is much slower than that what is possible via "normal" USB. Moreover, using Serial pc() you are seeing the mbed-memory as drive in the file browser. However, did nobody (maybe from the mbed team) ever experience such a problem? Or is somebody able to replicate it? I use realterm software in order to read data, maybe the problem is there? Or is it likely that the fast USB transmission doesn't allow the mbed MCU to respond to any interrupts or whatever in order to keep up the USB connection?

Tobias

03 Jul 2012

Try

Without the wait. Does it work?

I think it is the Printf statement that slows it down.

Samuel Mokrani wrote:

Hi,

@Kamyar: I did some experiments. I am able to send 9000 packets of 64 bytes/s from the mbed using the serial.writeBlock function. Be sure to delete all printf, ... because it is very slow otherwise. For the reception, I can receive about 1500 packets/s (callback attached when a message is received). Theoretically, USB 3.0 should be a big difference (5Gbit/s!!). I can't wait to test USB 3.0.

@d asao: You are not using the right library for your need. Indeed, the FTDI chip is already a USB device which has to be connected to a USB host. If you want, the USBSerial library "emulates" a FTDI chip. So it's normal that it does not work. For the moment mbed is not supporting an official USB Host library but a good beginning can be to explore: BlueUSB

Hope that helps,

Sam