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.

Problem with cc2538 usb cdc.

Other Parts Discussed in Thread: CC2538

The example project given in the foundation software for usb cdc works well without any modification in the code.

When I tried to add a delay of  1sec as follows,

while (1)

{

        usbCdcProcessEvents();

        //
        // Implement COM-port loopback
        //
        uint16_t count = usbibufGetMaxPushCount(&usbCdcInBufferData);
        uint16_t maxPopCount = usbobufGetMaxPopCount(&usbCdcOutBufferData);
        if (count > maxPopCount)
        {
            count = maxPopCount;
        }
        if (count)
        {
            usbobufPop(&usbCdcOutBufferData, pAppBuffer, count);
            usbibufPush(&usbCdcInBufferData, pAppBuffer, count);
        }

SysCtrlDelay (SysCtrlClockGet ());

}

and I plug the usb cable with the EVM, the device is not getting detected and not showing any COM port....

Can somebody help ?

Thanks & Regards,

Flaby

  • Hi,

    The reason why this is happening is because you are slowing down you device when it is trying to tell your PC that it is a CDC device therefore your computer most likely times out and has no way of recognizing the CC2538. A quick fix to this would be to add the following loop right before your while (1) loop:

    uint32_t x = 0;
    for(x = 0; x < 100000;x++)
    {
    usbCdcProcessEvents();
    }

    The number of loops doesn't have to be specifically 100000, it has to be a big enough number so the CC2538 has enough time to identify itself to the PC. Note that this fix is not very reliable since if you power up the device with an external source and then you connect the USB cable then the PC wont recognize it since the program will be already out of the for loop. I would recommend to not add a delay but if for some reason you have to have one then you will have to find a way to not delay usbCdcProcessEvents().

    Regards,
    Hector
  • Hi,
    I am not sure what you want to achieve by adding such a huge delay (btw, the delay function is 3 cycles x loop so it is actually 3 secs) in the while loop, but the reason that the device is not enumerating is actually because the USB transactions times out during the enumeration procedure from the host, and it is because you are adding that huge delay.

    In fact, usbCdcInit function executed outside of the loop initializes the USB CDC stack, the interrupt handler and then enable the pull up on D+ to trigger the enumeration process from the host.
    Then the host, notified of that transaction on D+ line, starts the actual logical enumeration process doing data transfer through USB pipe discovering endpoint descriptors.
    What I suspect is that if your delay is too big, then the host times out. I tried with smaller delays (like 300 cycles at system clock speed) and it worked.

    Thanks,
    TheDarkSide
  • Hi Hector & Darkside,

    Thanks for the reply.

    I tried the fix and worked.

    On my customized board with CC2538, I have a GSM module interfaced with CC2538.

    So I may go for a lengthy task like making a voice call or sending an SMS immediately after entering into the while (1) loop. Or I may go for any of the power mode after the initializations...

    This condition is same as adding a delay in the main loop. That is why  I tried it.

     Thanks & Regards,

    Flaby

  • Thanks for the follow up. If you think this our reply solved your issue, may I ask if you can kindly click on 'Verify Answer'?
    Thanks
    TheDarkSide