SystemCoreClockUpdate()

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

SystemCoreClockUpdate()

3,813 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mikewi on Wed Apr 11 03:08:11 MST 2012
The function
void SystemCoreClockUpdate (void) appears to be mandated by CMSIS with the folowing functionality:

"Updates the variable SystemCoreClock and must be called whenever the core clock is changed during program execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates the current core clock."

The only implementations that I have seen are naive ones setting predefined fixed values not functions. (system_ARMCM4.c attached)

Some examples also have the function exterened but not apparently implemented.

Am I missing something in the NXP library code?

Original Attachment has been moved to: system_ARMCM4.c.zip

Labels (1)
0 Kudos
Reply
1 Reply

2,793 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by PhilYoung on Fri Apr 13 09:49:06 MST 2012
the latest demo code provides some more detailed functions for this, as used in the fastboot example.
The problem however is computing some of the other values for setting up the PLL, particularly if you need to set up the audio or USB PLL, I can't find the algorithm for these but there is a program from NXP to compute them and provide the values to write into the registers.

Also, when updating the core clock you need to be careful about switching directly to a high speed since this can crash the device ( due to a bug that still hasn't made it into the errata ), you may need to switch frequency in stages or the CPU may crash.

personally I chose not to use the supplied functions since they build a cross reference table of frequencies and legal options and test everything, this has a significant RAM overhead and is completely unnecessary in most embedded systems where the frequency plan is determined once and fixed for the application lifetime.

Setting up the clocks then just needs a few lines of code.

regards

Phil.
0 Kudos
Reply