Content originally posted in LPCWare by Dave on Sun Aug 07 22:04:00 MST 2011
Here's another one to be aware of (I haven't contacted NXP to let them know):
File is SYSTEM_LPC177X_8X.C, line 406 reads as follows:
<code>
if(LPC_SC->CLKSRCSEL & 0x01)//pll1_clk_in = main_osc
USBClock = (OSC_CLK * ((LPC_SC->PLL1STAT & 0x1F) + 1));
else //pll1_clk_in = irc_clk
USBClock = (IRC_OSC * ((LPC_SC->PLL0STAT & 0x1F) + 1));
</code>
I believe it should be as follows:
<code>
USBClock = (OSC_CLK * ((LPC_SC->PLL1STAT & 0x1F) + 1)) / __USB_DIV;
else //pll1_clk_in = irc_clk
USBClock = (IRC_OSC * ((LPC_SC->PLL0STAT & 0x1F) + 1)) / __USB_DIV;
</code>
where __USB_DIV is defined as follows (up around line 284):
<code>
#define __USB_DIV (USBCLKSEL_Val & 0x1F)
</code>
Hope this helps,