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.

F28M35x USBLIB problem.

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

  i try to connect my mass storage(pen drive) with USB port. I attached my device and use the code from ControlSUITE( usb_host_msc_m3). I am using F28M35H52C1 MCU. Whenever i try to connect my pendrive to MCU, then power is coming to pendrive. But driver was not opening. I searched in the USBLIB source code. i found something that, in the  

//
// Open an instance of the mass storage class driver.
//
g_ulMSCInstance = USBHMSCDriveOpen(0, MSCCallback);

this routine is not calling driver opening function(USBHMSCOpen).

so i am getting NO Device connect error. 

Please help me to resolve this error.

Thanks in advance 

Thirumoorthy.R


  • Hi,

    How were you able to detect that the function was never been called ? Using step-into functionality?

    Secondly is your pd fat16/fat32 formatted? Please provide some more info on the board you're using custom/ kit and the usb interface implementation.

    Regards,

    Gautam

  • Gautam,

       After opening the driver function(in the example code from ControlSUITE) i added a function to check whether driver is ready or not which is API  --> USBHMSCDriveReady(unsigned long ulInstance); This function will return 0 if the driver is open an ready to work.    

       I am using a custom board with HOST_MODE interface. My pendrive is fat32 formatted. 

  • Hello,

    long time ago I dealt with the USB lib... I will try to remember...

    Well, you already read my last thread. There is already a good suggestion. Which driverlib are you using?
    As I wrote in the thread RE: USB Lib, MSC Host application hangs when device is removed I had problems with V201. When connecting any MSC device, the driverlib stalled somewhere so my WDT caused a reset.

    I had no problems with driverlib V160 (except that you should increase the stack size of the example project when dealing with the file system!). I would advice you to try this out!

    Actualy I don't understand your problem correctly. If the function USBHMSCDriveReady() will return 0, then the MSC device (not the driver!) is ready. A good way to check for the device status events are the callback functions

    static void MSCCallback(UINT32 ulInstance, UINT32 ulEvent, void *pvData)

    and

    static void USBHCDEvents(void *pvData)

    I use these functions to set my own application status bits regarding the USB device/driver status (MscDeviceConnected, UnknownDeviceConnected, PowerFault)

    I don't think a wrong file system would be a problem, since the host driver will detect any "slave" devices. If I connect a computer mouse or a USB hub to my USB port I will get the event "unkown device" (meaning "no MSC device") from the host driver. But you need a FAT system for data access with the FatFs.

    Regards,
    Stefan

  • Hi stefan,

      Thanks for your reply. 

    I really confused. I use the code which is from control. I dint change anything.  When i am connecting my UART with Hyper terminal, i am getting NO_DEV. From that i decided that USB is not connected with MSC.

      Could you please post your code which is related to USB MSC. I used the USBLIB from V160 only.

    Thanks in advance

    Thirumoorthy.R

  • Hello,

    as far as I remember I did not have any problems running the example code from TI Control Desk Concerto M35 driverlib V160 (except the mentioned stack issue). It was straight away.

    Sorry but I can't give you my adopted code for my bootloader application. I'm not a TI support engineer.
    But honestly there is not much to it. I just wrote an simple state machine for the device handler which is changing with the events of the driverlib using the provided callback functions. The more advanced things are located in the file handling...

    But I gave you already some hints to check further, where the problem could be.

    Do you get the USB Host events from the driverlib?

    Do you get the MSC events from the driverlib?

    What is the return code of that function USBHMSCDriveReady()? If it is 0 as mentioned earlier than it should be ready to use.

    Does your program stall?

    Is there something wrong with UART output? Use the debugger to determine the status of the MSC device.

    Are you using the evaluation board? I havent't used this since I already worked with an own processor board.
    Maybe you are using the wrong USB connector or you have to check if the provided connector is ready to use with a USB device (jumper settings etc.)? Is your initialization correct?

    Happy searching...

    Regards,
    Stefan

  • Hi, 

      i am new to USB. First of all i import the example program "usb_host_msc_m3" from v160. And i configure the correct GPIO pins which i used in my custom board( not in experimental board).

    I just run the program. In my UART terminal i got,

    USB Mass Storage Host program
    Type 'help' for help.

    NODEV>

    From this, ifound my MSC is not found. Is that anything wrong with code.

    Code is below

    int
    main(void)
    {
    int iStatus;

    g_eUIState = STATE_NO_DEVICE;

    //
    // Setup main clock tree for 75MHz - M3 and 150MHz - C28x
    //
    SysCtlClockConfigSet(SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_USE_PLL |
    (SYSCTL_SPLLIMULT_M & 0x0F));

    //
    // Setup USB clock tree for 60MHz
    // 20MHz * 12 / 4 = 60
    //
    SysCtlUSBPLLConfigSet(
    (SYSCTL_UPLLIMULT_M & 12) | SYSCTL_UPLLCLKSRC_X1 | SYSCTL_UPLLEN);

    //
    // Enable the UART.
    // Enable the peripherals used by this example.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

    // Set GPIO E4 and E5 as UART pins.
    GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    GPIOPinConfigure(GPIO_PD4_U3TX);
    GPIOPinConfigure(GPIO_PD5_U3RX);
    UARTStdioInit(3);
    UARTprintf("\n\nUSB Mass Storage Host program\n");
    UARTprintf("Type \'help\' for help.\n\n");

    //
    // Register interrupt handlers in the RAM vector table
    //
    IntRegister(INT_USB0, USB0HostIntHandler);
    IntRegister(FAULT_SYSTICK, SysTickIntHandler);

    //
    // Configure SysTick for a 100Hz interrupt.
    //
    SysTickPeriodSet(SysCtlClockGet(SYSTEM_CLOCK_SPEED) / TICKS_PER_SECOND);
    SysTickEnable();
    SysTickIntEnable();

    //
    // Enable Clocking to the USB controller.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

    //
    // Set the USB pins to be controlled by the USB controller.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

    // USB Pins
    GPIOPinConfigure(GPIO_PE4_USB0EPEN);
    GPIOPinConfigure(GPIO_PE5_USB0PFLT);
    GPIOPinTypeUSBDigital(GPIO_PORTE_BASE, GPIO_PIN_4);
    GPIOPinTypeUSBDigital(GPIO_PORTE_BASE, GPIO_PIN_5);
    GPIOPinTypeUSBAnalog(GPIO_PORTF_BASE, GPIO_PIN_6);
    GPIOPinTypeUSBAnalog(GPIO_PORTG_BASE, GPIO_PIN_2 | GPIO_PIN_5 | GPIO_PIN_6);

    //
    // Initialize the USB stack mode and pass in a mode callback.
    //
    // USBStackModeSet(0, USB_MODE_OTG, ModeCallback);
    USBStackModeSet(0, USB_MODE_HOST, ModeCallback);

    //
    // Register the host class drivers.
    //
    USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS);

    //
    // Open an instance of the mass storage class driver.
    //
    g_ulMSCInstance = USBHMSCDriveOpen(0, MSCCallback);

    //
    // Initialize the power configuration. This sets the power enable signal
    // to be active high and does not enable the power fault.
    //
    USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER);

    //
    // Initialize the USB controller for OTG operation with a 2ms polling
    // rate.
    //
    // USBOTGModeInit(0, 2000, g_pHCDPool, HCD_MEMORY_SIZE);
    USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE);

    //
    // Initialize the file system.
    //
    f_mount(0, &g_sFatFs);

    //
    // Enter an infinite loop for reading and processing commands from the
    // user.
    //
    while(1)
    {
    //
    // Get a line of text from the user.
    //
    ReadLine();
    if(g_cCmdBuf[0] == '\0')
    {
    continue;
    }

    //
    // Pass the line from the user to the command processor.
    // It will be parsed and valid commands executed.
    //
    iStatus = CmdLineProcess(g_cCmdBuf);

    //
    // Handle the case of bad command.
    //
    if(iStatus == CMDLINE_BAD_CMD)
    {
    UARTprintf("Bad command!\n");
    }

    //
    // Handle the case of too many arguments.
    //
    else if(iStatus == CMDLINE_TOO_MANY_ARGS)
    {
    UARTprintf("Too many arguments for command processor!\n");
    }

    //
    // Otherwise the command was executed. Print the error
    // code if one was returned.
    //
    else if(iStatus != 0)
    {
    UARTprintf("Command returned error code %s\n",
    StringFromFresult((FRESULT)iStatus));
    }
    }
    }

    Please help me to resolve this problem.

    Thirumoorthy.R

  • Thirumoorthy,

    I'm taking a look at this and have confirmed that there does appear to be an issue.  I'll try to get a solution later today or early next week.

    Regards,

  • Hi Trey,

    Thanks for your reply and your valuable time. 

    Now its working. It is because of my connector. My connector was not solder properly. So D- line is not connected. Now i checked everything. TI example works perfectly. 

    Thanks in advance

    Thirumoorthy.R

  • Glad to hear you got it working!