Let's take your FRDM-KL46Z for a test drive! You have the choice of watching the sequence in a short video or following the detailed actions list below.
Your FRDM-KL46Z comes loaded with a "bubble level" demo that leverages the on-board accelerometer. When the board is flat, the RGB LED is turned off, and when the board is tilted, the red or green LEDs gradually illuminate based on the degree of tilt on the X- and Y-axis.
No problem! Your board simply came in the old packaging and has a different out-of-box demo loaded into the flash memory.
You should be seeing the RGB LED toggling between each of the three colors; red, blue and green. It's OK to move onto the next step when you're ready.
Try proceeding to the next steps to get other example applications running on your board. If you still have problems, try contacting us through the NXP Community.
The Kinetis Software Development Kit (SDK) is complimentary and includes full source code under a permissive open-source license for all hardware abstraction and peripheral driver software.
Click below to download the SDK Release appropriate for your computer's operating system.
NXP offers a complimentary toolchain called Kinetis Design Studio (KDS).
Want to use a different toolchain?
No problem! The Kinetis SDK includes support for other tools such as IAR, Keil and command-line GCC.
Many of the example applications output data over the MCU UART so you’ll want to make sure that the driver for the board’s virtual COM port is installed. It should install automatically when you plug the board in to your PC. If the driver does not automatically install, click here to download the installer.
With the serial port driver installed, run your favorite terminal application to view the serial output from the MCU's UART. Configure the terminal to 115200 baud rate, 8 data bits, no parity and 1 stop bit. To determine the port number of the FRDM-K64F's virtual COM port, open the device manager and look under the "Ports" group.
Not sure how to use a terminal application? Try one of these tutorials:
Tera Term is a very popular open source terminal emulation application. This program can be used to display information sent from your NXP development platform's virtual serial port.
PuTTY is a popular terminal emulation application. This program can be used to display information sent from your NXP development platform's virtual serial port.
The Kinetis SDK comes with a long list of demo applications and driver examples. To see what's available,
browse to the SDK 'examples' folder of your SDK installation and select your board, the
FRDM-KL46Z (
To learn more about demo applications or driver examples, open the Kinetis SDK Demo Applications User's Guide,
located in
If one or more of the demo applications or driver examples sounds interesting, you're probably wanting to know how you can build and debug yourself. The Getting Started with Kinetis SDK guide provides easy, step-by-step instructions on how to configure, build, and debug demos for all toolchains supported by the SDK.
Use the guide below to learn how to open, build and debug an example application using the Kinetis Design Studio (KDS) IDE.
Using a different toolchain?
Before using KDS IDE with KSDK, the KSDK Eclipse Update must be applied. Without this update, Eclipse cannot generate KSDK-compatible projects.
The steps required for Mac OS are identical to Windows; the only difference is that the IDE looks slightly different.
After installing KDS, check for available updates. Install the Processor Expert 3.0.1 updates from NXP only - do not install any other updates. To check for updates, select “Help” -> “Check for Updates”.
Select "Help" -> "Install New Software".
In the Install New Software dialog box, click the "Add" button in the upper right corner. Then, in the Add Repository dialog, select the "Archive" button.
In the Repository archive dialog box, browse the KSDK install directory
Enter the
Click "Open", and the "OK" button in the Add Repository dialog box.
The KSDK update shows up in the list of the original Install dialogs
Check the box to the left of the KSDK Eclipse update and click the "Next" button in the lower right corner.
Follow the remaining instructions to finish the installation of the update.
After the update is applied, restart KDS for the changes to take effect.
The following instructions were performed using Ubuntu 14.04. These steps may be slightly different for other Linux distributions.
Launch KDS IDE from the command line as the root user. On the command line, use this command, assuming the default KDS IDE install path:
user@ubuntu:~$ sudo /opt/NXP/KDS_x.x.x/eclipse/kinetis-design-studio
The KDS IDE version (shown above as x.x.x) should reflect the version installed on your machine, for example, 3.0.0.
You are prompted to enter the root password.
After installing KDS, check for available updates. Install the Processor Expert 3.0.1 updates from NXP only - do not install any other updates. To check for updates, select “Help” -> “Check for Updates”.
Select "Help" -> "Install New Software"
In the "Install New Software" dialog box, click the "Add" button in the upper right corner. Then, in the "Add Repository" dialog, select "Archive".
In the Repository archive dialog box, browse the KSDK install directory.
Enter the
Click "Open", and "OK" in the "Add Repository" dialog box.
The KSDK update shows up in the list of the original Install dialogs.
Check the box to the left of the KSDK Eclipse update and click the "Next" button in the lower right corner.
Follow the remaining instructions to finish the installation of the update.
After the update is applied, restart the KDS IDE for the changes to take effect.
After KDS IDE restarts, shut down the IDE and restart by launching KDS IDE as the non-root user. To do this, follow the command in step 1, only without the "sudo" command.
These steps show how to open and build the platform library project in KDS IDE. The platform library is required by the demo and does not build without it.
NOTE
The steps required for Linux and Mac OS are identical to those for Windows.
Select "File->Import" from the KDS IDE menu. In the window that appears, expand the "General" folder and select "Existing Projects into Workspace". Then, click the "Next" button.
Click the "Browse" button next to the "Select root directory:" option.
Point to the platform library project for the appropriate device, which can be found using this path:
After pointing to the correct directory, your "Import Projects" window should look like the figure below. Click the "Finish" button.
There are two project configurations (build targets) supported for each KSDK project:
Choose the appropriate build target, "Debug" or "Release", by clicking the downward facing arrow next to the hammer icon, as shown below. For this example, select the "Debug" target.
The library starts building after the build target is selected. To rebuild the library in the future, click the hammer icon (assuming the same build target is chosen).
To build a demo application, repeat the steps listed in the "Build the Platform Library" section using a demo application project instead of the platform library project. Demo application projects are located in this folder:
For this example, the path is:
NOTE
The steps required for Linux and Mac OS are identical to those for Windows.
The FRDM-KL46Z board comes loaded with the mbed/CMSIS-DAP debug interface from the factory. If you have changed the debug OpenSDA application on your board, visit http://www.nxp.com/opensda for information on updating or restoring your board to the factory state.
Mac users must install the J-Link OpenSDA application in order to use the KDS IDE to download and debug their board.
Connect the development platform to your PC via USB cable between the "SDAUSB" USB port on the board and the PC USB connector.
Open the terminal application on the PC (such as PuTTY or TeraTerm) and connect to the debug COM port you determined earlier. Configure the terminal with these settings:
For Linux OS users only, run the following commands in your terminal. These install libudev onto your system, which is required by KDS IDE to launch the debugger.
user@ubuntu:~$ sudo apt-get install libudev-dev libudev1
user@ubuntu:~$ sudo ln —s /usr/lib/x86_64-linux-gnu/libudev.so /usr/lib/x86_64-linux-gnu/libudev.so.0
Ensure that the debugger configuration is correct for the target you're attempting to connect to. Consult Appendix B for more information about the default debugger application on the various hardware platforms supported by the KSDK.
To check the available debugger configurations, click the small downward arrow next to the green "Debug" button and select "Debug Configurations".
In the Debug Configurations dialog box, select debug configuration that corresponds to the hardware platform you're using. For Windows or Linux users, select is the CMSIS-DAP/DAPLink option under OpenOCD. For Mac users, select J-Link.
After selecting the debugger interface, click the "Debug" button to launch the debugger.
The application is downloaded to the target and automatically run to main():
Start the application by clicking the "Resume" button:
The hello_world application is now running and a banner is displayed on the terminal. If this is not the case, check your terminal settings and connections.
These steps show how to open a demo workspace in IAR Embedded Workbench, how to build the platform library required by the demo, and how to build the demo application. The example used below is for the hello_world demo, but similar steps can be applied to any demo in the KSDK.
Open demo workspace (*.eww file) in:
After the workspace is open, two projects are shown: one for the KSDK platform library and one for the demo. Also, the platform library project is bold, indicating that it is the active project. The active project can be changed at any time by right clicking on the desired project and selecting "Set as Active" or via the build target drop-down at the top of the workspace browser.
There are two project configurations (build targets) supported for each KSDK project:
Click the "Make" button, highlighted in red below.
When the build is complete, the library (libksdk_platform.a) is generated in one of the following directories, according to the chosen build target:
The KSDK demo applications are built upon the software building blocks provided in the Kinetis SDK platform library, built in the previous section. If the platform library is not present, the linker displays an error indicating that it cannot find the library. An easy way to check whether the library is present is to expand the Output folder in the ksdk_platform_lib project. If the platform library binary is not built and present, follow the steps on page 1 to build it. Otherwise, continue with the following steps to build the desired demo application.
If not already done, open the desired demo application workspace (*.eww file). This example's workspace file is located in:
Select the desired build target from the drop-down. For this example, select the "hello_world — Debug" target.
To build the demo application, click the "Make" button, highlighted in red below.
The build will complete without errors.
The FRDM-KL46Z board comes loaded with the mbed/CMSIS-DAP debug interface from the factory. If you have changed the debug OpenSDA application on your board, visit http://www.nxp.com/opensda for information on updating or restoring your board to the factory state.
Connect the development platform to your PC via USB cable between the "SDAUSB" USB port on the board and the PC USB connector.
Open the terminal application on the PC (such as PuTTY or TeraTerm) and connect to the debug COM port you determined earlier. Configure the terminal with these settings:
Click the "Download and Debug" button to download the application to the target.
The application is then downloaded to the target and automatically runs to the main() function.
Run the code by clicking the "Go" button to start the application.
The hello_world application is now running and a banner is displayed on the terminal. If this is not the case, check your terminal settings and connections.
After the MDK tools are installed, Cortex® Microcontroller Software Interface Standard (CMSIS) device packs must be installed to fully support the device from a debug perspective. These packs include things such as memory map information, register definitions and flash programming algorithms. Follow these steps to install the appropriate CMSIS pack.
Open the MDK IDE, which is called µVision. In the IDE, select the "Pack Installer" icon.
In the Devices tab on the left hand side of the dialog box that appears, expand the NXP category. Then expand the KLxx Series category and highlight KL4x by clicking it once.
In the Pack Installer window on the right of the dialog box, click on the "Install" button next to the pack.
NOTE:
This process requires an internet connection to successfully complete.
After the installation finishes, close the Pack Installer window and return to the µVision IDE.
These steps show how to open the demo workspace in µVision, how to build the platform library required by the demo, and how to build the demo application.
Demo workspace files can be found using this path:
The workspace file is named
After the workspace is open, two projects show up: one for the KSDK platform library, and one for the demo. By default, the demo project is selected as the active project.
Make the platform library project the active project since the library is required by the demo application to build. To make the platform library project active, right click on it and select "Set as Active Project". The active project has a black box around the project name. After it is active, the platform library project is highlighted.
There are two project configurations (build targets) supported for each KSDK project:
The tool allows selection of the build target based on the active project, so in order to change the configuration for the platform library it must be the active project. Choose the appropriate build target: "Debug" or "Release" from the drop-down menu.
For this example, select the "ksdk_platform_lib Debug" configuration.
Rebuild the project files by left-clicking the "Rebuild" button, highlighted in red.
The KSDK demo applications are built upon the software building blocks provided in the Kinetis SDK platform library, built in the previous section. If the platform library is not present, the linker displays an error indicating that it cannot find the library. If the platform library binary is not built and present, follow the steps on page 2 to build it. Otherwise, continue with the following steps to build the desired demo application.
If not already done, open the desired demo application workspace in:
The workspace file is named
Make the demo the active project.
To build the demo project, select the "Rebuild" button, highlighted in red.
The build will complete without errors.
The FRDM-KL46Z board comes loaded with the mbed/CMSIS-DAP debug interface from the factory. If you have changed the debug OpenSDA application on your board, visit http://www.nxp.com/opensda for information on updating or restoring your board to the factory state.
Connect the development platform to your PC via USB cable between the "SDAUSB" USB port on the board and the PC USB connector.
Open the terminal application on the PC (such as PuTTY or TeraTerm) and connect to the debug COM port you determined earlier. Configure the terminal with these settings:
After the application is properly built, click the "Download" button to download the application to the target.
After clicking the "Download" button, the application downloads to the target and should be running. To debug the application, click the "Start/Stop Debug Session" button, highlighted in red.
Run the code by clicking the "Run" button to start the application.
The hello_world application is now running and a banner is displayed on the terminal. If this is not the case, check your terminal settings and connections.
This section contains the steps to install the necessary components required to build and run a KSDK demo application with the Arm GCC toolchain, as supported by the Kinetis SDK.
There are many ways to use Arm GCC tools, but this example focuses on a Windows environment. Though not discussed here, GCC tools can also be used with both Linux OS and Mac OSX.
Download and run the installer from launchpad.net/gcc-arm-embedded. This is the actual toolchain (i.e., compiler, linker, etc.). The GCC toolchain should correspond to the latest supported version, as described in the Kinetis SDK Release Notes.
The Minimalist GNU for Windows (MinGW) development tools provide a set of tools that are not dependent on third party C-Runtime DLLs (such as Cygwin). The build environment used by the KSDK does not utilize the MinGW build tools, but does leverage the base install of both MinGW and MSYS. MSYS provides a basic shell with a Unix-like interface and tools.
Download the latest MinGW mingw-get-setup installer from sourceforge.net/projects/mingw/files/Installer/.
Run the installer. The recommended installation path is C:\MinGW, however, you may install to any location.
NOTE
The installation path cannot contain any spaces.
Ensure that the "mingw32-base" and "msys-base" are selected under Basic Setup.
Click "Apply Changes" in the "Installation" menu and follow the remaining instructions to complete the installation.
Add the appropriate item to the Windows operating system Path environment variable. It can be found under Control Panel -> System and Security -> System -> Advanced System Settings in the "Environment Variables..." section. The path is:
Assuming the default installation path, C:\MinGW, an example is shown below. If the path is not set correctly, the toolchain does not work.
NOTE
If you have "C:\MinGW\msys\x.x\bin" in your PATH variable (as required by KSDK 1.0.0), remove it to ensure that the new GCC build system works correctly.
Create a new system environment variable and name it ARMGCC_DIR. The value of this variable should point to the Arm GCC Embedded tool chain installation path, which, for this example, is:
C:\Program Files (x86)\GNU Tools Arm Embedded\4.8 2014q3
Reference the installation folder of the GNU Arm GCC Embedded tools for the exact path name of your installation.
Download CMake 3.0.x from www.cmake.org/cmake/resources/software.html.
Install CMake, ensuring that the option "Add CMake to system PATH" is selected when installing. It's up to the user to select whether it's installed into the PATH for all users or just the current user. In this example, the assumption is that it's installed for all users.
Follow the remaining instructions of the installer.
You may need to reboot your system for the PATH changes to take effect.
Open a GCC Arm Embedded tool chain command window. To launch the window, from the Windows operating
system Start menu, go to "Programs -> GNU Tools Arm Embedded
Change the directory of the command window to the platform library directory in the KSDK:
There are two project configurations (build targets) supported for each KSDK project:
There are batch files provided to build both configurations. For this example, the "Debug" target is built and "build_debug.bat" is typed on the command line. If the "Release" target is desired, type the "build_release.bat" instead. Alternatively, if using the command line is not desired, you can double click on the batch files from Windows Explorer.
When the build finishes, the output looks like the image below(with KL46Z4 in place of K64F12).
The library (libksdk_platform.a) is generated in one of these directories, according to the build target:
KSDK demo applications require that the platform library for the same build target (Debug or Release) is present. Please ensure that you follow the steps in section 7.2 prior to attempting to build a demo application.
To build a demo application, follow these steps.
If not already running, open a GCC Arm Embedded tool chain command window. To launch the window,
from the Windows operating system Start menu, go to "Programs -> GNU Tools Arm Embedded
Change the directory to the demo application project directory, which has a path like this:
For this example, the exact path is:
Type "build_debug.bat" on the command line or double click on the "build_debug.bat" file in Windows operating system Explorer to perform the build. The output is shown in this figure:
The GCC tools require a J-Link debug interface. To update the OpenSDA firmware on your board to the latest J-Link app, visit www.nxp.com/opensda. After installing the J-Link OpenSDA application, download the J-Link driver and software package from www.segger.com/downloads.html.
Connect the development platform to your PC via USB cable between the "SDAUSB" USB port on the board and the PC USB connector.
Open the terminal application on the PC (such as PuTTY or TeraTerm) and connect to the debug COM port you determined earlier. Configure the terminal with these settings:
Open the J-Link GDB Server application. Assuming the J-Link software is installed, the application
can be launched by going to the Windows operating system Start menu and selecting "Programs ->
SEGGER -> J-Link
Modify the settings as shown below. The target device selection chosen for this example is the "MKL46Z128xxx4".
After it is connected, the screen should resemble this figure:
If not already running, open a GCC Arm Embedded tool chain command window. To launch the window,
from the Windows operating system Start menu, go to "Programs -> GNU Tools Arm Embedded
Change to the directory that contains the demo application output. The output can be found in using one of these paths, depending on the build target selected:
For this example, the path is:
Run the command "arm-none-eabi-gdb.exe
Run these commands:
The application is now downloaded and halted at the reset vector. Execute the "monitor go" command to start the demo application.
The hello_world application is now running and a banner is displayed in the terminal window.
Let's create our own project and make a simple SDK-based application. NXP provides an intuitive, simple project generation utility that allows creation of custom projects based on the Kinetis SDK.
After extracting the ZIP file, open the utility by clicking on the KSDK_Project_Generator executable for your computer's operating system. Point the tool to your SDK installation path, name your project, and select the board that it uses as a reference. Click on the Quick Generate button to finish.
Your new project will be located in
Now, let's make our new project do something other than spin in an infinite loop. The SDK examples provide a board support package (BSP) to do various things specific to the board, including macros and definitions for items such as LEDs, switches and peripheral instances. To keep things simple, lets make the LED blink using the BSP macros.
Update the main() function in your project's main.c file with the following code:
volatile int delay;
// Configure board specific pin muxing
hardware_init();
// Initialize the UART terminal
dbg_uart_init();
PRINTF("\r\nRunning the myProject project.\n");
// Enable GPIO port for LED1
LED1_EN;
for (;;)
{
LED1_ON;
delay = 5000000;
while(delay--);
LED1_OFF;
delay = 5000000;
while(delay--);
}
With the changes made to your main() function, build your application. Remember to build the SDK platform library first if you did not build any of the other SDK examples in the previous steps. Once the build is complete, download the application to your board.
If you need help figuring out how to build, download or run an application, reference your tool-specific guide from section 3.2.
With the application downloaded, you will see the FRDM-KL46Z's green LED blinking. You can also view terminal output using PRINTF.
Documents and Videos | Description |
---|---|
AN4507 Using the Kinetis Security and Flash Protection Features | Using the system security and flash protection features on Kinetis MCUs to protect code and data from unauthorized access or modification. |
Documents and Videos | Description |
---|---|
AN12377 Tuning I2C Timing in Target Mode | How to configure the I2C timing of a slave device to meet application needs which apply to Kinetis parts that contain I2C IP instead of LPI2C. |
Several examples, demos and drivers are available within the SDK to help you get started. Some common examples for wired communications are listed below.
Demonstrates basic usage of the on-board accelerometer to implement a bubble level. A bubble level utilizes two axes to visually show deviation from a level plane (0 degrees) on a given axis.
Path: <SDK_PATH>/boards/frdmkl46z/demo_apps/bubble
Demonstrates how to implement a command line shell application.
Path: <SDK_PATH>/boards/frdmkl46z/demo_apps/shell
A number of driver examples exist within the SDK including I2C, SPI, LPSCI and UART.
Path: <SDK_PATH>/boards/frdmkl46z/driver_examples
These examples are built on and demonstrate various USB classes and provide jumping off points for your application.
Path: <SDK_PATH>/boards/frdmkl46z/usb_examples
Documents and Videos | Description |
---|---|
AN4631 Using Asynchronous DMA features of Kinetis L Series | How to use the asynchronous DMA of low-power Kinetis L microcontrollers and save power consumption in your application. |
AN4503 Power Management for Kinetis MCUs | When and how to use Kinetis low-power modes. |
AN5088 Power Management for Kinetis L Family | Shows details of each power modes and provides use case examples in the SDK power manage demo. Tips are given for using each of the power modes. |
Several examples, demos and drivers are available within the SDK to help you get started. Some common examples for power management are listed below.
Demonstrates the use of power modes in the SDK.
Path: <SDK_PATH>/boards/frdmkl46z/demo_apps/power_mode_switch
How to change power modes in the SDK.
Path: <SDK_PATH>/boards/frdmkl46z/demo_apps/power_manager
Demonstrates the usage of the ADC peripheral while in a low power mode.
Path: <SDK_PATH>/boards/frdmkl46z/demo_apps/adc16_low_power
Demonstrates the usage of the ADC and DMA peripheral while in a low power mode.
Path: <SDK_PATH>/boards/frdmkl46z/demo_apps/adc16_low_power_async_dma
Documents and Videos | Description |
---|---|
USB Speakers User’s Guide | Explains the features and usage of the USB Speakers reference design. |
Several examples, demos and drivers are available within the SDK to help you get started. Some common examples for audio are listed below.
CMSIS DSP examples are provided to demonstrate CMSIS DSP driver usage in the SDK environment
Path: <SDK_PATH>/CMSIS/DSP/Examples/ARM
Examples that enumerate a recording device
Paths:
<SDK_PATH>/boards/frdmkl46z/usb_examples/usb_device_audio_generator
<SDK_PATH>/boards/frdmkl46z/usb_examples/usb_device_composite_hid_audio
Documents and Videos | Description |
---|---|
AN12570 Using SLCD controller on K32L2B3 MCU | Describes the usage of the on-chip SLCD controller by enabling an SLCD device. |
Several examples, demos and drivers are available within the SDK to help you get started. A common example for display and graphics is listed below.
How to use the SLCD driver.
Path: <SDK_PATH>/boards/frdmkl46z/driver_examples/slcd
Want to learn more about using the FRDM-KL46Z? Check out our selection of training offerings ranging from online mini tech sessions to hands-on deep-dive training for help.
Documents and Videos | Description |
---|---|
Basic Application Development Using MCUXpresso IDE and MCUXpresso Config Tools | This three-part video series covers the basic interactions between the MCUXpresso IDE and Config Tools when working with either an imported SDK example project or creating a new one. |
Connect with other engineers and get expert advice on designing with the FRDM-KL46Z on one of our community sites.