I'm exploring my first arm device the lpc1343, I'm using VIM and ARM GCC, I have managed to light an LED but to blink it, I will need to startup the clock and pll, right now I can't find the right sequence for this in the user manual.
Where can I find the basic startup sequence for clock and PLL for lpc1343 ?
So far I came up with the following not working sequence :
void InitSys (void) {
InitCpu();
InitPorts();
}
void InitCpu (void) {
PDRUNCFG |= 0x00000020; // SYSOSC_PD = 1 -> System oscillator Powered Down
SYSOSCCTRL = 0x00000000; // Oscillator is not bypassed, 1 - 20 MHz frequency range
PDRUNCFG &= ~0x00000020; // SYSOSC_PD = 0 -> System oscillator is Powered
InitPLL();
SYSAHBCLKDIV |= 0x00000001; // System Clock Divide by 1
MAINCLKUEN &= ~0x00000001; // No change
MAINCLKSEL = 0x00000003; // Main clock source select register -> System PLL clock out
MAINCLKUEN |= 0x00000001; // Update clock source
}
void InitPLL (void) {
PDRUNCFG |= 0x00000080; // Set SYSPLL_PD
SYSPLLCLKUEN &= ~0x00000001; // No change
SYSPLLCLKSEL = 0x00000001; // System oscillator
SYSPLLCLKUEN |= 0x00000001; // Update clock source
SYSPLLCTRL = 0x00000025; // FCLKOUT = 72 MHz /// M div = 6 / P div = 2
PDRUNCFG &= ~0x00000080; // Set SYSPLL_PD
while(!(SYSPLLSTAT & 0x000000001)){} //If 1 -> PLL locked
}
Best Answer
You don't need to do anything to start the clock, and it's not necessary to start the PLL in order to blink an LED. By default the processor wakes up running at 12 MHz, using the internal RC clock directly. As long as that's a fast enough clock for your purposes you don't need to do anything else.
The manufacturer (NXP) is not at all vague about starting the clock and PLL. There is C code to do this in the
system_LPC13xx.c
file that comes with their examples (at least with the LPCxpresso examples). The clock is configured in theSystemInit()
function.Update: If you are using the
lpcopen
package, look forclock_13xx.c