LPC11 SystemInit() clock switching query

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

LPC11 SystemInit() clock switching query

241 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by push2eject on Wed Jul 18 03:18:45 MST 2012
Hi all, my first post here :-)

I have a couple of questions, both related to SystemInit() in system_LPC11xx.c, which appears to have been written by ARM.

1. When switching clock sources, the xUEN bit is written 1 then 0 then 1. My understanding from the LPC11Cxx User Manual is that it is only necessary to write 0 then 1. Why the preceeding write to 1 in the start-up code?

2. After writing xUEN to 1,0,1; there is a loop waiting for the xUEN bit to be set. But this bit was just set as described above. Nowhere in the User Manual or datasheet can I find anything about having to wait for this bit to become set (unlike the PLL lock status).

Am I missing something important about changing clock sources?
Or is the ARM startup code a bit crufty?

Thanks,
Kevin.
0 Kudos
1 Reply

220 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by push2eject on Sat Aug 04 16:26:17 MST 2012
I received feedback on this from NXP via my FAE. The initial writes to '1' (lines marked A below) are not really needed, they were just 'making sure', but the wait loops (lines marked B) are required to ensure a fast running CPU doesn't get ahead of the SYSCON hardware.


[FONT=Courier New][/FONT]*** IN FILE system_LPC11xx.c ***
void SystemInit (void)
{
[...]
  LPC_SYSCON->PDRUNCFG     &= ~(1 << 5);
  LPC_SYSCON->SYSOSCCTRL    = SYSOSCCTRL_Val;
  for (i = 0; i < 200; i++) __NOP();
  LPC_SYSCON->SYSPLLCLKSEL  = SYSPLLCLKSEL_Val;
  LPC_SYSCON->SYSPLLCLKUEN  = 0x01;             // A
  LPC_SYSCON->SYSPLLCLKUEN  = 0x00;
  LPC_SYSCON->SYSPLLCLKUEN  = 0x01;
  while (!(LPC_SYSCON->SYSPLLCLKUEN & 0x01));   // B
[...]
  LPC_SYSCON->MAINCLKSEL    = MAINCLKSEL_Val;
  LPC_SYSCON->MAINCLKUEN    = 0x01;             // A
  LPC_SYSCON->MAINCLKUEN    = 0x00;
  LPC_SYSCON->MAINCLKUEN    = 0x01;
  while (!(LPC_SYSCON->MAINCLKUEN & 0x01));     // B
[...]
}[/FONT]
0 Kudos