cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 5, 3 & 1

zvivered
New Contributor II

Hello,

My host is connected to a PSOC that contains a USBUART. 

Upon PSOC boot completion, the PC has a new COM23. 

On the PSOC side I used the following code to initialize:

USBUART_1_Start(USBFS_DEVICE, USBUART_1_5V_OPERATION);    
while(USBUART_1_GetConfiguration() ==0);
USBUART_1_CDC_Init();

On the PC, COM23 is configured to 115200[baud], 8 (data bits), 1(stop bit). 

I succeeded to send a packet to the PSOC and get a reply from the PSOC. 

But it seems the rate is quite low. 

Example: I sent 28 bytes to the PSOC and got 36 bytes from PSOC. 
Expected: (28 + 36) * 8 = 64 bytes = 512 bits
The time required to send + receive should be: ~4.5msec
Actual: The elapsed time till I got a reply was much longer. 

Is it possible to improve the performance ?

Thank you,

Zvika 

0 Likes
1 Solution
Len_CONSULTRON
Honored Contributor II

Zvika,

There are two RTOS-preferred methods to do what you want to do.

  • This method doesn't require an interrupt so is code-simple.   

    • Lower the UART task priority.  This allows other tasks to process more.
    • Get rid of CyDelay(100u).  It's not needed.  Replace it with TaskYIELD().  This task should be activated every so often if the other tasks are not blocking.  I see you only have one task scheduled.
    • Since UsbUartReadMsg() performs a non-blocking UsbUartRead() then the UsbUartHandleMsg() is executed when the rc == USBUART_TASK_OK and a message is available.
  • The second method is to create a RTOS_friendly ISR.  The ISR will be attached to the RX_FIFO_NOT_EMPTY.  When the ISR executes,
    • it sets a Notify to the UsbUartTask() using xTaskNotifyFromISR()
    • Replace CyDelay() in UsbUartTask() with xTaskNotifyWait().
Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

8 Replies