RT1021 USB FreeRTOS Requires Send to continue?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RT1021 USB FreeRTOS Requires Send to continue?

1,749 Views
variable_andrew
Senior Contributor I

I'm testing the dev_composite_cdc_vcom_cdc_vcom_freertos demo - 

In virtual_com.c , if I comment out the copy to TX, so that there is no data TX, then it appears that the RX will only execute once and all subsequent RX data is ignored. 

Any idea on why that is?

I'm referring to the below function. 

So normally, the "user code" check for recvSize is true every time I send data from terminal via USB.

BUT if i comment out the code to trigger a send, for some reason vcomInstance->recvSize is only ever != 0 once. 

void USB_DeviceCdcVcomTask(void)
{
    usb_status_t error = kStatus_USB_Error;
    volatile usb_cdc_vcom_struct_t *vcomInstance;

    for (uint8_t i = 0; i < USB_DEVICE_CONFIG_CDC_ACM; i++)
    {
        vcomInstance = &g_deviceComposite->cdcVcom[i];
        if ((1 == vcomInstance->attach&& (1 == vcomInstance->startTransactions))
        {
            /* User Code */
            if ((0 != vcomInstance->recvSize&& (0xFFFFFFFFU != vcomInstance->recvSize))
            {
                int32_t i;

                /* Copy Buffer to Send Buff */
                // Comment out the below 3 lines - then the RX block is only executed once 
                // for (i = 0; i < vcomInstance->recvSize; i++)
                // {
                //     vcomInstance->currSendBuf[vcomInstance->sendSize++] = vcomInstance->currRecvBuf[i];
                // }
                vcomInstance->recvSize = 0;
            }

            if (vcomInstance->sendSize)
            {
Labels (2)
0 Kudos
5 Replies

1,368 Views
R3t0
Contributor II

Hi

I have exactly the same problem. When data is received the function USB_DeviceCdcVcomTask() is executed. In the example, after each vcomInstance->receiveSize is > 0, the function USB_DeviceCdcAcmSend() is executed, beacuse the content from input is copied to output and therefore vcomInstance->sendSize is > 0.
If I want to wait for more data without calling USB_DeviceCdcAcmSend(), USB hangs up.

0 Kudos

1,502 Views
variable_andrew
Senior Contributor I

Hi Daniel,

Thanks for the response - I've responded to you in the RT1052 thread (USB CDC VCOM - Consecutive RXs Fail ) w/ how to reproduce.

Just for posterity, IDE: MCUXpresso 11.1.1 OSX.

I know all subsequent RX's are ignored because if I wait for USB to quit responding, I can then set a breakpoint inside the 0 != s_recvSize if statement, and never get there again.

Serial port testing done on OSX and Windows - the RT1052 stops getting RX in both cases as soon as the USB_DeviceCdcAcmSend is skipped for a packet.

Please give the code I shared in the https://community.nxp.com/message/1286718  thread (minus using OTG2 since I'm assuming you'll be on OTG1) a shot and see if you can reproduce

0 Kudos

1,502 Views
variable_andrew
Senior Contributor I

I'm still seeing this, seeing the same thing on the RT1052 w/ SDK2.7.0 as well.

Anyone understand why the USB stack is working this way?

0 Kudos

1,502 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Variable_andrew:

I am trying to reproduce your issue on my side, I will let you know my result later.

Regards

Daniel

0 Kudos

1,502 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Andrew:

Did you change other code on the dev_composite_cdc_vcom_cdc_vcom_freertos demo?

The function of the commented code is to echo back the characters it receives.  From my understanding it should not impact the receive function.

How do you know the RX will only execute once and all subsequent RX data is ignored?

Did you test it with Windows OS or Linux OS? Which IDE you are using?

Regards

Daniel

0 Kudos