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.

TMS320F28388D: Switch between HOST (MSC) and DEC (CDC) with C28x CPU1 USB

Part Number: TMS320F28388D
Other Parts Discussed in Thread: TUSB320LI

Hi,

My customer wants to switch between HOST (MSC) and DEC (CDC) with C28x CPU1 USB.

They are programming with usb_ex8_dual_detect as a reference, but once they recognize the MSC, they can't switch to the CDC without resetting the device. Is there a sample program to switch modes without resetting the device?

Best regards,
Sasaki

  • Hi Sasaki,

    They are programming with usb_ex8_dual_detect as a reference, but once they recognize the MSC, they can't switch to the CDC without resetting the device.

    This example checks the state of GPIO 47 in the while loop to switch between Host and device modes. Can you check the GPIO47 data register for the value being read by the c2000 device?

    Best,

    Kevin

  • Hi Kevin-san,

    Thank you for your reply.

    Yes. They check the GPIO47 data register.

    Their USB switching code is below. Is this code incorrect?

        if (USB_ID_iBit != oldID){
            oldID = USB_ID_iBit;
            if (USB_ID_iBit){
                bUsbHostMode = false;
                //
                // Device Mode
                // Kill the host mode
                //
                USBHCDTerm(0);
                USBHMSCDriveClose(g_psMSCInstance);
                //DeviceMode
                    //
                // Initialize the transmit and receive buffers.
                //
                USBBufferInit(&g_sTxBuffer);
                USBBufferInit(&g_sRxBuffer);
                //
                // Pass our device information to the USB library and place the device
                // on the bus.
                //
                USBDCDCInit(0, &g_sCDCDevice);
            
                //create que for receive data
                make_queue_char(&usbcdc_receive_queue,buf_usbcdc_receive_queue,QUEUE_LENGTH_USBCDC_RECV);
                make_queue_char(&usbcdc_receive_2nd_queue,buf_usbcdc_receive_2nd_queue,QUEUE_LENGTH_USBCDC_RECV_2ND);
                make_queue_char(&usbcdc_send_queue,buf_usbcdc_send_queue,QUEUE_LENGTH_USBCDC_SEND);
            }
            else{
                bUsbHostMode = true;
                //
                // Host Mode
                // Kill the Device mode
                //
                USBDCDCTerm((void *)&g_sCDCDevice);
                //HostMode
            	USBStackModeSet(0, eUSBModeForceHost, ModeCallback);
            	UsbHostStackInit();
            	USBHCDInit(0,g_pHCDPool, HCD_MEMORY_SIZE);
                f_mount(0, &g_sFatFs);
            }
        }

    Best regards,
    Sasaki

  • Sasaki,

    What is the code  for "USB_ID_iBit" ?   Is it reading the GPIO47 pin?

    Best Regards

    Siddharth

  • Hi Siddharth-san,

    Thank you for your reply.

    USB_ID_iBit is connected to GPIO114.

    The customer is using TUSB320LI and this IC outputs USB_ID. Since this USB_ID signal is connected to GPIO114, the program can branch to a USB Host or Device.

    By the way, is there example project that can switch between MSC (USB memory) and CDC (serial port) with ControlCARD? If there is, I would like to confirm it there.

    Best regards,
    Sasaki

  • Sasaki,

    There is no specific example that can switch between MSC and CDC , however usb_ex8_dual_detect example can be used as reference

    Best Regards

    Siddharth

  • Hi Siddharth-san,

    They have already referred to that example. Please let me know if there are any problems with their code.

    Best Reagrds,
    Sasaki

  • Sasaki,

    The code seems to be correct. You can ask them to debug and see if the USB_ID_iBit is read correctly in device and host mode.

    Best Regards

    Siddharth

  • Siddharth-san,

    Thank you for your support.

    OK. I will check with my customer.

    Best regards,
    Sasaki