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.

Need Help OMAP L138 USB OTG in Host Mode

Other Parts Discussed in Thread: CCSTUDIO, OMAPL138

Hi, I have some questions about configuration USB OTG controller on EVM  OMAP L138

Sample code I use refer  SPRUFM9D  :

1) file main.c

#include "stdio.h"

#include "types.h"

#include "evmomapl138.h"

#include "evmomapl138_timer.h"

#include "usb_reg_test.h"

#include "evmomapl138_usb.h"

///////////////////////////////////////////////////////////////////

int main(void)

{

//             uint16_t                 I;

//             uint32_t results = 0;

 

                #if NO_GEL

   EVMOMAPL138_init();

   EVMOMAPL138_initRAM();

   #endif     

 

    USTIMER_init();

    USB_OTG_init_forum();

//---------------------------------------------------------------------

printf("STATR = 0x%X\r\n",USB_OTG->STATR);

printf("CTRLR = 0x%X\r\n",USB_OTG->CTRLR);

printf("CFGCHIP[2] = 0x%X\r\n",SYSCONFIG->CFGCHIP[2]);

printf("INTSRCR = 0x%X\r\n",USB_OTG->INTSRCR);

printf("INTSETR = 0x%X\r\n",USB_OTG->INTSETR);

printf("INTCLRR = 0x%X\r\n",USB_OTG->INTCLRR);

printf("EOIR = 0x%X\r\n",USB_OTG->EOIR);

printf("FADDR = 0x%X\r\n",USB_OTG->FADDR);

printf("POWER = 0x%X\r\n",USB_OTG->POWER);

printf("INTRTX = 0x%X\r\n",USB_OTG->INTRTX);

printf("INTRRX = 0x%X\r\n",USB_OTG->INTRRX);

printf("INTRTXE = 0x%X\r\n",USB_OTG->INTRTXE);

printf("INTRRXE = 0x%X\r\n",USB_OTG->INTRRXE);

printf("INTRUSB = 0x%X\r\n",USB_OTG->INTRUSB);

printf("INDEX = 0x%X\r\n",USB_OTG->INDEX);

printf("HOST_CSR0 = 0x%X\r\n",USB_OTG->HOST_CSR0);

printf("COUNT0 = 0x%X\r\n",USB_OTG->COUNT0);

printf("HOST_TYPE0 = 0x%X\r\n",USB_OTG->HOST_TYPE0);

printf("HOST_NAKLIMIT0 = 0x%X\r\n",USB_OTG->HOST_NAKLIMIT0);

printf("CONFIGDATA = 0x%X\r\n",USB_OTG->CONFIGDATA);

printf("DEVCTL = 0x%X\r\n",USB_OTG->DEVCTL);

 

  USB_OTG_SETUP();

 

 

return(0);

               

}

USB initialization procedure:

//-----------------------------------------------------------------------------

// \file    test_usb.c

// \brief   simple reading registers

//

//-----------------------------------------------------------------------------

#include "stdio.h"

#include "types.h"

#include "evmomapl138.h"

#include "evmomapl138_timer.h"

//#include "usb_reg_test.h"

#include "evmomapl138_usb.h"

///////////////////////////////////////////////////////////////////////////////////////

void USB_OTG_init_forum()

{

                uint16_t I;

    // Config BootREGS

                SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;

                SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;

                //Config PINMUX

    SYSCONFIG->PINMUX[9] |= 0x010;

                SYSCONFIG->PINMUX[9] &= 0xFFFFFF7F ;

                // Reset the USB controller:

                USB_OTG->CTRLR |= 0x00000001;

                //Wait until controller is finished with Reset. When done, it will clear the RESET bit field.

                while ((USB_OTG->CTRLR & 0x1) == 1);

                // RESET: Hold PHY in Reset

                SYSCONFIG->CFGCHIP[2] |= 0x00008000; // Hold PHY in Reset

                // Drive Reset for few clock cycles

                for (I=0; I < 50; I++);

                // RESET: Release PHY from Reset

                SYSCONFIG->CFGCHIP[2] &= 0xFFFF7FFF; // Release PHY from Reset

                /* Configure PHY with the Desired Operation */

                // OTGMODE

                SYSCONFIG->CFGCHIP[2] &= 0xFFFF9FFF; // 00= > Do Not Override PHY Values

                //SYSCONFIG->CFGCHIP[2] |= 0x00002000; // 11= > Override PHY Values, force host, VBUS low

                // PHYPWDN

                SYSCONFIG->CFGCHIP[2] &= 0xFFFFFBFF; // 1/0 = > PowerdDown/ NormalOperation

                // OTGPWRDN

                SYSCONFIG->CFGCHIP[2] &= 0xFFFFFDFF; // 1/0 = > PowerDown/ NormalOperation

                // DATAPOL

                SYSCONFIG->CFGCHIP[2] |= 0x00000100; // 1/0 = > Normal/ Reversed

                // SESNDEN

                SYSCONFIG->CFGCHIP[2] |= 0x00000020; // 1/0 = > NormalOperation/ SessionEnd

                // VBDTCTEN

                SYSCONFIG->CFGCHIP[2] |= 0x00000010; // 1/0 = > VBUS Comparator Enable/ Disable

                /* Configure PHY PLL use and Select Source */

                // REF_FREQ[3:0]

                SYSCONFIG->CFGCHIP[2] |= 0x00000002; // 0010b = > 24MHz Input Source

    // USB2PHYCLKMUX: Select External Source

                SYSCONFIG->CFGCHIP[2] &= 0xFFFFF7FF; // 1/0 = > Internal/External(Pin)

                // PHY_PLLON: On Simulation PHY PLL is OFF

                SYSCONFIG->CFGCHIP[2] |= 0x00000040; // 1/0 = > On/ Off

                // Wait Until PHY Clock is Good //

                while ((SYSCONFIG->CFGCHIP[2] & 0x00020000) == 0);

 

                #ifndef HS_ENABLE

                // Disable high-speed

                USB_OTG->POWER &= ~USB_OTG_POWER_HSEN;

                #else

                // Enable high-speed

                USB_OTG->POWER |= USB_OTG_POWER_HSEN;

 

                #endif

               

                // Enable Interrupts

                // Enable interrupts in OTG block

                USB_OTG->CTRLR &= 0xFFFFFFF7; // Enable PDR2.0 Interrupt

                USB_OTG->INTRTXE = 0x1F; // Enable All Core Tx Endpoints Interrupts + EP0 Tx/Rx interrupt

                USB_OTG->INTRRXE = 0x1E; // Enable All Core Rx Endpoints Interrupts

               

                // Enable all interrupts in OTG block

                USB_OTG->INTMSKSETR = 0x01FF1E1F;

               

                // Enable all USB interrupts in MUSBMHDRC

                USB_OTG->INTRUSBE = 0xFF;

               

                // Enable SUSPENDM so that suspend can be seen UTMI signal

                USB_OTG->POWER |= USB_OTG_POWER_ENSUSPM;

               

                //Clear all pending interrupts

                USB_OTG->INTCLRR = USB_OTG->INTSRCR;

 

                //Set softconn bit

    USB_OTG->POWER |= USB_OTG_POWER_SOFTCONN;

//             while (( USB_OTG->DEVCTL & 0x01) == 0);

 

 

                // Start a session                        

                USB_OTG->DEVCTL |= USB_OTG_DEVCTL_SESSION;

                                               USTIMER_init();

 

                USB_OTG->POWER |=  0x20; // set bit5 - "1"

                USB_OTG->POWER |=  0x08;  //set bit3 - "1"

                for (I=0; I<50; I++);

//    set delay 20ms

                USTIMER_delay(500000);

                USB_OTG->POWER &= 0xF7;                    

          

 }                                        

 

void USB_OTG_SETUP()

{

 printf("_____________________\n");

 

 USB_OTG->INTCLRR &= 0xffffffff;

 printf("INTCLRR = 0x%X\r\n",USB_OTG->INTCLRR);

 

 USB_OTG->FIFO0 = 0x030500 ;//DATA

 

 USB_OTG->HOST_CSR0 |= 0x0A;/// SETUPPKT and TXPKTRDY

 printf("HOST_CSR0 = 0x%X\r\n",USB_OTG->HOST_CSR0);

 

 USTIMER_delay(500000);

 printf("INTSRCR = 0x%X\r\n",USB_OTG->INTSRCR);

 printf("INTCLRR = 0x%X\r\n",USB_OTG->INTCLRR);

 

 if ((USB_OTG->HOST_CSR0 & 0x04)== 0x04 )// RXSTALL

 {

  printf("RXSTALL = 0x%X\r\n",USB_OTG->HOST_CSR0);

  }

 else

 {

   printf("RXSTALL_OK = 0x%X\r\n",USB_OTG->HOST_CSR0);

 }

 

  if ((USB_OTG->HOST_CSR0 & 0x0010)== 0x0010 )// ERROR

  {

   printf("ERROR = 0x%X\r\n",USB_OTG->HOST_CSR0);

  }

   else

   {

    printf("ERRROR_OK = 0x%X\r\n",USB_OTG->HOST_CSR0); 

 

   }

   if ((USB_OTG->HOST_CSR0 & 0x080)== 0x080 )// NAK_TIMEOUT

   {

    printf("NAK_TIMEOUT = 0x%X\r\n",USB_OTG->HOST_CSR0);

   

    }

   else

   {

    printf("NAK_TIMEOUT_OK = 0x%X\r\n",USB_OTG->HOST_CSR0);    

   }  

}

 

////////////////////////////////////////////////////////////////////////////////

 

And now I have some questions

  1. Where can I find  PINMUX settings USB OTG (in my sample code I use PINMUX from OMAP L137 example)
  2. Registers values after run this programm:

STATR=0x01

INTSRCR=0x1100000

INTSETR=0x1100000

INTCLRR=0x1100000

EOIR=0

FADDR=0

POWER=0x61

INDEX=0

DEVCTRL=0x5D

CTRL=0x0

CFGCHIP2=0x301F2

USB_ID pin is LOW

After doing init USB I try to start Control Transfer and receive Standart Device Descriptor

Load 8 bytes in EP0 FIFO and set  SETUPPKT and TXPKTRDY, and then EP0 Interrupt...But I did not receive ANY INTERRUPT AT ALL!

АБСОЛЮТНО НИЧЕГО НЕ ПРОИСХОДИТ!НИКАКИХ ПРЕРЫВАНИЙ НЕ ВОЗНИКАЕТ!

That should I do?There is my mistake?

Best regard,Anton

 

  • Anton,

    USB driver is available on both DSP and ARM end for L137/37 platforms.  Can you not re-use the same for your product?

    regards

    swami

  • Hi swami

    First of all, I want to say you that I do my first steps working with such complex feature processor

    And I first open the box with EVM board and use CD with install of CCStudio and EVM Drivers and BSL

     Thats all, now I did not use any more Driver. So I don't cleary understand your question.

     If any mory Drivers I need for my product, please tell my about, maybe some links will be useful for me

       With best wishes

    Anton

  • Anton,

    The EVM kit would have documentation providing the link to the Software and Tools location.  You can also locate the same by entering OMAPL138 name in the search at www.ti.com.

    In any case pl. find below the link to the associated software and tools for OMAPL138 platform in the link below

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/omap_l138/1_00/latest/index_FDS.html

    Can you provide more information on your product requirements and how USB fits in those requirements?  Do you want to use both DSP and ARM ? Any specific OS or no OS needs in the product?

    regards

    swami

  • Swami,

    As I can understand for my work with this board I need download more software:

    OMAP_L138_dsp_setupwin32_1_00_00_08.exe

    BIOSUSB Driver

    TI_CGT_C6000_6.1.9_setup.exe

    In general, my main aim - create an USB OTG HOST for work with Mass Storage Devices in High Speed Mode, so I think I only need to use USB OTG Controller as part of OMAP

     For this purposes I buy EVM board.

    My steps to rich this aim:

    1. Initialize USB OTG in High Speed Host Mode

    2. Make a Control Transfer to get Descriptors and Statuses of different High Speed Mass Storage Devices

    3. Make a non-DMA Bulk Transfer

    As I can read in docs, I need only DSP part of OMAP

    Now I have Windows PC connected to EVM board  through cable in box and emul tool

    Using J6 on board USB OTG connector I use Micro-A plug to standard A receptacle and connect HS Flash Drive

    Then I create sample code initializing USB OTG in HOST mode in CCstudio3.3 and load it into memory of OMAP,and run application I posted upper

    And did not receive any Interrupt at all.

    And now I try to solve this problem:)

    regards

    Anton

     

  • Anton,

    You would need to install BIOSUSB package and the dependant packages.  Pl. refer to the BIOSUSB user guide for more details on the package versions and download the same from the link that I shared with you earlier.

    Pl. follow the instructions in the user guide of BIOSUSB to compile and run the Host MSC sample application.  If you have done the steps that re mentioned in the user guide for MSS Host applications then you should be able to work with a connected USB Stick/HDD automatically.

    BIOSUSB package has support for Host MSC application by default and that is what I feel you are needing based on your latest update. 

    regards

    swami

  • Swami

    Thank you very much!

     I will try this soft and post about my results

    regards

    Anton