ROM-Based USB HID changing sys clock to 48MHz?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ROM-Based USB HID changing sys clock to 48MHz?

337 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Mon Feb 15 14:39:11 MST 2010
I have been trying to debug a number of issues related to timing on the LPC1343 (specifically with SPI and UART), and the problem seems to occur after USB HID is initialised (following the examples from NXP). I'm running the system clock at 72MHz, but as soon as I init the rom-based USB I have the impression that the system clock is being dropped down to 48MHz, throwing off all the other peripherals that were configured for 72MHz. (I suspected this when my UART, set at 57600, worked fine before USB init but I had to drop it to 38400 after the init.  If I set the clock to 48MHz, though, instead of 72 and everything works fine).

Since I can't see any of the rom-based code, and the only oscillascope I have on hand is limited to 25MHz, I can't confirm if the system clock is indeed being set to 48MHz after USB is initialised ... perhaps someone from NXP can offer some insight into whether my suspicion is true or not? I definately wouldn't have expected that behaviour, though.  Are you oblidged to run the main clock at 48MHz if you want to use USB?

Original Attachment has been moved to: 1100119_LPC1100-FFT-Example.zip

0 Kudos
2 Replies

260 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Mon Feb 15 18:31:54 MST 2010
It seems there is actually a note in the UM that the system clock is set to 48MHz when you call "init_clk_pins", though it's not something I would have expected. If you want to run the system clock at a different speed (72MHz, for example), you'll need to manually configure the USB clock and setup the USB pins yourself ...  and DON'T call "(*rom)->pUSBD->init_clk_pins()". 

After several days pouring through the SPI code thinking the problems was there ... I definately wasn't expecting to find the culprit in the USB code, but perhaps this will help someone else having odd clock-related issues. :o  SPI is now happily running at 4MHz and my UART is finally behaving like it should.
0 Kudos

260 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ktownsend on Mon Feb 15 16:24:05 MST 2010
I just went through all the initialisation code again, comparing it line for line against the NXP examples as well as the UM, and I seem to be setting up the USB clock correctly (multiplier 4 using the external 12MHz crystal), and the system clock is set to 72MHz (multiplied 6, divider 1).  It runs fine at 72MHz until I call usb init, and the rom-based code is definately dropping the system clock down to 48MHz (messing up SPI, UART, etc.).  For the moment I've adjusted to code to run the system clock at 48MHz which solves the problem, but at the expense of losing 1/3 processing speed.  I'll likely have to implement a SW USB stack if there is no work around for this with the ROM drivers (which would be a shame since I'll lose a couple KBs flash as well).

Is this a bug in the rom-based code, though?  I was under the impression that the USB and sys clocks can be run at different speeds (by adjusting the multiplier/divider settings).
0 Kudos