LPC812-MAX, LPCOpen problem with 12MHz XTAL, could not get it working

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

LPC812-MAX, LPCOpen problem with 12MHz XTAL, could not get it working

960 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by riscy00 on Wed May 06 08:13:34 MST 2015
Hi

LPCxpresso 7.7.2 (most recent) along with most recent library (installed last week). I use LINK2 board on SWD port. The setup working fine with UART, Systick and blinker working (derived from LPCOpen)

I have LPC812-MAX and wish to use external crystal as clock source instead of IRC.

My attempt, was to first power up using IRC and then switch over to external XTAL (12Mhz). I use LPCOpen Chip_SetupXtalClocking(); but ended up crashes (no LED blinking and debug provide error).

I copied over some code from Chip_SetupXtalClocking() to my routine as shown below, it crashed only when statement is excuted Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_SYSOSC);

I power down and power up (without debug) and the LED is not blinking, so the clock failed to get thro the PPL block.

I have two possibility,
> The onboard XTAL did not tick (defective hardware)..I have not checked XTALOUT yet (I'm on vacation).
> Undocumented procedure how to do this correctly.

i forget to add, I have changed the jumper SJ2 and SJ3 to connect XTAL to LPC812 on MAX board.

I have followed the datasheet to configure the port correctly.

void SysClock_LPC812_Swicth_To_XTAL(void)
{
//------------------------------------------------Enable the clock to the Switch Matrix
    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
    Chip_SWM_EnableFixedPin(SWM_FIXED_XTALIN);
    Chip_SWM_EnableFixedPin(SWM_FIXED_XTALOUT);
//-----------------------------------------------Disable the clock to the Switch Matrix to save power
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
    /**
     * @briefSets pull-up or pull-down mode for a pin
     * @parampIOCON: The base of IOCON peripheral on the chip
     * @parampin: Pin number
     * @parammode: Mode (Pull-up/Pull-down mode)
     * @returnNothing
     * @noteDo not use with pins PIO10 and PIO11.
     */
    Chip_IOCON_PinSetMode(LPC_IOCON, IOCON_PIO8, PIN_MODE_INACTIVE);
    Chip_IOCON_PinSetMode(LPC_IOCON, IOCON_PIO9, PIN_MODE_INACTIVE);

//Code copied over from Chip_SetupXtalClocking(); to investigate source of crashes.

/* EXT oscillator < 15MHz */
Chip_Clock_SetPLLBypass(false, false);

/* Turn on the SYSOSC by clearing the power down bit */
Chip_SYSCTL_PowerUp(SYSCTL_SLPWAKE_SYSOSC_PD);

/* Select the PLL input to the external oscillator */
Chip_Clock_SetSystemPLLSource(SYSCTL_PLLCLKSRC_SYSOSC);

// PPL code to be included once above is fixed (will not crash). 
}


(1) Do you have example code that shown external clock is used.
(2) Is there other element missing from above code?


Labels (1)
0 Kudos
Reply
3 Replies

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpc_bloke on Wed Jul 29 01:10:19 MST 2015
This is all very well documented in chapter 4 of the user manual.

You will need to enable clock to IOCON and SWM.
Power up the crystal oscilator
wait a bit
set the PLL multiplier and dividers
Route the PLL clock input to the crystal OSC
Wait for the PLL to lock
Select the PLL output and the CPU clock
Correctly set up the AHB clock divisors

The function you are looking for was called SystemInit and it is usually called before main is called in the system startup code.

I currently run an LPC812 and 28MHz as I needed a specific divisor and this was the best clock frequency I found to meet my needs.

You could most likely get a 30MHz CPU clock from either 12MHz or 10MHz and the PLL and multiply and divide to suit you needs within the range documented in the user manual.

Good luck.
0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Tue Jul 28 22:55:54 MST 2015
Any ideas? I'm suffering from the same issue  :(( 

https://www.lpcware.com/content/forum/changing-main-frequency-clock
0 Kudos
Reply

668 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by riscy00 on Thu May 07 22:20:42 MST 2015
Bump, any helper?
0 Kudos
Reply