MCUXpresso Config Tools: How to Use the Clocks Tool (Japanese Blog) table of contents
Introduction
In what situations can Clocks Tool be used?
Installing Config Tools
Browse Tool screen configuration
Basic Terminology for Using Clocks Tool
Demonstration: Change the CPU core clock settings and alter the LED blinking speed.
Bonus 1 - Clock settings are already available as presets.
Bonus 2 - Where are the settings values that were automatically generated by the initialization code?
Introduction
MCUXpresso is a microcontroller development software platform provided by NXP. In addition to the MCUXpresso IDE, it also offers MCUXpresso for VSC (Visual Studio Code) and Config Tools to assist with peripheral configuration.
Config Tools consists of tools such as the " Pins Tool " for setting pins and the " Clocks Tool " for configuring clock settings, and its key feature is that initial setup of the microcontroller can be performed intuitively and easily via a GUI . In this article, we will focus on the "Clocks Tool," which is responsible for clock settings.
Clock settings are a crucial element directly impacting microcontroller performance, power consumption, and the operation of each peripheral. However, the clock tree can be complex, making it difficult to understand which clock is being used where . Clocks Tool allows you to visualize and configure clock sources, frequency division settings, and the clock supply status to each peripheral. It can also automatically generate initialization code based on the settings.
When you install the MCUXpresso IDE , Config Tools are also installed, making them available as a built-in feature of the IDE . On the other hand, in the Visual Studio Code ( VSC ) environment, which has become increasingly popular in embedded development in recent years, you can similarly use Config Tools (including Clocks Tool ) by installing MCUXpresso -related extensions. There are no significant differences in the functionality of Config Tools between the IDE version and the VSC version.
This article explains how to install Config Tools in the VS Code environment, how to use the tools, and finally demonstrates how to change the CPU clock settings within Clocks Tool and alter the LED blinking speed using the FRDM-MCXN947 .
In what situations can Clocks Tool be used?
When you want to check the existing internal clock settings (clock tree)
When you want to adjust and optimize the operating frequency for each module
When you want to consider a configuration that lowers the clock frequency with low power consumption in mind.
Installing Config Tools
This guide explains how to install Config Tools in the VS Code environment. *If you haven't installed MCUXpresso for VS Code yet, please refer to this blog post.
Installing MCUXpresso for VSC and SDK (Japanese blog)
After launching VS Code , select MCUXpresso from the left-hand panel, and then click Open MCUXpresso Installer from the Quick Start Panel .
The installer will launch. Select MCUXpresso Configuration Tools and click Install in the upper right corner. (This blog post describes the installation of MCUXpresso Config Tools v26.03.)
You will be prompted to log in to MyNXP as soon as the installation begins.
After logging in, the License Agreement will be displayed. Please review its contents and agree to them.
*Please restart VS Code after installation.
Q. What if the installation fails? A. Please download the installer appropriate for your PC's OS environment from the following website and try it. MCUXpresso Config Tools | Software Development for NXP Microcontrollers (MCUs) | NXP Semiconductors As you proceed with the installation, the following screen will appear on the initial screen. If you do not see anything relevant, you can close it.
To access Config Tools from VS Code , install the SDK , import the sample, then right-click on your project. "Open with MCUXpresso Config Tools " will appear; click on it. *This entire process will be explained in detail in the final demonstration, so we will omit it here. Config Tools will start after a short while.
If you are using the MCUXpresso IDE, Config Tools are integrated by default and can be launched directly from the top tab.
Browse Tool screen configuration
After launching Config Tools , you can switch between tools using the panel on the right side of the screen.
This time, we'll select " Clocks ".
The Clocks Diagram , which is frequently used when changing clock settings , can be selected from the top left of the screen. The Problem view in the lower right corner of the screen displays any errors or warnings related to your settings.
If there is an error due to incorrect clock settings, the Problem view will display the location and cause of the error. Additionally, the relevant area will be highlighted in red on the Clock Diagram, allowing you to visually identify the problem.
For example, if you set the CPU clock to exceed the specified maximum value, an error message (shown below) will be displayed.
Basic Terminology for Using Clocks Tool
This section clarifies the basic terminology displayed on the Clock Diagram when using the Clocks Tool .
Clock Tree This is a configuration diagram (tree diagram) showing where clocks are generated, how they are distributed and selected, and how they are supplied to each block. Clocks Tool allows you to configure settings while visually viewing this Clock Tree .
Clock Source This is the signal source that serves as the starting point for the clock. This includes internal RC clocks, external crystals (oscillators), and external clock inputs, and is located upstream in the clock tree. In the MCX N947, the built-in 48MHz RC clock (FIRC) is used as the clock source by default .
PLL ( Phase Locked Loop) This circuit generates a stable high-frequency clock using a clock source as input. The output frequency can be adjusted by setting the multiplier and frequency divider, allowing for flexible creation of clocks for CPUs and high-speed buses . Here, a 300MHz clock (48MHz/8*50=300MHz) is generated based on the 48MHz input clock, which is the Clock Source .
DIV (Divider ) This function allows you to divide and adjust the clock frequency. Frequency division settings are available for the CPU , bus, and each peripheral, and are used to adjust to the required operating frequency. In the following example, a 150MHz clock (300MHz/2=150MHz) is generated from a 300MHz clock generated by PLL0.
Mux ( Multiplexer ) This mechanism allows you to switch which clock to use from among several potential clocks. Switching the selection changes the clock supplied downstream. In the diagram below, there are two MUXs ; the one on the left selects a 48MHz clock from the internal RC clock, and the one on the right selects a 150MHz clock divided by DIV (PLL0_PDIV) .
Demonstration: Change the CPU core clock settings and alter the LED blinking speed.
Here, we will actually change the clock supplied to the CPU using Clocks Tool and see if the blinking speed of the LEDs on the evaluation board changes.
Hardware Preparation The evaluation board used in this article is the FRDM-MCXN947
Installing the SDK With the MCUXpresso icon selected in the left-hand panel of VS Code , click " Import Repository ".
Next, click on " REMOTE ARCHIVE ," the second option from the left, and search for " FRDM-MCXN947 " in the Package section . Entering " 947 " will immediately display FRDM-MCXN947 as a suggestion .
The Name , Location , and the "Create Git" checkbox can be set as you wish.
*For Name and Location names, it is best to use only lowercase alphanumeric characters and underscores (_) or hyphens (-) , and avoid symbols such as ( \, /, :, *, ?, ", <, >, | , specs) (which may cause program malfunctions).
Finally, check the " I agree " box and click " Import " to begin the SDK installation. Please wait a moment. The installation is complete when " Repository successfully imported" is displayed in the lower right corner of the screen.
Importing sample code Once the SDK installation is complete, proceed to import the sample code. Click " Import Example From Repository " in the panel on the left.
Within each tab displayed on the right, under " Repository ," select the SDK you just imported. Please select FRDM-MCXN947 for " Board ". In this " Template " demonstration, we will be changing the blinking speed of the LED . I'll try it with " driver_examples/gpio/gpio_led_output_cm33_core0 " which appears when I type " led ".
Next, select the Toolchain and click " Import" .
Open ConfigTools Right-click on the imported sample and select " Open with MCUXpresso Config Tools ". The Config Tools will launch after a short wait.
Once Config Tools opens, first check the Overview in the right-hand panel. In this example, both Clocks and Pins are green (ON ) , indicating that both tools are enabled.
Now, let's look at the Clock Diagram . The main clock of 150MHz is generated from the clock source FIRC 48MHz via PLL (PLL0) , DIV (PLL0_PDIV) , and MUX (SCSSEL) .
Next, scroll down a bit to see the clock supplied to the CPU . In this sample application, " System_clock" corresponds to the CPU core clock.
The MAIN Clock at 150MHz passes through a DIV ( Distributed Variable) in between, but is still supplied to the System Clock at 150MHz . Later, we will change the value of this DIV and thereby change the clock signal input to the System Clock , observing the change in the LED blinking speed.
Check the LED blinking speed when the CPU Clock is set to 150MHz. First, let's look at the LED blinking speed when the CPU Clock is set to 150MHz without any changes. Close Config Tools and open VS Code . Before building, connect the board ( FRDM-MCXN947) to the PC .
Once the connection is established, debug the imported sample (build, write, and run the application).
Once the debugging process is complete, the program will have stopped at the breakpoint, so click the "|▶" icon at the top of the screen.
As shown in the video, the red LED will start blinking. This is the blinking speed at a clock speed of 150MHz (default setting). (function() { var wrapper = document.getElementById('lia-vid-6395306957112w304h540r825'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos) To stop, click the square icon (even after stopping the debug, the program will continue to run on the board, so the LED will continue to blink, but please ignore this for now ) .
Change the CPU clock to 50MHz and check the LED blinking speed. Next, we'll use ClocksTool to change the CPU core clock from 150MHz to 50MHz . Open the Clocks Tool in Config Tools again . Scroll down slightly in the Clocks Diagram and change the DIV (AHBCLKDIV) connected to the System Clock . When changing it, click on the number within the DIV you want to change to select from the dropdown menu. Selecting 1/3 here will change the System Clock to 50MHz .
*When changing clock settings, please note that changing the clock settings upstream, which are close to the Clock Source, may affect multiple clock settings downstream.
Now, we will rewrite the sample code. First, click "Update Code" in the upper left corner of the Config Tools screen. In the dialog box that appears, select "OK".
When you return to VS Code in this state, three checkboxes will appear at the top of the screen. Make sure they are checked and click OK . After a short wait, the changes made in Clocks Tool will be applied to the sample code in VS Code .
If successful, the following message will be displayed in the lower right corner of the screen.
Run the debug test again, and once it's finished, run the sample application using "|▶". The LED will start blinking. This is the blinking speed at a 50MHz clock. It is clearly slower compared to the speed at 150MHz .
(function() { var wrapper = document.getElementById('lia-vid-6395308518112w304h540r707'); var videoEl = wrapper ? wrapper.querySelector('video-js') : null; if (videoEl) { if (window.videojs) { window.videojs(videoEl).ready(function() { this.on('loadedmetadata', function() { this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) { bar.setAttribute('role', 'presentation'); bar.setAttribute('aria-hidden', 'true'); }); }); }); } }})(); (Show My Videos)
This concludes the demonstration. Thank you for your participation.
Bonus 1 - Clock settings are already available as presets.
While the previous steps involved changing the clock using DIV , Clocks Tool comes with several clock settings pre-configured. Select Clocks Tool in Config Tools , and then choose your desired clock from the top of the screen : FRO 12MHz / FRO HF 48MHz / FRO HF 144MHz…
For example, if you select "BOARD_BootClockPLL_100M " , you will see that the Clock Source , PLL , and DIV are all different from before. For example, the Clock Source is a 24MHz external clock (SOSC) .
Bonus 2 - Where are the settings used to automatically generate the initialization code?
We will examine how the clock settings are automatically updated (Update Code) using Clock Tools, and how this is reflected in the actual initialization code.
Check the C source file (gpio_led_output.c) in the Project Files of the imported sample.
If you look inside the C source file, you'll find code that initializes the Pin , Clock , and Debug console .
Right-click on BOARD_InitHardware(); and click "Go to Definition" to see more details.
There is code to initialize the Pin , Clock , and Debug console . Right-click on BOARD_InitBootClocks(); and select " Go to Definition" (or "fn + F12") to see more details. The destination file (clock_config.c) is FRDM-MCXN947This is the generated code that defines the startup clock configuration. As you scroll down, you will see that, as explained earlier, multiple clock configurations ( FRO 12MHz / FRO HF 48MHz / FRO HF 144MHz / PLL 150MHz / PLL 100MHz ) are available as presets. In the image below, the default value of PLL150MHz is shown,
For example, if you change this part to BOARD_BootClockFROHF48M
Initialization will be performed using the FRO HF 48M clock configuration, which is prepared as a preset.
Next, let's see how the clock configuration and code change when we directly modify the DIV in Clocks Tool while keeping the FRO HF 48M . The text and settings enclosed in the red box will be changed.
Furthermore, if you change the DIV connected to the System Clock in Clocks Tool to 1/2 , i.e., from 48 to 24MHz, and then run Update Code, you will see that the red frame has changed due to the change in DIV.
You can also check the differences before and after the changes in Clocks Tool. After changing the clock settings, clicking Update Code will display a dialog box like the one below. Files with differences will have "change" displayed to the right of the file name. Clicking this will allow you to view the differences.
clock_config.c Let's check the difference. The left side (Newly generated) shows the modified file, and the right side (On disk) shows the original file. You should be able to see that there is a difference in the System Clock. The areas where differences have occurred are highlighted with a different color, making them visually easy to spot.
Due to the increasing integration of functions in microcontrollers and processors, their internal clock trees have become extremely complex. Without a clock visualization tool like this, designing and evaluating such systems would be practically impossible, so please make use of it.
=========================
We are currently unable to respond to comments left in the " Comment " section of this post . We apologize for the inconvenience, but please refer to " Technical Questions to NXP - How to Contact Us ( Japanese Blog ) " when making inquiries . (If you are already an NXP distributor or have a relationship with NXP , you may ask your representative directly.) This guide focuses on the "Clocks Tool" within the MCUXpresso Config Tools, explaining the basics and methods of setting the clock. It covers everything from installation in a VS Code environment to a demonstration of LED blinking caused by CPU clock changes. (Estimated time: 10 minutes *Assumes MCUXpresso for VSC (Visual Studio Code) SDK is installed) MCUXpresso MCX Victoria | Downloads Japanese Blog
查看全文