NOTICE: This website will be shut down in the near future. Product content has moved to Forum content and FAQs have been moved to We encourage you to create a user account on to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.


SystemClockUpdate() - Function

3 replies [Last post]
Joined: 2011-06-29
Posts: 7

I have one question regarding the "SystemClockUpdate" function in main. This function updates the "SystemFrequency" global variable. But I cannot see use of this variable in the project itself.

Can you please explain what is the use of this function if "SystemFrequency" variable is not used or it used in some libraries ?

Your rating: None

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-12-02
Posts: 643

Hello sherrysamuel,

which LPCXpresso board are you using?

- NXP European team -

- NXP European team -

Joined: 2010-01-26
Posts: 685

The variable SystemCoreClock gives you the value of the system core clock (CCLK) and it can be used by your routines to calculate system timing.

As an example, look at the UARTinit() function used in a number of the example projects delivered with the LPCXpresso tools.
In there you'll see the following code:

    LPC_UART1->LCR = 0x83;             /* 8 bits, no Parity, 1 Stop bit */

    Fdiv = ((SystemFrequency/4)/16)/baudrate ;    /*baud rate */

    LPC_UART1->DLM = Fdiv / 256;
    LPC_UART1->DLL = Fdiv % 256;
    LPC_UART1->LCR = 0x03;        /* DLAB = 0 */
    LPC_UART1->FCR = 0x07;        /* Enable and reset TX and RX FIFO. */
(SystemFrequency is a #define of SystemCoreClock on top of the uart.c file).

This shows how the SystemCoreClock variable is used to calculate the baudrate.
SystemCoreClock is set during SystemInit() but if you change the clock (e.g. reprogram the PLL or select a different clock source) then calling the SystemCoreClockUpdate() function will calculate the new CCLK frequency.

Use of the SystemCoreClock variable depends on your project and which files you have in the project. The uart example code uses it and also the FreeRTOS project uses this to calculate the correct timing for the system tick. You can also use it in your own code to do stuff like programming timers, PWM, I2C clock frequency calculation etc. independent of the current frequency you are running at.

Whenever you change PLL settings or select a different clock source, you can call SystemCoreClockUpdate() and after that reinitialize modules that need their timing changed.

This is independent of the LPCXpresso board you are using. It is a system function provided by CMSIS to allow you to update the SystemCoreClock variable when your program changes the core clock frequency.



Joined: 2011-06-29
Posts: 7

Thanks Rob for your detailed answer. I started with an independent project. So I didn't look in other example projects to see how it is used.

Thanx. Sorry for the trouble.