This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with Virtual Com Port

Hi all!
I try to implement a Virtual Com Port with eval board MCBSTM32. I started with the HID example provided in the download area.
There are two interfaces: I0: bulk in + bulk out with max. packet size = 64k, I1: interrupt in

So far everything works fine: I can connect my device to host and open Com port with TeraTerm.
Additionally I can write data to host (less or more than maxPacketSize=64k) and also receive one byte. But after the first transmission (in both directions) usb does not seem to work any more, i.e. ISR for bulk(in)-endpoint is not called when I write data to it.

Any help would be appreciated.

  • Andi;
    Two quick suggestions.
    One: Search this forum for more information on MaxPacketSize.
    Two: Look at Zero Length Packet (ZLP). Windows HID always looks for a complete packet as defined in the descriptor file. If you send less than a full packet, then you need to tell Win HID that the small packet is complete. This is the purpose of the ZLP.

    Bradford

  • Are you looking at any of already existing examples for other boards for reference?

  • Thank you for the quick answers.

    @Al Bradford
    In the first transmission I can send data with less than 64k data, with more than 64k data (= EPxwrite has to be called more than one time) and also with exactly 64k data. If less than maxpacketsize data is sent, the receiver automatically understands this as the end of transmission. In the latter case I have to send a ZLP afterwards to indicate the end of the transmission as described for bulk transfer. Is this what you mean by ZLP? Or is there any additional "termination" packet I have to send?

    On Win side I do not use HID, I use a VCP driver for connection with the device.

    @wild(1)
    I use the uVision 4 Development Environment which also provides an example from ST for the virtual com port. I looked through the code but could not find anything which could solve my problem.

  • > I started with the HID example provided in the download area.

    This one?
    "STM32 USB HID (Human Interface Device) Example"
    http://www.keil.com/download/docs/361.asp

    > EPxwrite

    Is it your custom function?
    Aren't USB_WriteEP() / USB_ResetEP() (usbhw_STM32F10x.c) enough?

    > also provides an example from ST for the virtual com port.

    Surely, KEIL example is much better than ST's.

    Tsuneo

  • Auu.. copy mistake.

    s/ USB_ResetEP / USB_ReadEP/

    Tsuneo

  • Hi Tsuneo,

    of course I use USB_ReadEP, USB_WriteEP, ... sorry, my misstake.

    The HID example I started from is that from http://www.keil.com/download/docs/361.asp, you are right.

    Surely, KEIL example is much better than ST's.
    Does KEIL also provide an example for VCP? Or do you mean the HID one?

    Andi

  • Hi all,

    I have solved my problem by just using a bulk IN Endpoint and a simple linux driver on host side.

    For sending about 1MB with MaxPacketSize of always 64 Byte I get a data rate of about 30 kbyte/s. I need a transfer rate of at least 120 kbyte/s.

    For Bulk transfer the STM32F103xx supports double bufferd bulk transfer (STM32F103xx Reference manual). Both examples for the MCBSTM32 board (USB_HID and USB_MSC) write that double buffering is not yet supported. Is the limitation within hardware or is it possible to "just" add the code to get higher transfer rates by double buffering?

    Has anyone else achieved higher data rates with this uC?

    Any help would be appreciated.