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

RL ARM - USB HOST Memory stick not recognized - LPC4078

Hi,
I encounter a problem since 3 days with the RL- USB Host application.
I try to acces to a memory stick through the USB PORT1 from the RDB4078 board (LPC4078 processor)

I modified the code from Keil\ARM\Boards\Keil\MCB1700\RL\USB\Host\MSD_File to adapt it for the LPC4078

In the asm startup file (system_lpc407x_8x_177x_8x.s) I use 0x800 bytes for the Stack and for the Heap.
In the C startup file (system_lpc407x_8x_177x_8x.s) I use the main oscillator (with a 12MHz crystal), the PLL0 multiplier value is 10 and the divider value 1 (the PLL0 output is 120MHz)
The PLL1 multiplier is 4 and the PLL1 divider is 2, the PLL1 output is (48MHz)
The USB clock is derived from the PLL1 and the divider value is 1 (=48MHz)

From usb_config.c, I use USB HOST 0 on OHCI mode and the class configuration is MSC
From usbh_ohci_lpc177x_8x.c, the USB base address is 0x2008C000 (datasheet), the Root hub port is 1 (Port 1), the start address for USB data is 0x20000000 (peripheral SRAM)

My pins config function is :

BOOL usbh_ohci_hw_pins_config (BOOL on) {

  if (on) {
    /* Set pin functions                                                      */
    LPC_IOCON->P0_29 = 1;               /* USB_D+1                            */
    LPC_IOCON->P0_30 = 1;               /* USB_D-1                            */

    LPC_IOCON->P1_18 = 1;               /* USB_UP_LED1                        */
    LPC_IOCON->P1_19 = 2;               /* !USB_PPWR1                         */
    LPC_IOCON->P1_22 = 2;               /* USB_PWRD1                          */
    LPC_IOCON->P1_27 = 2;               /* !USB_OVRCR1                        */


  } else {
    /* Reset pin functions                                                    */

    LPC_IOCON->P1_18 = 0x30;
    LPC_IOCON->P1_19 = 0x30;
    LPC_IOCON->P1_22 = 0x30;
    LPC_IOCON->P1_27 = 0x30;
    LPC_IOCON->P0_29 = 0;
    LPC_IOCON->P0_30 = 0;
  }

  return (__TRUE);
}

My USB init function is :

BOOL usbh_ohci_hw_init (BOOL on) {
  S32 tout;

  if (on) {
    usbh_ohci_hw_delay_ms (10);         /* Calibrate delay                    */

    /* Initialize memory pool for data                                        */
    if (!usbh_mem_init(0, (U32 *)&usbh_ohci_mpool, sizeof(usbh_ohci_mpool)))
      return (__FALSE);

    LPC_SC->PCONP       |=  (1UL << 31);/* Enable USB interface power/clock   */
    LPC_USB->OTGClkCtrl |=  0x19;       /* Enable Host, OTG, AHB mster clk    */

    tout = 10100;
    while (!((LPC_USB->OTGClkSt & 0x19) == 0x19)) {   /* Wait clock enable    */
      if (tout-- <= 100) {
        if (tout == 0)
          return (__FALSE);
        usbh_ohci_hw_delay_ms (10);                   /* Wait ~10 ms          */
      }
    }

    LPC_USB->StCtrl   =  0x03;          /* U1 = HOST            */

    NVIC_SetPriority (USB_IRQn, 0);     /* Set USB interrupt highest priority */
  } else {
                LPC_USB->StCtrl     &= ~0x03;       /* Deselect port function             */

    LPC_USB->OTGClkCtrl &= ~0x19;       /* Disable Host,OTG, AHB mster clk*/

   for (tout = 100; ; tout--) {
      if ((LPC_USB->OTGClkSt & 0x19) == 0)/* Wait for clocks disabled         */
        break;
      if (!tout)
        return (__FALSE);
    }

    LPC_SC->PCONP       &= ~(1UL << 31);/* Disable USB interface power/clock  */
  }

  return (__TRUE);
}

Where the host, OTG and AHB clock are enabled (by LPC_USB->OTGClkCtrl |= 0x19;) and USB1 is a host without using OTG (LPC_USB->StCtrl = 0x03;)

Finnally, my main program is something like this :

int main(void){
        BOOL reslt;

        result = usbh_init(0);
        while(1){

                usbh_engine(0);
                reslt = usbh_msc_status(0, 0);
                //(...)

        }
}

the usbh_init(0); always returns true (as expected), and the usbh_msc_status(0, 0); always returns false (msc init failed) ..

What did I miss ?
Thank you.