0
\$\begingroup\$

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
}
\$\endgroup\$
  • \$\begingroup\$ Doesn't the manufacturer provide the CMSIS framework? You'll have an easier time if you use it. \$\endgroup\$ – Scott Seidman Apr 7 '14 at 15:33
  • \$\begingroup\$ The manufacturer is pretty vague about it, and has loads of examples always attatched to something more, i have a hard time learning if you throw to much stuff at me at the same time. Im just looking for a basic step by step, turno on the register, load this register with xxxxx, and so on and so on. \$\endgroup\$ – Electropepper Apr 7 '14 at 15:46
  • \$\begingroup\$ It took me enought just to get the linkerscript and vector table to work, i dont want to use another one now. \$\endgroup\$ – Electropepper Apr 7 '14 at 15:48
  • \$\begingroup\$ My limited experience w/ ARM Cortex is that the CMSIS framework is the way to go. "load this register, load that register, load the next register,..." WILL drive you crazy. \$\endgroup\$ – Scott Seidman Apr 7 '14 at 16:15
  • \$\begingroup\$ I believe i found it in NXP website under the name, NXP LPC Cortex-M3 IEC60335 Class B library, i still believe its vague or at least not very obvious, there is to many scatered information and no obvious answer, like maybe, default template libraries from scratch, or something, forgive me if im too basic. \$\endgroup\$ – Electropepper Apr 9 '14 at 14:04
2
\$\begingroup\$

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 the SystemInit() function.

Update: If you are using the lpcopen package, look for clock_13xx.c

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.