This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB CDC

Hi,

I'm stuck in Sending USB-Data. My code is like this:

while (1)
if (usb_state == ST_ENUM_ACTIVE) {
   rc = USBCDC_intfStatus(CDC0_INTFNUM, &bytesSent, &bytesReceived);
   if (!rc) { // O.K.
         sprintf(data, "Ich bin hier:%d\n", out_count++);
	rc = cdcSendDataInBackground(data, sizeof(data), CDC0_INTFNUM, 0);
    } else {
       __no_operation();
   }
}

after > 1000 loops the state rc stays on
kUSBCDC_waitingForSend

Any idea?

  • I've just read:

    //! \return \b 0 if the call succeeded; all data has been sent.
    //! \return \b 1 if the call timed out, either because the host is unavailable
    //!     or a COM port with an active application on the host wasn't opened.
    //! \return \b 2 if the bus is unavailable.
    //
    //*****************************************************************************
    BYTE cdcSendDataInBackground (BYTE* dataBuf,

    Need the USB-Link an active application?

    For test-purposes, I wait for an command from the PC. Then it works fine.

    But I don't want a "start command". How do I get the state of an application on the PC?

    Why does the timeout comes not until>1000 loops? Is there a FIFO?

    Any hints are welcome.

  • Steffen Netz said:
    Why does the timeout comes not until>1000 loops? Is there a FIFO?

    There is a buffer at the driver level on the PC side, but no application reading data out. Eventually it fills up.

  • Steffen Netz said:

    Any hints are welcome.

    Try to explain for what you want to use CDC.
    In general, sender / receiver must know in advance data transfer length, and before each CDC enumeration (device restart) you must close port on PC side, and open it again after enumeration is done.
  • That seems to be the answer. I have to open a application on the PC side.

    Thanks

  • hello Steffen,

    I'm trying to create a USB serial communication between my MSP-TS430PN80USB experimentor oard and the pc. Now, from the user experience demo, it seems simple, and actually it is.

    However, without changing anything, nothing seem to work these few days. My codes compiled correctly, no errors indicated, and it downloaded correctly into the flash memory. However, while running the programme, I was unable to use HyperTerminal or Putty on COM4 (that's where MSP-FET430UIF - VCP is).

    If I do the other way round, meaning that I start Hyperterminal or Putty on COM4 on 57600 bauds, and I compiled and tried to debug the project, an error message was displayed on CCSv4 "Error Initializing Emulator: MSP-FET430UIF is already in use".

    Thanks again for your help!

    Claire

  • Hi Claire,

    you have to differentiate between your custom USB-CDC-virtual port and the port the FET430UIF is using.

    You don't must to access the latter one. You have to watch which port is assigned to your virtual COM-port

    during installation. Look into the device-manager or take a better terminal as hterm(http://www.der-hammer.info/terminal/)

  • Hi Steffen,

    in my application the FET430UIF is using COM1 and when i look in to the device-manager the VCP is label:

    MSP-FET430UIF - CDC (COM1). I choose COM1 for the Hyperterminal. It still dont work.

    Kann you please give me a picture of your measurement setup? It will be great

    Thanks for replying

  • yonkou claire said:

    in my application the FET430UIF is using COM1 and when i look in to the device-manager the VCP is label:

    MSP-FET430UIF - CDC (COM1). I choose COM1 for the Hyperterminal. It still dont work.

    The FET430UIF is the debugger. This attaches to the PC as a virtual com port, which then the debugging/programming drivers for CCS/IAR/etc use for programming and source-level debugging of your application code. It is NOT a serial port interface to the UART module on your device.

  • yonkou claire said:
    MSP-FET430UIF - CDC (COM1).

    This is, as the name says, the FET430UIF. If you select it in HyperTerminal, you are talking to the FET, not to your MSP. This COM port is only for use by the debugger. The FET430UIF does not provide a data bridge to the target MSP. Only the embedded eZ430 FETs on the LaunchPads do.

  • Hi,

    I've attached a picture from the device-manager.

    You can see:

      MSP-FET430UID CDC(COM28) -> this is the debug-interface not for you!!

      Virtual COM Port(CDC)(COM34) -> this is your (my) MSP

  • Hi Steffen,

    Thanks a lot. Does that means, that you have the both USBs attached at the same time?(The one who connects the debug box to PC and the other who connects the MSP device to the PC).

    Thank you all for replying

  • Not necessarily.

    Please concentrate on the Virtual COM Port.

  • yonkou claire said:
    Does that means, that you have the both USBs attached at the same time?

    Not have to: One is for debugging and between PC and debugger, the other one is between PC and the target MSP for data transfer with your application. Two different USB controllers, two different CPUs behind, and two different purposes.

    If the second COM doesn’t appear, your application firmware doesn’t work correctly.

**Attention** This is a public forum