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: CM USB host example

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

Hello all,

I'm running some tests on the F28388D, using the Controlcard + docking station. I tried C2000WARE example usb_ex7_host_msc_cm (with usb_config_c28x running on CPU1), and although the application is running OK, I am unable to access a USB drive connected (with a USB A - micro USB adapter cable) to the micro USB interface on top if the Controlcard. On the UART terminal I keep getting error code FR_NOT_READY, so no device detected:

NODEV> ls
Command returned error code FR_NOT_READY

It looks like the USB drive is not getting powered at all. The same USB drive (with the same USB A - micro USB adapter cable)  is working fine when I connect it to a mobile phone.

The usb_ex1_device_serial_cm example which also uses the micro USB interface on top if the Controlcard is working fine, so it looks like the USB interface is OK.

Do I need to do any other initialization on CPU1, or maybe set different switches on the Controlcard to make the USB host example work?

Thanks and kind regards,
Arjan

  • Hi Arjan,

    What is the file system on the USB drive? The example only supports FATFS. Also , can you try running the "usb_ex7_host_msc.projectspec" on C28x to make sure that there is no problem with the USB drive itself.

    If other examples are running fine, then there maybe an issue with the USB drive itself or the file system on the drive?

    Best Regards

    Siddharth

  • Hi Siddharth,

    The file system on the USB drive is FAT32, and it works fine with my Windows laptop. I thought FatFS supported FAT32?

    I will try usb_ex7_host_msc on the C28 though.

    Thanks and kind regards,
    Arjan

  • Hi Siddarth,

    I tried to build usb_ex7_host_msc (F2838x C28 example), but I'm getting linker errors:

    <Linking>
    "../2838x_RAM_combined_lnk_cpu1.cmd", line 72: error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. run placement with alignment/blocking fails for section ".data" size 0x455page 0.  Available memory ranges:
       RAMLS56      size: 0x1000       unused: 0x0          max hole: 0x0       
       RAMGS101112   size: 0x3000       unused: 0xb          max hole: 0x9       
    error #10010: errors encountered during linking; "usb_ex7_host_msc.out" not built
     
    >> Compilation failure
    makefile:153: recipe for target 'usb_ex7_host_msc.out' failed
    gmake[1]: *** [usb_ex7_host_msc.out] Error 1
    makefile:149: recipe for target 'all' failed
    gmake: *** [all] Error 2
    
    **** Build Finished ****
    

    I didn't change anything after importing.

    I also noticed the FatFs version in C2000Ware is quite old, R0.04b from 2007. The latest one is R0.14 from 2019...

    Kind regards,
    Arjan

  • Hi Arjan,

    What is the C2000Ware version that you are using? Also , which build configuration of the example "usb_ex7_host_msc" (F2838x C28 example) did you try to compile?

    Yes, the FatFS version in C2000Ware is very old and needs to be updated. There is already a request raised for this and this may be addressed in a future release version of C2000Ware.

    Best Regards

    Siddharth

  • Hi Siddharth,

    I'm using C2000Ware 3.03.00.00, and I used the CPU1_RAM build config with the C28 example. Now I changed it to CPU1_FLASH and it builds and runs OK. When I insert the USB drive the terminal shows "Mass storage device connected.", and I can see the USB drive contents when I use the commands. So the hardware is OK.

    However the CM example still fails with "FR_NOT_READY" in the same setup with the same USB drive. I tried both CM_RAM and CM_FLASH configurations (and usb_config_c28x running on CPU1). And I did not change anything in the example's source code.

    Kind regards,
    Arjan

  • Hi Arjan,

    Can you single step through the code and figure out where the source of the issue is? .

    You can put a breakpoint at f_mount() and step through the code.

    Best Regards

    Siddharth

  • Hi Siddharth,

    I tried that, f_mount() returns FR_OK and after that the code ends up in the while loop of ReadLine(), with g_eState staying at STATE_NO_DEVICE. Is there anything in particular you would like me to look at?

    For some reason the callbacks ModeCallback() and MSCCallback() never get called.

    Do you have this hardware available on your side to test?

    Kind regards,
    Arjan

  • Hi Arjan,

    Unfortunately I don't have the hardware available to try it out here.  We are still working from home due to pandemic and I currently don't have a board available.

    I will try to get it and will let you know. I do remember that it was working fine . I had tested it before.

    Did you plug-in the USB drive once the code is running or it was already plugged-in?

    Best Regards

    Siddharth

  • Hi Siddharth,

    Sorry to hear about the hardware. Maybe one of your colleagues has access?

    I tried both: plugged in when starting, and plugging in after starting the program. Both not working.

    Also tried running from RAM and from flash, same result. And the board is powered with a 5V / 2A power supply so power should also not be the problem.

    To me it seems like some CM initialization is missing, causing USB interrupt not to occur. For example I see a call to Interrupt_registerHandler() for INT_USB0, but no call to Interrupt_enable(INT_USB0). Or is that done elsewhere?

    Kind regards,
    Arjan

  • Hi Arjan,

    Will try to get a hardware setup for it and check it out. Will keep you posted.

    Best Regards

    Siddharth

  • Hi Siddharth,

    Any luck with that hardware setup? I tried on a second F28388D controlcard I have here, but same result.

    I also noticed in project usb_config_c28x the CM system clock is set to 120MHz:

        // Set the CM Clock to run at 120MHz.
        // The CM Clock is a fractional multiple of the AUXPLL Clock (120 Mhz) from
        // which the USB Clock (60 MHz) is derived.
        //
        SysCtl_setCMClk(SYSCTL_CMCLKOUT_DIV_1, SYSCTL_SOURCE_AUXPLL);
    

    But in cm.h in project usb_ex7_host_msc_cm the clock frequency is defined as 125MHz:

    //*****************************************************************************
    //
    // Defines related to clock configuration. This frequency will be the CM clock
    // frequency driven by c28x.
    //
    //*****************************************************************************
    
    #define CM_CLK_FREQ       125000000U
    

    I'm not sure if that would affect USB interface behaviour. Should I change it to 120MHz and rebuild usblib_cm.lib and driverlib_cm.lib?

    Kind regards,
    Arjan

  • Hi Arjan,

     Sorry for the delay , we are working remotely and hence unable to get a hardware setup.

    The  auxiliary PLL is configured to 60 MHz and it is provided to the USB module. Hence I don't think the CM_CLK_FREQ should affect USB interface.

    Which revision of the Control card are you using? F2838x controlCARDs (Rev.B and later) have been updated to use 25MHz XTAL by default. If you have an older revision of the board, please add a predefined symbol "USE_20MHZ_XTAL" in your CCS project.

    Best Regards

    Siddharth

  • Hi Siddharth,

    I understand about the hardware setup in the current situation. But maybe some other forum members will come across this and test it on their hardware!

    The controlcards I'm using both have revision B (MCU063B), so the "USE_25MHZ_XTAL" definition is OK.

    The cause must be somewhere specifically in the host device settings for the CM, because the same example on CPU1 works fine, and so does the usb_ex1_device_serial_cm example on the CM.

    Kind regards,
    Arjan

  • Hi Arjan,

    Hope so, other forum members see this post and try it out. 

    We do have a remote setup with the Control Card, however we don't have a mass storage connected to it, hence cannot test it right now.

    Best Regards

    Siddharth

  • Hi Siddharth,

    I had left this issue alone for a few days, focused on other stuff. But I just had a fresh look at it, and I finally figured it out! Of course it's embarrassingly obvious once you see it...

    In usb_config_c28x (running on CPU1) the USB GPIOs are initialized, which is fine. And then also the External Power Signal Enable pin is set:

        //
        // Configure the External Power Signal Enable.
        //
        GPIO_setMasterCore(121, GPIO_CORE_CM);
    	GPIO_setDirectionMode(121, GPIO_DIR_MODE_OUT);
    	GPIO_writePin(121, 1);
    
    

    But of course after setting the pin's master core to CM, the CPU1 can no longer control that GPIO! So I moved 'GPIO_WritePin(121, 1)' to the usb_ex7_host_msc_cm code at the beginning of main(), and now it's working fine!

    I think in a next C2000Ware release the cm_common_config_c28x.c code should be updated: either move the GPIO_WritePin() call to the CM code like I did, or call it before setting master core of that pin to CM.

    Kind regards,
    Arjan

  • Hi Arjan,

    Thanks for figuring it out. Will update the code in the next release of C2000Ware.

    Best Regards

    Siddharth