LPC1114 clock questions

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

LPC1114 clock questions

1,246 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ultrabit on Tue Nov 15 10:23:24 MST 2011
Hi all.
I have the following code snippet:
void clockOutInit(void) {
    unsigned int i;

    LPC_SYSCON->SYSAHBCLKCTRL = (0xFFFFFFFF & (~(1<<15))); //enable all clocks except the WDT

    LPC_SYSCON->PDRUNCFG &= ~(1<<5) ;    /* Enable System Oscillator  */
    for (i = 0; i != 24000; i++);               // wait for it to stabilize

    //LPC_SYSCON->SYSOSCCTRL = 1; // bypass PLL

    LPC_SYSCON->SYSPLLCLKSEL = 0x01;            // System PLL source is the system oscillator
    LPC_SYSCON->SYSPLLCLKUEN = 0x00;            // Update the system PLL source...
    LPC_SYSCON->SYSPLLCLKUEN = 0x01;            //...
    while (!(LPC_SYSCON->SYSPLLCLKUEN & 0x01));   /* Wait Until Updated       */

    LPC_SYSCON->MAINCLKSEL = 0x01;
    LPC_SYSCON->MAINCLKUEN = 0x00;
    LPC_SYSCON->MAINCLKUEN = 0x01;
    while (!(LPC_SYSCON->MAINCLKUEN & 0x01));   /* Wait Until Updated       */

    //LPC_SYSCON->PDRUNCFG |= (1<<1);
    LPC_IOCON->PIO0_1 = 0xc1;                    /* CLKOUT Function selected */
    LPC_SYSCON->CLKOUTCLKSEL = 0x1;                /* System Osc. Clock selected */
    LPC_SYSCON->CLKOUTDIV = 0x02;                /* divided by 2 */
    LPC_SYSCON->CLKOUTUEN = 0x00;
    LPC_SYSCON->CLKOUTUEN = 0x01;
    while (!(LPC_SYSCON->CLKOUTUEN & 0x01));    /* Wait Until Updated       */
}
This code works (loaded on a lpc1114 lpcxpreso board)  as is and my oscilloscope show a clock signal of about 6Mhz at the CLKOUT pin.

1) Is it possible to disable IRC clock using PDRUNCFG register (i.e. disabling IRC_PD and/or IRCOUT_PD)  ? When i try to do this i have no signal on my oscilloscope !
2) how does the "LPC_SYSCON->SYSOSCCTRL = 1;"  work ? When i try to do this i have no signal on my oscilloscope !
3)  Can i ask to the NXP boys to write a better (deeper) user guide ?


Thanks,
ub
0 Kudos
Reply
2 Replies

915 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by steven_ece on Tue May 15 15:51:41 MST 2012
There may be other devices on the chip that need to be reconfigured for the new clock source. For example the USB device on reset runs from the IRC source.

EDIT: I fixed this by powering down the IRC after switching the clock out select to main oscillator. The moral of the story is that funny things happen when parts of the chip have no clock source. There is no need to mess with the USB PLL because it is powered down at reset.

EDIT: If the PLL is not powered it seems that the PLL input clock will show up on the output.

Here is what I did to achieve a 12MHz clock
uint32_t i; 

// Power on PLL
LPC_SYSCON->PDRUNCFG &= ~(0x01<<7);

/* Power on system oscillator */
LPC_SYSCON->PDRUNCFG &= ~(1<<5);
for(i = 0; i < 30000; i++); /* Wait for oscillatopr to stabalize */

/* Configure PLL */
LPC_SYSCON->SYSPLLCTRL = (0x03<<5); /*M = 1, P = 2^3, Fclkout = 12MHz */;
/* Select PLL Source */
LPC_SYSCON->SYSPLLCLKSEL = 0x01; /* Use system oscillator (crystal) */;
/* Update clock source of the PLL */
LPC_SYSCON->SYSPLLCLKUEN = 0x00;
while(LPC_SYSCON->SYSPLLCLKUEN & 0x01); /* Wait for update */
LPC_SYSCON->SYSPLLCLKUEN = 0x01;
while(!(LPC_SYSCON->SYSPLLCLKUEN & 0x01)); /* Wait for update */

/* Select main clock source */
LPC_SYSCON->MAINCLKSEL = 0x03;
/* Update main clock source */
LPC_SYSCON->MAINCLKUEN = 0x00;
while(LPC_SYSCON->MAINCLKUEN); /* Wait for update */
LPC_SYSCON->MAINCLKUEN = 0x01;
while(!(LPC_SYSCON->MAINCLKUEN)); /* Wait for update */

        /* Output clock to io pin */
        LPC_IOCON->PIO0_1 = 0x01; /* Enable clock out function on pin0_1 */
        LPC_SYSCON->CLKOUTSEL = 0x03; /* Main oscillator frequency */
        LPC_SYSCON->CLKOUTDIV = 24; /* Divide by 24 */
        LPC_SYSCON->CLKOUTUEN = 0x00;
        while(LPC_SYSCON->CLKOUTUEN & 0x01); /* Wait for update */
        LPC_SYSCON->CLKOUTUEN = 0x01;
        while(!(LPC_SYSCON->CLKOUTUEN & 0x01)); /* Wait for update */

        /* Power down internal oscillator */
LPC_SYSCON->PDRUNCFG |= 0x01;                      
        LPC_SYSCON->PDRUNCFG |= (0x01<<1);
0 Kudos
Reply

915 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Wed Nov 16 09:20:10 MST 2011

Quote: ultrabit
1) Is it possible to disable IRC clock using PDRUNCFG register (i.e. disabling IRC_PD and/or IRCOUT_PD)  ? When i try to do this i have no signal on my oscilloscope !
ub



Hello

So far, I haven't studied the clock options for this micro, but I know one thing: the IRC is the first clock source for the chip after applying power, so before you disable it, or changing to other clock source (crystal, watchdog), that other clock source must be already initialized; otherwise you'll end with no clock source at all.
0 Kudos
Reply