2363914_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2363914_en-US

2363914_en-US

MCUXpresso Config Tools: How to Use the Clocks Tool (Japanese Blog)

table of contents

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 .


You can also watch it in video format. Click this link to watch.


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.


After launching VS Code , select MCUXpresso from the left-hand panel, and then click Open MCUXpresso Installer from the Quick Start Panel .

Kogiso_0-1778572125810.png


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.)

Kogiso_1-1779262222580.png



You will be prompted to log in to MyNXP as soon as the installation begins.

Kogiso_2-1778572191255.png

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.

Kogiso_3-1778572212609.png

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.

Kogiso_0-1779263924259.png



If you are using the MCUXpresso IDE, Config Tools are integrated by default and can be launched directly from the top tab.

Kogiso_5-1778572280128.png


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 ".

Kogiso_6-1778572331001.png


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.

Kogiso_0-1779261646084.png


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.

Kogiso_1-1778634860572.png


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 .

Kogiso_8-1778572482107.png


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 .

Kogiso_9-1778572553141.png


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.

Kogiso_0-1778575383641.png


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) .

Kogiso_10-1778572690176.png


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 ".

Kogiso_11-1778572835161.png


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 .

Kogiso_12-1778572855885.png

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.

Kogiso_13-1778572880338.png

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.

Kogiso_14-1778572955527.png


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 ".

Kogiso_15-1778572977361.png


Next, select the Toolchain and click " Import" .

Kogiso_16-1778572998907.png


Open ConfigTools
Right-click on the imported sample and select " Open with MCUXpresso Config Tools ". The Config Tools will launch after a short wait.

Kogiso_17-1778573044565.png


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.

Kogiso_18-1778573085903.png


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) .

Kogiso_19-1778573132716.png


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.

Kogiso_20-1778573194903.png



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 .

Kogiso_21-1778573253173.png


Once the connection is established, debug the imported sample (build, write, and run the application).

Kogiso_4-1779431772140.png


Once the debugging process is complete, the program will have stopped at the breakpoint, so click the "|▶" icon at the top of the screen.

Kogiso_23-1778573283897.png

As shown in the video, the red LED will start blinking. This is the blinking speed at a clock speed of 150MHz (default setting).

(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 ) .

Kogiso_24-1778573665179.png


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.

Kogiso_0-1779430403587.png


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".

Kogiso_26-1778573845631.png


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 .
*This may not be displayed if the SDK version is different.

Kogiso_27-1778573865307.png

If successful, the following message will be displayed in the lower right corner of the screen.

Kogiso_28-1778573878068.png


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 .

(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…

Kogiso_0-1778574158553.png

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) .

Kogiso_1-1778574179336.png

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.

Kogiso_2-1778574228909.png


If you look inside the C source file, you'll find code that initializes the Pin , Clock , and Debug console .

Kogiso_3-1778574247421.png


Right-click on BOARD_InitHardware(); and click "Go to Definition" to see more details.

Kogiso_4-1778574280972.png


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,

Kogiso_5-1778574353197.png


For example, if you change this part to BOARD_BootClockFROHF48M

Kogiso_6-1778574378576.png


Initialization will be performed using the FRO HF 48M clock configuration, which is prepared as a preset.

Kogiso_7-1778574399078.png


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.

Kogiso_8-1778574466864.png


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.

Kogiso_9-1778574928326.png

 

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.

Kogiso_2-1779431079086.png

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.

Kogiso_3-1779431340110.png

 

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.

 

Reference materials


 

=========================

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)

MCUXpressoMCXVictoria | DownloadsJapanese Blog
タグ(1)
評価なし
バージョン履歴
最終更新日:
木曜日
更新者: