SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By id___
#134453
Hello,
I am using LPC1754 for my current project.
By the following function I am trying to initialize the USB host controller, i.e. after its execution I expect to see with an oscilloscope SOF impulses generated every 1ms on D+ (D-), but this does not happen. Why?
Code: Select all
void USB_Host_Init (void)
{
LPC_SC->PCONP |= (1 << 31); //PCUSB = 1 enable USB host

LPC_SC->PLL1CFG = 0x23; // M=4 12MHz(crystal)*4=48; P=2 CCO=2*M*P*Fosc=2*4*2*12=192MHz
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;
LPC_SC->PLL1CON = 0x01; // PLL1 Enable
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;
while (!(LPC_SC->PLL1STAT & (1<<10)));// Wait for PLOCK1
LPC_SC->PLL1CON = 0x03; // PLL1 Enable & Connect
LPC_SC->PLL1FEED = 0xAA;
LPC_SC->PLL1FEED = 0x55;

LPC_USB->USBClkCtrl = 0x0000001F; /* Enable USB host clock */
while ((LPC_USB->USBClkSt & 0x0000001F) != 0x1F);

/* P1[18] = USB_UP_LED, 01 */
/* P1[19] = /USB_PPWR, 10 */
/* P1[22] = USB_PWRD, 10 */
/* P1[27] = /USB_OVRCR, 10 */
LPC_PINCON->PINSEL3 &= ~((3<<4) | (3<<6) | (3<<12) | (3<<22));
LPC_PINCON->PINSEL3 |= ((1<<4)|(2<<6) | (2<<12) | (2<<22)); // 0x00802080
//Pin has neither pull-up nor pull-down resistor enabled.
LPC_PINCON->PINMODE3 &= ~((3<<4) | (3<<6) | (3<<12) | (3<<22));
LPC_PINCON->PINMODE3 |= ((2<<4)|(2<<6) | (2<<12) | (2<<22));
/* P0[29] = USB_D+, 01 */
/* P0[30] = USB_D-, 01 */
LPC_PINCON->PINSEL1 &= ~((3<<26) | (3<<28));
LPC_PINCON->PINSEL1 |= ((1<<26)|(1<<28)); // 0x14000000
//Pin has neither pull-up nor pull-down resistor enabled.
LPC_PINCON->PINMODE1 &= ~((3<<26) | (3<<28));
LPC_PINCON->PINMODE1 |= ((2<<26)|(2<<28));

LPC_USB->HcControl |= (1 << 7);
}
Thank you!