LCP1114F/302 Without External Oscillator

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

LCP1114F/302 Without External Oscillator

846 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Thu Mar 05 13:35:23 MST 2015
Hello,

I can not use the micro without external oscillator.
I configure the micro with IRC oscillator and I can see the CLKOUT pin to 12MHZ but I have the oscillator in the board.

When I remove the oscillator the micro doesn't work.
Following the instructions, the configuration to use the IRC is easier than configure the PLL...
Labels (1)
0 Kudos
15 Replies

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Mar 08 09:55:52 MST 2015

Quote: brattchess

- Which toolchain are you using?
I don't like putting a lot of files without sense.
I am using the lcexpresso

- Where does this toolchain setup your system?
I only include LCP11x.h

- Which code is executed before you reach main?
I don't execute any code before main().



Are you kidding me?

Where's your main function call?

No cr_startup_lpc11xx.c  :quest:  :exmark:  :~
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Sun Mar 08 09:24:14 MST 2015
Hello,

- Which toolchain are you using?
I don't like putting a lot of files without sense.
I am using the lcexpresso

- Where does this toolchain setup your system?
I only include LCP11x.h

- Which code is executed before you reach main?
I don't execute any code before main().
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Mar 08 06:27:50 MST 2015

Quote: brattchess

My main function is that:..



:quest:

I this a language problem?

I've seen that already  :exmark:

I can't help you if you don't follow my hints  |(

- Which toolchain are you using?

- Where does this toolchain setup your system?

- Which code is executed before you reach main?






0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Sun Mar 08 05:30:39 MST 2015
Hello,

My main function is that:

LPC_SYSCON->SYSAHBCLKCTRL = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<16);
LPC_SYSCON->SYSOSCCTRL = 0x00;//No Bypass; 1-20Mhz Range
//MAINCLOCK
LPC_SYSCON->MAINCLKSEL = 0x00; // 0x0: IRC oscillator|0x1:Input clock to system PLL|0x3:System PLL clock out
LPC_SYSCON->MAINCLKUEN = 0x01; // Update MCLK Clock Source
LPC_SYSCON->MAINCLKUEN = 0x00; // Toggle Update Register
LPC_SYSCON->MAINCLKUEN = 0x01;
while (!(LPC_SYSCON->MAINCLKUEN & 0x01)); // Wait Until Updated

LPC_SYSCON->CLKOUTCLKSEL = 0x03; // 0:IRC oscillator|0x1:System oscillator|0x3:Main clock
LPC_SYSCON->CLKOUTUEN = 0x01; // Update clock
LPC_SYSCON->CLKOUTUEN = 0x00; // Toggle update register once
LPC_SYSCON->CLKOUTUEN = 0x01;
while ( !(LPC_SYSCON->CLKOUTUEN & 0x01) ); // Wait until updated
LPC_SYSCON->CLKOUTDIV = 1; // Divided by 1

LPC_IOCON->PIO0_1 &= ~0x07;
LPC_IOCON->PIO0_1 |= 0x01;
LPC_GPIO0->DIR |= (1<<1); //set pin direction to output (sec 12.3.2)

while(1);


Where I can modify the register??
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun Mar 08 05:08:33 MST 2015

Quote: brattchess
Why has the PDRUNCFG the value 0x50? I don't active the PLL Block neither System Oscillator.
I don't understand it. Could be affect that I am using debbuger?



Is 0x50 the default value? No  :exmark:

So your code is changing it  :O

Look in your toolchain ( :quest: ) System Init functions...
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Sun Mar 08 04:06:13 MST 2015
Hello,

I check debugging that I don't powered the System osc and the register indicates that it was running.
So I reset this block and it stops all the micro, having the block of IRC osc activated.


LPC_SYSCON->SYSAHBCLKCTRL = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<16);
LPC_SYSCON->SYSOSCCTRL = 0x00;//No Bypass; 1-20Mhz Range
//MAINCLOCK
LPC_SYSCON->MAINCLKSEL    = 0x00;      // 0x0: IRC oscillator|0x1:Input clock to system PLL|0x3:System PLL clock out
LPC_SYSCON->MAINCLKUEN    = 0x01;                       // Update MCLK Clock Source
LPC_SYSCON->MAINCLKUEN    = 0x00;                       // Toggle Update Register
LPC_SYSCON->MAINCLKUEN    = 0x01;
while (!(LPC_SYSCON->MAINCLKUEN & 0x01));          // Wait Until Updated



LPC_SYSCON->CLKOUTCLKSEL = 0x03; // 0:IRC oscillator|0x1:System oscillator|0x3:Main clock
LPC_SYSCON->CLKOUTUEN = 0x01; // Update clock
LPC_SYSCON->CLKOUTUEN = 0x00; // Toggle update register once
LPC_SYSCON->CLKOUTUEN = 0x01;
while ( !(LPC_SYSCON->CLKOUTUEN & 0x01) ); // Wait until updated
LPC_SYSCON->CLKOUTDIV = 1; // Divided by 1


LPC_IOCON->PIO0_1 &= ~0x07;
LPC_IOCON->PIO0_1 |= 0x01;
LPC_GPIO0->DIR              |= (1<<1);     //set pin direction to output (sec 12.3.2)


while(1);



Why has the PDRUNCFG the value 0x50? I don't active the PLL Block neither System Oscillator.
I don't understand it. Could be affect that I am using debbuger?
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat Mar 07 06:56:13 MST 2015
User Manual 10398:


Quote:

3.4 Clock generation
....
The LPC111x/LPC11Cxx include[color=#f00] three independent oscillators. These are the system oscillator, the Internal RC oscillator (IRC), and the watchdog oscillator[/color]. Each oscillator can be used for more than one purpose as required in a particular application.
...
Following reset, the LPC111x/LPC11Cxx will operate from the Internal RC oscillator until switched by software. This allows systems to operate without any external crystal and the bootloader code to operate at a known frequency



Datasheet:


Quote:
When the system oscillator is not used, connect XTALIN and XTALOUT as follows: XTALIN can be left floating or can be grounded (grounding is preferred to reduce susceptibility to noise). XTALOUT should be left floating.



So system oscillator is whatever you connect to XTALIN / XTALOUT: usually a (12MHz) crystal  :O
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Sat Mar 07 06:09:52 MST 2015
Hello,

Yes I am using the system oscillator but which is it?
The external or the IRC oscillator?
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sat Mar 07 03:02:09 MST 2015

Quote: brattchess
I check that if I power down the system oscillator the micro doesn't work.



Then you are obviously using the system oscillator as clock source...
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Sat Mar 07 01:40:01 MST 2015
Hello,

I check that if I power down the system oscillator the micro doesn't work.
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Mar 06 07:45:39 MST 2015
And why are you enabling System Oscillator (and waiting until it's ready) if you don't use it  :quest:


Quote: brattchess

[color=#f00]//Enable system oscillator and go into a little dummy delay[/color]
LPC_SYSCON->SYSOSCCTRL = 0x00;//No Bypass; 1-20Mhz Range
LPC_SYSCON->PDRUNCFG &= ~(0x1<<5);//Enable Sys oscillator
for (counter = 0; counter < 200; counter++) __NOP();//Dummy wait for the system osc


0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Fri Mar 06 07:31:19 MST 2015
Hello,

I will use this code to configure IRC as main source clock:

uint32_t counter = 0;
//Enable AHB/APB bridge; ROM; RAM; FLASHREG; FLASHARRAY; GPIO; IOCON
LPC_SYSCON->SYSAHBCLKCTRL = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<16);


//Enable system oscillator and go into a little dummy delay
LPC_SYSCON->SYSOSCCTRL = 0x00;//No Bypass; 1-20Mhz Range
LPC_SYSCON->PDRUNCFG &= ~(0x1<<5);//Enable Sys oscillator
for (counter = 0; counter < 200; counter++) __NOP();//Dummy wait for the system osc

//MAINCLOCK
LPC_SYSCON->MAINCLKSEL    = 0x00;      // 0x0: IRC oscillator|0x1:Input clock to system PLL|0x3:System PLL clock out
LPC_SYSCON->MAINCLKUEN    = 0x01;               // Update MCLK Clock Source
LPC_SYSCON->MAINCLKUEN    = 0x00;               // Toggle Update Register
LPC_SYSCON->MAINCLKUEN    = 0x01;
while (!(LPC_SYSCON->MAINCLKUEN & 0x01));       // Wait Until Updated
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Mar 06 06:39:49 MST 2015

Quote: brattchess
Can I use it to stop system oscillator and to force to use IRC oscillator?

LPC_SYSCON->PDRUNCFG |= (0x1<<5);//Disable Sys oscillator



:D

If you power down Sys Oscillator (and it's your PLL source) you just force your code to fail   :((

You have to switch IRC as PLL source manually...
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brattchess on Fri Mar 06 05:29:25 MST 2015
Hello,

Can I use it to stop system oscillator and to force to use IRC oscillator?

LPC_SYSCON->PDRUNCFG |= (0x1<<5);//Disable Sys oscillator
0 Kudos

795 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu Mar 05 14:09:42 MST 2015

Quote: brattchess
I can not use the micro without external oscillator.



:quest:

Then look in your toolchain ( :quest: ) and change setup settings there...

LPCOpen is doing that in board layer file board_sysinit.c:


/* Setup system clocking */
STATIC void SystemSetupClocking(void)
{
volatile int i;

/* Powerup main oscillator */
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSOSC_PD);

/* Wait 200us for OSC to be stablized, no status
   indication, dummy wait. */
for (i = 0; i < 0x100; i++) {}

/* Set system PLL input to main oscillator */
Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);

/* Power down PLL to change the PLL divider ratio */
Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_SYSPLL_PD);

/* Setup PLL for main oscillator rate (FCLKIN = 12MHz) * 4 = 48MHz
   MSEL = 3 (this is pre-decremented), PSEL = 1 (for P = 2)
   FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 4 = 48MHz
   FCCO = FCLKOUT * 2 * P = 48MHz * 2 * 2 = 192MHz (within FCCO range) */
Chip_Clock_SetupSystemPLL(3, 1);

/* Powerup system PLL */
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SYSPLL_PD);

/* Wait for PLL to lock */
while (!Chip_Clock_IsSystemPLLLocked()) {}

/* Set system clock divider to 1 */
Chip_Clock_SetSysClockDiv(1);

/* Setup FLASH access to 3 clocks */
Chip_FMC_SetFLASHAccess(FLASHTIM_50MHZ_CPU);

/* Set main clock source to the system PLL. This will drive 48MHz
   for the main clock and 48MHz for the system clock */
Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_PLLOUT);
}

0 Kudos