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.

USB inteface with tms320f28069

Other Parts Discussed in Thread: TMS320F28069, CONTROLSUITE

Hi,

     I want to use the USB interface in TMS320F28096.

     I am new to USB protocol. Can anybody give me the source code to interface pendrive to TMS320F28069? I want to read/write data from/to pendrive...

    Can anybody help me???? 

 

  • Hi Trupti,

    Make use of 'usb_host_msc' example code to design a driver for Pendrive <-> TMS320F28069 interface.

    Regards,

    Gautam

  • Hi Gautam,

        Thanks...I will go through it. But how i will cross verify the connection. In code they have mention to create virtual comm port...

        Can you please explain me in details how to create the setup for this i.e. with TMS320F28069 Devlopment board, pendrive and pc??? it will be helpfull for me to easily get the overall idea quickly...

  • Lets go step by step. Please use the same sample project and implement all the FAT commands because you'll be needing them while using a pendrive. Using UART you can execute these commands. 

    Also go through: http://elm-chan.org/fsw/ff/00index_e.html

    Regards,

    Gautam

  • Dear gautam,

         i have try to check the sample code given in controlsuite.... i have just downloaded that sorce file and check for data to come on hyper terminal. but i am didn't getting anything. please tell me how to check does the sample program is running or not??

     

  • H Trupti,

    Make use of a counter in midway(during UART reception probably) of the code and keep updating it. When you're in the debugging menu, add the count variable into watch window. While debugging (when you press the play button), this count variable should keep updating. This will ensure you whether the sample cod's working or no; in other words Sample codes always work, there might be some issue with the implementation.

    Regards,

    Gautam 

  • Hi gautam,

       Will this UARTprintf("Bad command!\n"); function or  UARTwrite("a", 1); print data on hyper terminal ??? I am just trying to check the serial communication in this sample code file. But i am getting garbage data on hyperterminal...

  • Can you paste your UART implementation?

    Regards,

    Gautam

  • Hi,

     i am using the same file i.e. usb_host_msc.c.......But i have commented usb part which is indicated in bold and checking for serial

    //*****************************************************************************
    //
    // This is the main loop that runs the application.
    //
    //*****************************************************************************
    int
    main(void)
    {
    int iStatus;

    //
    // Initially wait for device connection.
    //
    g_eState = STATE_NO_DEVICE;
    g_eUIState = STATE_NO_DEVICE;

    //
    // Set the clocking to run from the PLL at 60MHz.
    //
    SysCtrlInit();

    //
    // Initialize PIE and vector table
    InitPieCtrl();
    InitPieVectTable();

    //
    // Enable Clocking to the USB controller and
    // register interrupt handler
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    IntRegister(INT_USB0, f2806x_USB0HostIntHandler);

    //
    // Enable Host mode
    //
    EALLOW;
    *(unsigned long *)0x9B0 = 1;
    *(unsigned long *)0x441C = 0;
    EDIS;

    //
    // Enable the UART and setup GPIOs
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    EALLOW;
    GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;
    GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0;
    GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3;
    GpioCtrlRegs.GPADIR.bit.GPIO28 = 0;

    GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;
    GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO29 = 1;
    EDIS;

    UARTStdioInit(0);
    UARTprintf("\n\nUSB Mass Storage Host program\n");
    UARTprintf("Type \'help\' for help.\n\n");

    /*
    //
    // Enable Interrupts
    //
    IntMasterEnable();

    //
    // Enable the uDMA controller and set up the control table base.
    //
    //TODO: Add DMA support

    //
    // Initialize the USB stack mode and pass in a mode callback.
    //
    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.
    //
    //TODO: Add external power support

    //
    // Initialize the USB controller for OTG operation with a 2ms polling
    // rate.
    //
    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)
    {

    count++;
    if(count >=10000)
    count=0;
    // UARTprintf("Bad command!\n");

    UARTwrite("T\n\n", 3);

    // Get a line of text from the user.
    /* //
    ReadLine();
    if(g_cCmdBuf[0] == '\0')
    {
    continue;
    count1++;
    }

    //
    // 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");
    count2++;
    }

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

    //
    // 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));
    error_count++;
    }
    */
    }
    }

  • Ohhk  you're using the sample project itself. So no need to modify anything, let it be as it is. Connect the kit to the computer using RS-232 cable -> open the terminal -> Use these settings Baud rate: 115,200 bps, and 8-N-1 mode. When you run the program, you should be able to see a message on the hyperterminal. I guess you are acquainted to the post settings of hyperterminal like enabling echo... etc

    Regards,

    Gautam

  • Hey gautam,

           i am also not getting what is wrong.... I havn't  enable any echo in hyperterminal and also done the same baudrate settings..... i have done the same things that you have mentioned above regarding setup. But was unable to watch anything on hyperterminal...

          Do you have the same sample code which you have tested and working fine...can you mail me the same on t.golatkar@autodatatech.com...

         I have already tested the serial port it's working fine... But after downlaoding the sample code of misc i was not getting anything on hyperterminal...

  • Hi Trupti,

    I've attached the project: 

    4578.usb_host_msc.zip

    Here is the hyperterminal settings file:

    4846.SCI_96.zip

    Regards,

    Gautam

  • Dear Gautam,

        I had tried with your code..but not getting any thing on hyperterminal...

      So that i have check if the tms320f28069 supports 115200 baudrate or not. I have check with one of my  serial code for these baudrate. But till 38400 baudrate i was able  to see the normal communication but after that baudrate there was communication error. Using formula in pdf i have change the seeting of baudrate registers

    BRR  = ( LSPCLK /(SCI Asynchronous Baud  *8))− 1

      I have change the baud rate 115200 to 9600 to see will it now working or not but still no datat on hyperterminal but on terminal v1.9b i was getting garbage data..

    plz guide...

  • Hi Trupti,

    As SCI communication is our issue right now, please try implementing SCI based example code for F28069. 

    Regards,

    Gautam

  • Hey gautam,

     I have checked with sci_echoback folder till 115200 baudrate...

    And it's working fine...

    Kindly inform me the next testing procedure

  • Are you able to see the transmitted data on hyperterminal without any errors?

  • here i am attching what i am getting on hyperterminal when i have downloaded sci_echoback example5074.Presentation1.ppt

  • Wonderful.... but its very very strange. Please check the configuration settings of uart ie uartstdio.c file. 

    I'm too checking the same.

    Regards,

    Gautam

  •  hey gautam,

    When i am passing baud rate to below function it was not giving me the output on hyperterminal... 

    UARTConfigSetExpClk(g_ulBase, SysCtlClockGet()/4, ulBaud,
    (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
    UART_CONFIG_WLEN_8));

    so that i have directly pass the value to following register then i can see data on hypertreminal... Till this point i have just check serial comm. Now i am moving to usb par


    SciaRegs.SCIHBAUD =0x0000; // 115200 baud @LSPCLK = 20MHz (80 MHz SYSCLK).
    SciaRegs.SCILBAUD =0x0014;

    I dpn't know why the above function is not working...

  • Hey Gautam,

       Thanks for the co-ordination n your valuable supports...Sample code is working fine... :)

  • What was the issue?

  • Hey Gautam,

    In uartstdio.c file there is a function implemented as follow

    UARTConfigSetExpClk(g_ulBase, SysCtlClockGet()/4 ulBaud,
    (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
    UART_CONFIG_WLEN_8));

    As i was not sure about the baud rate i have checked the serial sample code in that they have mention LSPCLK as 20M. But when i see the above function SysCtlClockGet() is returning 60M. So the value is getting pass to further calculation was 15M. So i have just change SysCtlClockGet()/4 to SysCtlClockGet() / 3 ...so that instead of 15M i am getting 20M...After that i can see the data om hyperterminal.

    Dear Gautam can you let me know on which factor this 15M OR 20M frequency gets decided????

  • Good to hear that you were able to find the error. LSPCLK is indirectly dependent on SYSCLK ie the actual controller clock frequency.

    Regards,

    Gautam

  • Hey gautam ,

       last one now i want to interface pendrive... To interface it i have to use fatfs command,ri8???

  • Yup, now you'll have to be thorough with the FAT based command set.

    Go through the site mentioned: http://elm-chan.org/fsw/ff/00index_e.html

    Regards,

    Gautam

  • Hi gautam,

      i have made the connection as per below. Are they ri8? plz see the file

    7824.Presentation1.ppt

  • Yes, connection's fine.

    -------------------------------------

    Hi,

    Here's an interview by TI for my contributions towards the community E2E.

    http://e2e.ti.com/group/helpcentral/b/weblog/archive/2013/08/07/meet-the-ti-e2e-community-gautam-g-iyer.aspx

    Regards,

    Gautam

  • Hi Trupti,
    It's looks like you are using all the functions: UARTStdioInit(), UARTPrintf().... that I used when I was working with other processor and compiler.
    Are using them in CCS environment ? did you modify them to work with the TMS320f28069?
    I am using now the TMS320f28069 and trying to communicate with PC or terminal.
    Your help will be appreciated
    Hamid