I'm adding a 12Mhz Xtal to my BB.
Reading the 1114 user guide it looks as if some registers (SYSOSCCTRL, SYSPLLCLKSEL, MAINCLKSEL, others?) may have to be updated to effect the switch from the RC osc to the Xtal - but it's really not very clear, to me anyway!
Can Coridium add details to the BB User Guide please?
Chris
Xtal on BasicBoard
Re: Xtal on BasicBoard
Here's my code to enable the BasicChip to use an external 12Mhz crystal.
The code is derived from the NXP startup code, and has several lines that are probably not required - but I've left them in anyway.
Code: Select all
'******************************************************************
' Derived from the Clock Start Up code in:
'
'* @file system_LPC11xx.c
'* @brief CMSIS Cortex-M0 Device Peripheral Access Layer Source File
'* for the NXP LPC11xx Device Series
'* @version V1.00
'* @date 17. November 2009
'
' This version uses ~470 bytes of code space, no data space.
' I suspect there are a number of lines here that are unnecessary!
'
' Chris Parker 11/28/12
'******************************************************************
#define SYSPLLCTRL *&H40048008 ' System PLL control (R/W)
#define SYSPLLSTAT *&H4004800C ' System PLL status (R/ )
#define SYSOSCCTRL *&H40048020 ' System oscillator control (R/W)
#define SYSPLLCLKSEL *&H40048040 ' System PLL clock source select (R/W)
#define SYSPLLCLKUEN *&H40048044 ' System PLL clock source update enable (R/W)
#define MAINCLKSEL *&H40048070 ' Main clock source select (R/W)
#define MAINCLKUEN *&H40048074 ' Main clock source update enable (R/W)
#define PDRUNCFG *&H40048238 ' Power-down configuration Register (R/W)
PDRUNCFG = PDRUNCFG AND NOT(1 << 5) ' Power-up System Osc - Clear bit5
SYSOSCCTRL = 0 ' Should not be needed, this is the default
TIMER=0
WHILE (TIMER < 10000) ' Give it 10 mS to stabilise
LOOP
MAINCLKSEL = 0 ' Select IRC as MainClk
MAINCLKUEN = 1 ' Update MCLK Clock Source
MAINCLKUEN = 0 ' Toggle Update Register
MAINCLKUEN = 1
WHILE (MAINCLKUEN = 0) ' Wait Until Updated
LOOP
SYSPLLCLKSEL = 1 ' Select SYSOSC as PLL Input
SYSPLLCLKUEN = 1 ' Update Clock Source
SYSPLLCLKUEN = 0 ' Toggle Update Register
SYSPLLCLKUEN = 1
WHILE (SYSPLLCLKUEN = 0) ' Wait Until Updated
LOOP
PDRUNCFG = PDRUNCFG OR (1 << 7) ' Power-down SYSPLL Set bit 7
SYSPLLCTRL = &H23 ' *** The BasicChip has this set incorrectly ***
PDRUNCFG = PDRUNCFG AND NOT (1 << 7) ' Power-up SYSPLL Clear bit7
WHILE (SYSPLLSTAT = 0) ' Wait Until PLL Locked
LOOP
MAINCLKSEL = 3 ' Select PLL Clock Output
MAINCLKUEN = 1 ' Update MCLK Clock Source
MAINCLKUEN = 0 ' Toggle Update Register
MAINCLKUEN = 1
WHILE (MAINCLKUEN = 0) ' Wait Until Updated
LOOP
' User program starts here
Re: Xtal on BasicBoard
Thanks for the code. Do you have to add 39 pF caps as in http://www.coridium.us/ARMhelp/index.ht ... rPins.html ?
Re: Xtal on BasicBoard
I added 22pF caps as spec'd 'somewhere' for the BasicChip/LPC1114.hyte wrote:Thanks for the code. Do you have to add 39 pF caps as in http://www.coridium.us/ARMhelp/index.ht ... rPins.html ?
Re: Xtal on BasicBoard
Ordered some parts after reading this (pdf) http://www.eetkorea.com/ARTICLES/2001SE ... AMD_AN.PDF and explained the things I was missing. Will report back if they work.