This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1768 and LPC1788 USB Differences

Hi all,

My USB Host Driver working fine with LPC1768 for USB HID Devices.
But I want to use this driver with LPC1788(On Embedded Artist Board) its doesnt work.
LPC1788 works fine with USB Host Lite sample.
And I use this sammple's Hardware init function but my driver didnt work.

I have a Hardware Init block.
It looks like :


#if IC == 1788

#define USBControlReg                           (LPC_USB->Control)
#define USBOTGStatusControlReg                  (LPC_USB->StCtrl)
#define USBInterruptStatusReg                   (LPC_USB->InterruptStatus)
#define USBControlHeadEDReg                     (LPC_USB->ControlHeadED)
#define USBBulkHeadEDReg                        (LPC_USB->BulkHeadED)
#define USBCommandStatusReg                     (LPC_USB->CommandStatus)
#define USBFMIntervalReg                        (LPC_USB->FmInterval)
#define USBPeriodicStartReg                     (LPC_USB->PeriodicStart)
#define USBRhStatusReg                          (LPC_USB->RhStatus)
#define USBHCCAReg                              (LPC_USB->HCCA)
#define USBInterruptEnableReg                   (LPC_USB->InterruptEnable)
#define USBRhPortStatus1Reg                     (LPC_USB->RhPortStatus1)

#elif (IC == 1768)

#define USBControlReg                           (LPC_USB->HcControl)
#define USBOTGStatusControlReg                  (LPC_USB->OTGStCtrl)
#define USBInterruptStatusReg                   (LPC_USB->HcInterruptStatus)
#define USBControlHeadEDReg                     (LPC_USB->HcControlHeadED)
#define USBBulkHeadEDReg                        (LPC_USB->HcBulkHeadED)
#define USBCommandStatusReg                     (LPC_USB->HcCommandStatus)
#define USBFMIntervalReg                        (LPC_USB->HcFmInterval)
#define USBPeriodicStartReg                     (LPC_USB->HcPeriodicStart)
#define USBRhStatusReg                          (LPC_USB->HcRhStatus)
#define USBHCCAReg                              (LPC_USB->HcHCCA)
#define USBInterruptEnableReg                   (LPC_USB->HcInterruptEnable)
#define USBRhPortStatus1Reg                     (LPC_USB->HcRhPortStatus1)

#else
#error "Undefined IC"
#endif
PRIVATE void hwInit(HCCA *cca)
{
  NVIC_DisableIRQ(USB_IRQn);

  // turn on power for USB
  CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCUSB, ENABLE);

  // Enable USB host clock, port selection and AHB clock
  USBClockControlReg |= CLOCK_MASK;

  // Wait for clocks to become available
  while ((USBClockStatusReg & CLOCK_MASK) != CLOCK_MASK);

  //  We are a Host
  USBOTGStatusControlReg |= 1;

  configuratePins();

  //  Reset OHCI block
  USBControlReg = 0;
  USBControlHeadEDReg = 0;
  USBBulkHeadEDReg = 0;

  USBCommandStatusReg = HostControllerReset;
  USBFMIntervalReg = DEFAULT_FMINTERVAL;
  USBPeriodicStartReg = FRAMEINTERVAL * 90 / 100;

  USBControlReg = (USBControlReg & (~HostControllerFunctionalState)) | OperationalMask;
  USBRhStatusReg = SetGlobalPower;

  USBHCCAReg = (U32)cca;
  USBInterruptStatusReg |= USBInterruptStatusReg;
  USBInterruptEnableReg = MasterInterruptEnable |
                          WritebackDoneHead     |
                          RootHubStatusChange   |
                          FrameNumberOverflow;

  NVIC_SetPriority(USB_IRQn, 0);
  NVIC_EnableIRQ(USB_IRQn);

  // 10ms delay before diving in
  hostDelayMS(10);
}

There is All hardware dependent code.
But system not work same with LPC1768 and LPC1788.

Is there any difference between LPC1768 and LPC1788 USB unit?

Thanks.

Parents
  • > LPC1788 works fine with USB Host Lite sample.

    The target device of USBHostLite_LPC17xx is LPC1768 on Keil MCB1760 board. As this example works on LPC1788, just by changing the target device, it suggests that there isn't any difference around the USB host engine on these devices.

    Sound like your firmware doesn't reflect board circuit difference enough.
    - Is the crystal frequency the same?
    - How about USB_PPWR(P1.19) and USB_OVRCR(P1.27) setting?

    Tsuneo

Reply
  • > LPC1788 works fine with USB Host Lite sample.

    The target device of USBHostLite_LPC17xx is LPC1768 on Keil MCB1760 board. As this example works on LPC1788, just by changing the target device, it suggests that there isn't any difference around the USB host engine on these devices.

    Sound like your firmware doesn't reflect board circuit difference enough.
    - Is the crystal frequency the same?
    - How about USB_PPWR(P1.19) and USB_OVRCR(P1.27) setting?

    Tsuneo

Children
  • Hi Tsuneo,

    LPC1768 working on Landtiger Demo board.
    LPC1788 working on Embedded Artist board.

    - Is the crystal frequency the same? which crystal value do you want to know? USB Units does not need a crystal. Main Crystals are 12 MHz for both of two ICs.

    - How about USB_PPWR(P1.19) and USB_OVRCR(P1.27) setting? I use onlt USB1 D+, USB1 D- And PPWR pins. I didnt use USB_OVRCR pin. LPC1768 working without OVRCR. And is it neccasary?

    Thanks.

    Murat.

  • > USB Units does not need a crystal. Main Crystals are 12 MHz for both of two ICs.

    USB engine (both of host and device) requires a crystal to satisfy USB spec.
    MCB1760 mounts a 12MHz crystal. Embedded Artist LPC1788 Dev Kit, too.
    In SystemInit() (system_LPC17xx.c), USBHostLite_LPC17xx waits for main OSC stabilization, and it sets up PLL1 for USB
    Does your firmware have this code?

    Tsuneo

  • Ah, I remember.
    For LPC178x, OTGStCtrl.PORT_FUNC has changed to assign the function of two USB ports, device or host.

    Tsuneo

  • Hi Tsuneo,

    I call SystemInit() function at the beginning of my code.
    And additional, I call SystemCoreClockUpdate().

    Is it a timing/clocking problem?

    I have used FRAMEINTERVAL value as (25000 - 1) and (12000 - 1) but result is same.

    LPC_USB->HcFmInterval = DEFAULT_FMINTERVAL;
    LPC_USB->HcPeriodicStart= FRAMEINTERVAL * 90 / 100;
    

    What are the correct values for HID Host?
    I couldnt find neccesary info in Datasheet.

    Thanks.

    Murat.

  • And Additional,

    My Driver waiting for WriteBackDoneHead Interrupt.
    But interrupt never occured :(

  • > I have used FRAMEINTERVAL value as (25000 - 1) and (12000 - 1) but result is same.
    > What are the correct values for HID Host?

    "HID Host" doesn't need any specific FRAMEINTERVAL value. It's common to host implementation. Apply the value defined in USBHostLite as is.

    > I couldnt find neccesary info in Datasheet

    It's because the host engine is based on OHCI spec.
    See OHCI spec for the details.

    OHCI, UHCI and EHCI spec link on USB.org
    www.usb.org/.../

    Sound like you are playing on the host engine without understanding OHCI spec. Fortunately, you have an example, USBHostLite, which works on the EA board. Realize every line of the example (usbhost_lpc17xx.c), first. And then, customize it as you like.

    Tsuneo

  • I couldnt find neccesary info in Datasheet about FRAMEINTERVAL.

    My Basic problem is :

    When a HID Device connected,
    I can sense HubStatus Changing and Device Connecting.
    After that, I want to add device.
    So first of all, I request Device Descriptor(8 Byte).
    While requesting Device Descriptor, I am sending a SETUP TOKEN.
    But I cant receive WritebackDoneHead.

    All of them working fine on LPC1768. So I think I have mistake with LPC1788 hardware initialization. I apply all USBHostLite hardware init code to my firmware with neccesary modifies but result is same.

    There is a same problem but it not resolved :(
    www.embeddedrelated.com/.../53982.php

    If you want, I can send all of my driver code to you.
    I'm about to go crazy.

    Murat.

  • > I can sense HubStatus Changing and Device Connecting.
    After that, I want to add device.
    So first of all, I request Device Descriptor(8 Byte).

    How about bus reset?
    The first thing to do after detecting connection is, bus reset.
    Until bus reset finishes, the root hub doesn't connect the bus segment.
    Around the bus reset, follow the timing specified in the USB2.0 spec.

    USB 2.0 Connect Timing ECN.pdf (distributed in USB2.0 spec zip)
    delta-t4(Tcon_rst) - 100ms minimum before bus reset
    delta-t6(Trstrcy) - 10 ms minimum after bus reset

    USB2.0 spec
    www.usb.org/.../usb_20_101111.zip

    Tsuneo

  • Hi Tsuneo,

    Thanks for your interest.
    There is 100 ms waiting before and after bus reset when device connected.

    Additional since tomorrow I trying to apply NXP's nxpUSBLib.

    www.lpcware.com/.../nxpusblib

    In package there are some examples(HID Host) for LPC1768 and I have tried, its working.
    And I have changed "only" register names for converting 1768 project to LPC1788 project.
    Because they are defined different in lpc17xx.h and lpc177x_8x.h

    Example :

    LPC1768
    ----------------------------
    LPCUSB->HcControl
    LPCUSB->HcInterruptStatus

    LPC1788
    ----------------------
    LPCUSB->Control
    LPCUSB->InterruptStatus

    But result is same. After sending setup token, Writebackdonehead interrupt never occured.

    Is there any "extra" modification between LPC1768 and LPC1788.
    Are you develop any Host HID application on LPC1788 or anyone?

    Thanks.

  • USB device/host uses dedicated RAM for DMA

    1.2 Features (UM10360-LPC17xx User manual, UM10470-LPC178x/7x User manual)
    Up to two 16 kB SRAM blocks with separate access paths for higher throughput.
    These SRAM blocks may be used for Ethernet, USB, LCD, and DMA memory, as
    well as for general purpose instruction and data storage.

    This peripheral RAM locates,
    LPC1768: 0x2008 0000 - 0x2008 3FFF
    LPC1788: 0x2000 4000 - 0x2000 7FFF

    Then, this macro should be modified for LPC1788

    usbhost_lpc17xx.h
    #define HOST_BASE_ADDR          0x20080000  // <--- 0x20004000
    

    Tsuneo