EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

LPC2648 USB Host enumeration problem

Started by KrUtsav 7 years ago97 views
Trying to enumerate USB Host using NXP's USBHostLite using LPC2468 controller. It stuck at "while (!HOST_RhscIntr);"

Below is my Host_init function.

void Host_Init (void)
{
USB_INT32U pinsel;
USB_INT32U pinmode;
uint32_t HostBaseAddr;


PCONP |= 0x80000000;
VICIntEnClr = (1 << 22); /* Enable the USB interrupt source */

OTG_CLK_CTRL = 0x0000001F; /* Enable USB host clock */

while ((OTG_CLK_STAT & 0x0000001F) != 0x1F);

OTG_STAT_CTRL = 0x3;
/* P0[12] = USB_PPWR2 01 */
pinsel = PINSEL0;
pinsel &= 0xFCFFFFFF;
pinsel |= 0x01000000;
PINSEL0 = pinsel;
/* P0[31] = USB_D+2 */
pinsel = PINSEL1;
pinsel &= 0x3FFFFFFF;
pinsel |= 0x40000000;
PINSEL1 = pinsel;
/* P1[30] = USB_PWRD2 01 */
/* P1[31] = USB_OVRCR2 01 */
pinsel = PINSEL3;
pinsel &= 0x0FFFFFFF;
pinsel |= 0x50000000;
PINSEL3 = pinsel;

/* Set up host base address and TD and ED descriptors */
HostBaseAddr = 0x7FD00000;

Hcca = (volatile HCCA *)(HostBaseAddr+0x000);
TDHead = (volatile HCTD *)(HostBaseAddr+0x100);
TDTail = (volatile HCTD *)(HostBaseAddr+0x110);
EDCtrl = (volatile HCED *)(HostBaseAddr+0x120);
EDBulkIn = (volatile HCED *)(HostBaseAddr+0x130);
EDBulkOut = (volatile HCED *)(HostBaseAddr+0x140);
TDBuffer = (volatile uint8_t *)(HostBaseAddr+0x150);
FATBuffer = (volatile uint8_t *)(HostBaseAddr+0x1D0);
UserBuffer = (volatile uint8_t *)(HostBaseAddr+0x1000);


/* Initialize all the TDs, EDs and HCCA to 0 */
Host_EDInit(EDCtrl);
Host_EDInit(EDBulkIn);
Host_EDInit(EDBulkOut);
Host_TDInit(TDHead);
Host_TDInit(TDTail);
Host_HCCAInit(Hcca);


Host_DelayMS(50); /* Wait 50 ms before apply reset */
HcControl = 0; /* HARDWARE RESET */
HcControlHeadED = 0; /* Initialize Control list head to Zero */
HcBulkHeadED = 0; /* Initialize Bulk list head to Zero */

/* SOFTWARE RESET */
HcCommandStatus = OR_CMD_STATUS_HCR;
HcFmInterval = DEFAULT_FMINTERVAL; /* Write Fm Interval and Largest Data Packet Counter */

/* Put HC in operational state */
HcControl = (HcControl & (~OR_CONTROL_HCFS)) | OR_CONTROL_HC_OPER;
HcRhStatus = OR_RH_STATUS_LPSC; /* Set Global Power */

HcHCCA = (USB_INT32U)Hcca;
HcInterruptStatus |= HcInterruptStatus; /* Clear Interrrupt Status */
/* Enable interrupts */
HcInterruptEnable = OR_INTR_ENABLE_MIE |
OR_INTR_ENABLE_WDH |
OR_INTR_ENABLE_RHSC;

// Update USB Interrupt address in Vectored Interrupt Controller
VICIntSelect &= ~(1 << 22); /* Configure the ISR handler */
VICVectAddr22 = (USB_INT32U)Host_Isr; /* Set the vector address */
VICIntEnable = (1 << 22); /* Enable the USB interrupt source */
}

With this code snippet, it is not hitting the ISR itself. If OTG_STAT_CTRL = 0x3; is removed from the above function, it used to enter the ISR but "HOST_RhscIntr" is not getting set.

Notes:
1. Not sure about value of "HostBaseAddr "(I copied this piece of code from NXP USBhostlite example for 2478)
2. Configuring U2 pins and checking the status of "HcRhPortStatus2" in ISR.

Please provide your suggestions about what am doing wrong.

The 2024 Embedded Online Conference