The tinyK22 board with the NXP K22FN512 is a bread-board-friendly small board with a 8 MHz external oscillator:
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.
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:
- Open the Clocks Tool
- Configur using external oscillator with 8 MHz
- Enable PLL mode
- Set Frequency to 120 MHz
- Generate code
- Celebrate 🙂
In this tutorial I’m using a FreeRTOS project I have on GitHub, but any other SDK project could be used.
Open the Clocks tool using the Icon in the Project Explorer:
This opens the tool with a graphical view of the clocking hardware:
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:
Then switch to the PLL (Phase Locked Loop) mode with External reference clock: PEE (PLL Engaged External):
As now not everything can work as is, part of the clock paths turns red to indicate an error:
We need to feed the PLL with the external clock: Right-Click on the OSC and enable the oscillator:
A dialog asks to enter the frequency which is 8 MHz in my case:
Now the error disappears, and clocking is set to 96 MHz:
I have to change the settings of the oscillator a bit more:
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‘:
Now I can change the PLL output to 120 MHz. One way is to directly edit the value:
It will automatically update the dividers. And voilà: maximum frequency reached with 120 MHz 🙂
I can check the settings and output frequencies in the ‘Clock Table’:
Now it is time to update the code. But it gives an error:
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….
So I switch the perspective back to the ‘Development’ so I can add the missing driver:
In the Project Explorer view I can use the tool button to manage SDK Components:
In the following dialog I enable and add the SMC SDK Component Driver:
A dialog asks me to confirm the changes with the new driver added:
Now I switch back to the Clocks tool:
Everything still looks good:
So I update the files again, and this time there is no error:
Now I can build the application. And it is now running at maximum speed of 120 MHz :-).
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 🙂
- Project used in this article: https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/MCUXpresso/tinyK22/tinyK22_FreeRTOS
- MCUXpresso IDE V11.1.0: https://mcuoneclipse.com/2020/01/05/mcuxpresso-ide-v11-1-0/
- MCUXpresso IDE web page: http://www.nxp.com/mcuxpresso/ide
- MCUXpresso SDK web page: http://mcuxpresso.nxp.com/
- Clock configuration with Processor Expert: FRDM-K64F at Maximum Speed of 120 MHz