USB as multiple COM ports?

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

cross mob
Anonymous
Not applicable

Hi there, I checked the USBUART component.

   

According to what I have understood, it lets the USB act as a COM port (which I can access via hyperterminal/putty,etc..)

   

Suppose my application requires me to have 2 [or multiple] COM ports.

   

Is it possible to have the USB act as multiple COM ports?

   

Regards.

0 Likes
13 Replies
JECA_264511
Level 3
Level 3
10 replies posted 5 replies posted First question asked
        Hello Goose. I hope you are better. please read at: http://www.cypress.com/?app=forum&rID=66583 best regards, jesus. pd, it if you are using psoc 3,4,5 platform.   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

The question was abourt USB-UARTs (CDC ports), not about physical UARTS.

   

I would guess that USB would support having multiple virtual COM ports over a single USB connection. For example the FT2232 supports this IIRC. But I would also guess that the default windows driver cannot handle this...

   

Also, the USBUART component cannot handle this AFAIK, you would need to roll your own USB device driver on the PSoC side...

   

What is your use case here? Is there a reason not to handle multiple transfers of a single COM port? (I think the useable bandwidth would also be reduced in this scenario).

0 Likes
JECA_264511
Level 3
Level 3
10 replies posted 5 replies posted First question asked
        Hi Hli. thanks for your reply and corrections. regards, jesus   
0 Likes
Anonymous
Not applicable

Hello hli, thanks for you reply......there is no particular reason for me not to use a single port for multiple transfers..

   

Its just that, I somehow got to know that using USB as multiple COM ports is infact possible in PSoC. So I just wanted to try it out.

   

However, I dont think it can be done by mere use of the APIs.

   

So I was just looking for a clue as to how to go through with it? [just to increase my PSoC knowledge]

   

 

   

Regards.

0 Likes
Anonymous
Not applicable
        Any update on this ......anyone? Regards.   
0 Likes
Anonymous
Not applicable

Hi there, I got to know that to actually achieve this [just incase anyone needs to...], one would require some changes to be made in the attached file........some application-level changes.

0 Likes
Anonymous
Not applicable

Hi Goose,

   

I am attempting to do the same. Could you advise me on how I can do this?

   

 

   

Many thanks,

   

G

0 Likes
lock attach
Attachments are accessible only for community members.
YaIs_283501
Level 3
Level 3
First like given

hello

I have created a composite device with two COM ports.

One COM port is operating correctly but the other COM port is not working properly...

Where should I fix it?

pic.png

0 Likes

It seems that there is an API function USBUART_GetComPort(void) to select one of two COM ports.  Following snapshot comes from the USBUART component datasheet.

GS003274.png

Actually, I didn't use this API function.  Can you try this API function?

Regards,

Noriaki

0 Likes

thank you for your reply.

I described SetComPort for each EP interrupt in USBUART_1_episr.c

For the time being, the program is working as intended.

Is this the correct way?

0 Likes
lock attach
Attachments are accessible only for community members.

You don't need to modify the episr file.  Just call USBUART_SetComPort() before calling port associated APIs.  I have modified the project attached to this discussion as follows.

   for(;;)

   {

        // the number of bytes       

        USBUART_SetComPort(USBUART_COM_PORT1);

        Count = USBUART_GetCount();

       

        if(Count != 0){

            //Get data

            USBUART_SetComPort(USBUART_COM_PORT1);

            USBUART_GetAll(Buffer);

            if(Buffer[0] == '?'){

                // Send data

                USBUART_SetComPort(USBUART_COM_PORT2);

                USBUART_PutData(Hello, Count2);

                //wait tx

                USBUART_SetComPort(USBUART_COM_PORT2);

                while(!USBUART_CDCIsReady()){}

            }else{

                // Echo data

                USBUART_SetComPort(USBUART_COM_PORT1);

                USBUART_PutData(Buffer, Count);

                //wait tx

                USBUART_SetComPort(USBUART_COM_PORT1);

                while(!USBUART_CDCIsReady()){}

            }

        }

    }

And the execution result as follows.

GS003277.png

At the end of for-loop you called USBUART_DataIsReady() API function to wait for TX completed.  But the API is incorrect.  USBUART_CDCIsReady is used to wait for the TX completion.

Attached project is modified for the CY8CKIT-059 without using the external crystal oscillator.

Regards,

Noriaki

lock attach
Attachments are accessible only for community members.

Thank you for your kindness.

We will provide a project for SetComPort in USBUART_1_episr.c for reference only.

And the execution result as follows.

test.png

The attached project file was created with CY8C5868AXI-LP035.

0 Likes

Please let me add a comment.

It is recommended to use a MACRO CALLBACK feature to add your own code to the ISR procedure.  You can declare a CALLBACK in the "cyapicallbacks.h" header file like as follows to be invoked from the ISR .

#ifndef CYAPICALLBACKS_H

#define CYAPICALLBACKS_H

   

    /*Define your macro callbacks here */

    /*For more information, refer to the Writing Code topic in the PSoC Creator Help.*/

    #define USBUART_1_EP_1_ISR_ENTRY_CALLBACK

    extern void USBUART_1_EP_1_ISR_EntryCallback(void);

   

    #define USBUART_1_EP_2_ISR_ENTRY_CALLBACK

    extern void USBUART_1_EP_2_ISR_EntryCallback(void);

   

#endif /* CYAPICALLBACKS_H */  

The callback function can be described in any C files like main.c

void USBUART_1_EP_1_ISR_EntryCallback(void) {

    USBUART_1_SetComPort(0);

}

void USBUART_1_EP_2_ISR_EntryCallback(void) {

    USBUART_1_SetComPort(0);

}

This feature was implemented in PSoC Creator 3.3  You don't need to modify the "Generated_Source" files anymore when using the CALLBACK feature.

Regards,

Noriaki

0 Likes