How to change sample code from usb1 to usb2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to change sample code from usb1 to usb2

988 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mehdi.smh24 on Mon Jan 12 10:02:43 MST 2015
Hi

I use LPC1788 and I want to run USB_Host example (IAR Systems\Embedded Workbench 6.4 Evaluation\arm\examples\NXP\LPC17xx\IAR-LPC-1788-SK\USB_Host)
But my board is not a development one and Its USB inteface is connected to usb2 pins but the example is for USB1.
I changed two lines of Host_Init as below:
 while ((OTGCLKST & 0x00000001) == 0) {
    }
    
    OTGSTCTRL = 0x00000003;               //usb port sel , changed from 1 to 3 for usb2                    /**/
                                   
    IOCON_P0_31 = 0x1;                    // changed 29(D+1) to 31(D+2)        /* P0[31] = USB_D+2                         */
                                                              
    IOCON_P1_30 = 0x1A1;                          /* P1[30] = USB_PWRD2                       */
    IOCON_P1_31 = 0x1A1;                          /* P1[31] = USB_OVRCR2                      */
    IOCON_P0_12 = 0x1A1;                          /* P0[12] = USB_PPWR2                       */


but I still have problems in Host_EnumDev :
USB_INT32S  Host_EnumDev (void)
{
    USB_INT32S  rc;


    PRINT_Log("Connect a Mass Storage device\n\r");
    while (!HOST_RhscIntr);

it stays in while statement
I think USB_IRQHandler doesnt call properly and i need more changes in code because of hardware differnce but i confused ...
please let me know if hardware schematic helps
Thanks
Labels (1)
0 Kudos
Reply
1 Reply

924 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Tue Jan 20 05:34:07 MST 2015

Quote:
OTGSTCTRL = 0x00000003;   //usb port sel , changed from 1 to 3 for usb2  /**/


OTGSTCTRL &= ~(0x00000001 << 1);  // drop the bit 1, to assign USB2 port to host

OTGSTCTRL.PORT_FUNC = 3 means U1 = host, U2 = device

Tsuneo
0 Kudos
Reply