LPCXpresso LPC824

07 Mar 2016

Search system clock setup of LPCXpresso Board LPC824, my conclusion it is 10 MHz. (12 MHz x 5) / 3 = 20 20 / 2 = 10 MHz

My question: May I change this clock value without block board ?

07 Mar 2016


The clock configuration code for the LPCXpresso824-MAX is here: https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC82X/TARGET_LPC824/system_LPC8xx.c


MAIN_CLOCK = SYS_PLLCLKOUT = 12000000 * ((0x24 & 0x1F) + 1) = 60MHz SYSAHBCLKDIV_Val = 2


You can also refer the system clock by SystemCoreClock global variable such as:

printf("system clock = %d\n", SystemCoreClock);

07 Mar 2016

You can change the values of the PLL and other dividers as long as you stay within the limits given in the datasheet. F_clkin must be in the range of 10 MHz to 25 MHz F_CCO must be in the range of 156 MHz to 320 MHz

However, your conclusion above is not correct. The default setting is to select the internal RC oscillator (instead of the external crystal). The IRC is running at (approximately) 12 MHz. The PLL will increase that to F_CCO = 12 * M * 2P = 240 MHz. The FCLKOUT = F_CCO / 2P = 60MHz.

SYSPLLCTRL_Val = 0x00000024, which means that MSEL=4 and P=2

M = MSEL+1 = 4 + 1 = 5

2P = 2*2 = 4

SYSAHBCLKDIV_Val = 0x00000002, which means that the 60MHz FCLKOUT is divided by 2 and defines the SystemCoreClock at 30 MHz.

08 Mar 2016

All right. In my tests with clock decrease, found that WAIT function is clock dependent. Same proportion I think.

Clock 30 MHz: wait (1) 1 s delay

Clock 1 MHz (SYSAHBCLKDIV = 60 ) : wait (1/30) 1 s delay

08 Mar 2016

Then someone didn't make nice code most likely and used hardcoded values inside the mbed source code.

However first: How did you change the clock? If you changes it in the cmsis system.c files: Make sure you also change the SystemCoreClock default. If you changed it inside your main.cpp, make sure you call the SystemCoreClockUpdate function (or whatever it is called) after changing clock settings, and make sure you have not used any timer function, or even initliazed a Timer, before you change the clock, since it will set those values only once.

08 Mar 2016

Nice. Where is documented all functions like SystemCoreClockUpdate() ?

09 Mar 2016

Here: http://www.keil.com/pack/doc/cmsis/Core/html/group__system__init__gr.html, they are supposed to be provided by manufacturers, so they should always be available.