Tutorial: Maximum Clock Frequency for Kinetis using MCUXpresso Clock Tools

The tinyK22 board with the NXP K22FN512 is a bread-board-friendly small board with a 8 MHz external oscillator:

tinyK22 Board

tinyK22 Board

This tutorial is about how to use the NXP MCUXpresso Clock configuration and configure the board to the maximum clock frequency of 120 MHz. The same steps apply to many other boards, including the FRDM-K22F one.

The tinyK22 has the K22FN512 ARM Cortex-M4F on it which runs up to 120 MHz. It is the same processor as the one on the FRDM-K22F.

tinyK22 on breadboard

tinyK22 on breadboard

The NXP MCUXpresso SDK examples do not come with a clock configuration which runs at the maximum of 120 MHz. In this tutorial I show how to use the Clock configuration tool with the NXP MCUXpresso IDE V11.1.0 to achieve that:

  1. Open the Clocks Tool
  2. Configur using external oscillator with 8 MHz
  3. Enable PLL mode
  4. Set Frequency to 120 MHz
  5. Generate code
  6. Celebrate 🙂

In this tutorial I’m using a FreeRTOS project I have on GitHub, but any other SDK project could be used.

tinyK22 FreeRTOS Project

tinyK22 FreeRTOS Project

Open the Clocks tool using the Icon in the Project Explorer:

Open Clocks

Open Clocks

This opens the tool with a graphical view of the clocking hardware:

MCUXpresso IDE Clocks Tool

MCUXpresso IDE Clocks Tool

The first important thing to do is to switch from RUN to HSRUN (High-Speed Run), as only in this mode the highest clock frequency can be used:

Enable HSRUN

Enable HSRUN

Then switch to the PLL (Phase Locked Loop) mode with External reference clock: PEE (PLL Engaged External):

Switch to PEE Mode

Switch to PEE Mode

As now not everything can work as is, part of the clock paths turns red to indicate an error:

Errors with PLL Enabled

Errors with PLL Enabled

We need to feed the PLL with the external clock: Right-Click on the OSC and enable the oscillator:

Enable Oscillator

Enable Oscillator

A dialog asks to enter the frequency which is 8 MHz in my case:

Enter Oscillator Value

Enter Oscillator Value

Now the error disappears, and clocking is set to 96 MHz:

8 MHz Oscillator applied

8 MHz Oscillator applied

I have to change the settings of the oscillator a bit more:

Edit Settings

Edit Settings

As I’m using an external oscillator, I change the setting to reflect this: Set the OSC mode to ‘Using oscillator with external crystal (low power)‘ plus configure the frequency Range to ‘High frequency range 3-8 MHz‘:

External Crystal with High Frequency

External Crystal with High Frequency

Now I can change the PLL output to 120 MHz. One way is to directly edit the value:

Change PLL output to 120 MHz

Change PLL output to 120 MHz

It will automatically update the dividers. And voilà: maximum frequency reached with 120 MHz 🙂

maximum clock frequency

maximum clock frequency

I can check the settings and output frequencies in the ‘Clock Table’:

Clocks Table

Clocks Table

Now it is time to update the code. But it gives an error:

Update Code

Update Code

The problem is that the SMC which manages the system clock:

💡 it would be ideal if the Clock tool would now ask to add the driver because obviously it knows about it. So I have to do it manually….

SMC Driver Needed

SMC Driver Needed

So I switch the perspective back to the ‘Development’ so I can add the missing driver:

Switching Perspective

Switching Perspective

In the Project Explorer view I can use the tool button to manage SDK Components:

Manage SDK Components

Manage SDK Components

In the following dialog I enable and add the SMC SDK Component Driver:

Add SMC Component

Add SMC Component

A dialog asks me to confirm the changes with the new driver added:

SDK Component Manager Confirmation Dialog

SDK Component Manager Confirmation Dialog

Now I switch back to the Clocks tool:

Switch back to Clocks

Switch back to Clocks

Everything still looks good:

Finished Clock Settings

Finished Clock Settings

So I update the files again, and this time there is no error:

Update Files

Update Files

Now I can build the application. And it is now running at maximum speed of 120 MHz :-).

Summary

This tutorial shows how I can change the default clock of the Kinetis to use the maximum clock frequency. The MCUXpresso Clocks tool gives me great control over the clock path and settings, and the graphical view really helps understanding the clock distribution. The downside is the complexity of these parts: it is easy to get into clock configuration which does not work. And even with such a graphical tool, it still requires to read the reference manual and the details behind the clocking of the device. I hope you find the documented steps in this tutorial useful, so you could do the same for your specific device.

Happy Clocking 🙂

Links

3 thoughts on “Tutorial: Maximum Clock Frequency for Kinetis using MCUXpresso Clock Tools

  1. Hi Erich,
    I notice the little ballon message in the very first picture says ‘K22FX512’. Pretty sure your talking about the K22FN512 in this article. As we both know, the FX is quite a different animal than the FN when it comes to the clocks and flash memory config.

    Brynn

    Like

  2. Pingback: FatFS, MinIni, Shell and FreeRTOS for the NXP K22FN512 | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.