Kinetis Software Development Kit Knowledge Base

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Kinetis Software Development Kit Knowledge Base

Labels

Discussions

Sort by:
Introducing Kinetis SDK v2 Kinetis SDK v2 is available on www.nxp.com/ksdk web page. Click on Build your SDK now to customize the KSDK based on your selection of device or evaluation hardware, RTOS, build system and more.   (Did you see the announcement of MCUXpresso IDE, SDK and Config Tools?  Kinetis SDKv2 is being renamed to MCUXpresso SDK and expanding to cover LPC devices as well.  Check out the MCUXpresso SDK webpage and Community for more information.)   What's New in Kinetis SDK v2? As was true for KSDK v1, v2 is a collection of comprehensive software enablement for NXP Kinetis Microcontrollers. It includes system startup, peripheral drivers, USB and connectivity stacks, middleware, and real-time operating system (RTOS) kernels. The Kinetis SDK also includes getting started and API documentation (online, PDF) along with usage examples and demo applications. However, v2 features several new components and improvements upon v1.   Note: The Kinetis SDK v2.0 Transition Guide provides more details about the differences and things to consider when moving from KSDK v1 to v2.   Updated Peripheral Drivers KSDK v2 eliminates the separate HAL and Peripheral Driver, replacing these two layers with a single driver for each peripheral. The single driver provides both the low-level functionality of the HAL and the non-blocking interrupt-based functionality of the Peripheral Driver. Peripheral drivers in KSDK v2 also eliminate external software dependencies on an OSA, Power Manager, and Clock Manager.  This makes the drivers easier to configure and more suitable for usage outside of the KSDK environment.   Simplified Folder Structure The folder structure of KSDK v2 has been simplified. The image below shows the folder structure for a KSDK v2 build for FRDM-K64F. The boards folder has been elevated to the top level and contains folders for all supported evaluation hardware. Specific board folders contain demo application, driver examples, middleware examples, and RTOS examples—all designed and tested to run on that specific board. The CMSIS folder contains the ARM® CMSIS vendor-independent hardware abstraction layers for Cortex®-M devices including CMSIS-CORE include files and CMSIS-DSP source and libraries.   The devices folder has also been elevated to the top level.  This folder contains sub-folders for each supported Kinetis MCU device.  KSDK v2 does not have a separate platform library.  All peripheral drivers can be found in the drivers folder contained within each device. Here you’ll find all the drivers for the given device.  This greatly simplifies include path requirements and makes it easy to determine which drivers apply to which devices.   You’ll also find middleware, and rtos folders at the top level that contain subfolders with source code for all middleware components and RTOS kernels supported.   RTOS Support One of the most notable changes in KSDK v2 is the focus on FreeRTOS.  All RTOS examples now use the FreeRTOS kernel.  Micrium μC/OS-II and μC/OS-III kernels are also pre-integrated into the KSDK (under an evaluation license).  RTOS peripheral driver wrappers for FreeRTOS and uC/OS-II & III are also provided that leverage native RTOS services (with no OSA).  These are provided for use as-is or as examples for how to integrate KSDK drivers and middleware with other Operating Systems.   The MQX kernel, stacks and middleware have been removed from the Kinetis SDK.  However, MQX Software is still a supported software suite from NXP that is available in the MQX RTOS and MQX for KSDK v1.3 products. New ports of MQX following the “Classic” architecture (i.e. similar style to MQX v4.x) will soon be available for newer Kinetis devices.  From here forward, the Kinetis SDK will focus on open-source RTOS solutions.   Middleware KSDK v2 features a few new and updated middleware packages. The USB stack is new and now offered under an open source, permissive license. lwIP and FatFS are retained as open source solutions or TCP/IP communications and filesystem support, respectively. There are also two optional cryptography packages, available separately, that have been pre-integrated and tested with the Kinetis SDK: wolfSSL and mbedTLS.   Supported Devices A complete list of support devices has been published in the new MCUXpresso Community.     Toolchain Support KSDK v2 supports the latest versions of: Kinetis Design Studio IAR Embedded Workbench Keil MDK Atollic TrueSTUDIO GNU GCC command line usin CMake   Project Generators Kinetis Design Studio (KDS) and Kinetis SDK v2 An update is available for KDS v3.x that adds a Kinetis SDK v2.x New Project wizard.  See this KDS Community post for details on installing the update.   Stand-alone KSDK Project Generator To quickly create new Kinetis SDK projects, or to clone existing projects, use the Kinetis SDK Project Generator   Configuration Tools Unlike KSDK v1, v2 does not have Processor Expert support available.  A new suite of configuration tools is being created that will build on KSDK v2 and will be rolled out throughout 2016.
View full article
Hi all,   Please find attached the new version of this document using KDS3.0 and KSDK1.2.0.   For more information about using Interrupts please see the following document from Jorge_Gonzalez Interrupt handling with KSDK and Kinetis Design Studio   For information about creating a new KSDK project with MQX please see the following document. How To: Create a New MQX RTOS for KSDK Project in KDS   For information about creating a new C++ project in MQX for KSDK1.2 please see the following document. How to Create a C++ Project Using MQX RTOS for KSDK1.2   For information about getting started with FreeRTOS and KSDK1.2 see the following document. How to: Create a New FreeRTOS for KSDS1.2 Project in KDS3.0     I hope it is useful.   Regards, Carlos Technical Support Engineer
View full article
This document will cover some of the most commonly asked questions about Kinetis Software Development Kit (Kinetis SDK). Anything requiring more in-depth discussion/explanation will be put in a separate thread. All new questions should go into their own thread as well. The variable KSDK_PATH is mentioned in several answers. This is the path into which Kinetis SDK was installed. With the current 1.2 release of Kinetis SDK, this would be equivalent to C:\Freescale\KSDK_1.2.0     What is the Kinetis Software Development Kit? Kinetis SDK is a free software framework that was created to make it easier for developers to create applications for Freescale’s line of Kinetis microcontrollers. It ensures there’s a common and thoroughly tested software framework for Kinetis devices that you can then use to build your application on top of. Let Kinetis SDK provide the basic startup code and drivers, so that you can spend more time creating your specific application code.   The two most significant features of Kinetis SDK are: Hardware Abstraction Layer (HAL) – A common API used to abstract hardware accesses into functional accesses Peripheral Drivers – High-level drivers that make use of the HAL API to implement higher level functionality for common peripheral use cases.   Additionally there are several other features: System Services – Code for utilizing specific Kinetis features which includes a clock manager, low-power manager, hardware timer, and interrupt manager ARM CMSIS Core and DSP standard libraries CMSIS compliant register header files Sample code for accessing accelerometers and audio codecs on Freescale evaluation boards Stacks and middleware for USB, Ethernet, and filesystems. Many examples and demo code to showcase how to use Kinetis SDK   This sounds great! Where can I download it and find more documentation and information? http://freescale.com/ksdk   How do I get started using Kinetis SDK? First read the Kinetis SDK 1.2 release notes to learn about the software. You will also want to check to make sure your Kinetis device is supported by Kinetis SDK. If you don't see your device in the KSDK 1.2 release notes, check to see if one of the stand-alone releases available includes it.   Once you’ve selected the appropriate installer for your device, either the mainline or one of the stand-alone releases, install it on your computer. The default path for the mainline Kinetis SDK 1.2 is C:\Freescale\KSDK_1.2.0 You will also need to install one of the compilers that Kinetis SDK supports. Kinetis Design Studio 3.0 IAR Embedded Workbench for ARM 7.40.2 MDK-ARM Microcontroller Development Kit (Keil) 5.14 ARM GCC 4.8.3 Atollic TrueSTUDIO for ARM 5.3 If you are not sure, we recommend starting with Kinetis Design Studio since it is free and also runs on Linux.   Then read the Getting Started with Kinetis SDK (KSDK) v1.2.pdf document. It can also be found in <KSDK_PATH>/doc. It will have details about Kinetis SDK and there will be a section for getting up and going with your particular IDE to run the hello_world demo application. Note that you will need to compile the Kinetis SDK platform library first before you can compile the demos.   You can then run one of the other demo applications included with Kinetis SDK to see examples of how to use the HAL and Driver APIs.   If you are using Kinetis Design Studio, also make sure to follow the directions in Appendix A of this document to update Kinetis Design Studio to work with Kinetis SDK: https://community.freescale.com/docs/DOC-102612   How do I run the demo projects that are included with Kinetis SDK? First read the Getting Started with Kinetis SDK (KSDK) v1.2.pdf document. You will need to import and compile the KSDK platform library, and then import and compile the particular demo project.   Where can I find specific instructions on a particular demo? For details on a specific demo, including any board jumper settings and to check if the demo will run on your particular board, refer to the Kinetis SDK v1.2 Demo Applications User's Guide.pdf found in the <KSDK_PATH>/doc folder.   How does Kinetis SDK fit in with other Freescale enablement? Kinetis SDK is a key component going forward in all Freescale Kinetis enablement. It replaces the bare-metal sample code examples. Freescale’s MQX RTOS will now use KSDK drivers for supported devices, instead of the classic MQX-specific drivers. And it will use the KSDK startup and board support code.   Processor Expert, a GUI tool for software configuration and code generation, now uses the KSDK HAL and Drivers to implement its code for KSDK supported devices. And the mbed platform also uses Kinetis SDK underneath for devices supported by Kinetis SDK.   Kinetis SDK Details:   What exactly am I getting when I download and install Kinetis SDK? The default installation path for KSDK 1.2 is at C:\Freescale\KSDK_1.2.0   Inside that directory, you’ll find the full source code for the various KSDK components (HAL, drivers, system services, header files, etc) as well as demos, documentation, and higher level stacks like our USB stack, lwIP, FatFS, and various RTOS kernels.   Some of the key directories are: examples – SDK examples and demos doc - Documentation lib – SDK libraries projects, and where the compiled library .a files are generated platform – SDK driver and HAL source code, linker files, and startup code   Section 5 of the Kinetis SDK v1.2 release notes lists the different components and where they are located in the Kinetis SDK directory structure.   What Kinetis devices/boards are supported by Kinetis SDK? In KSDK 1.2, the following boards are supported: FRDM-K22F FRDM-K64F FRDM-KL02Z FRDM-KL03Z FRDM-KL27Z FRDM-KL43Z FRDM-KL25Z FRDM-KL26Z FRDM-KL46Z FRDM-KW24 MRB-KW019032xx TWR-K21D50M TWR-K21F120M TWR-K22F120M TWR-K24F120M TWR-K60D100M TWR-K64F120M TWR-K65F180M TWR-KL43Z48M TWR-KV10Z75M TWR-KV31F120M TWR-KV46F150M TWR-KW24D512 USB-KW24D512   Kinetis SDK also supports many of the subfamiles that these boards support. So for instance, if you're interested in the K02 device, use the FRDM-K22F for evaluation but use the K02 libraries provided to write code which will run on the K22F since it is a superset device. The subset devices supported are all listed in the Release Notes.   The KSDK 1.2 release can be found at http://freescale.com/ksdk   Which version of Kinetis SDK do I install? I see that there are Mainline and Standalone Releases. What's the difference? If the device you are interested in is listed in the previous question, download the Mainline release appropriate for your computer (Windows/Linux/Mac).   If your device is listed as a Standalone install, you just need to use that Standalone installer. These are releases for new devices that did not make into KSDK 1.2 but will be rolled into later releases. Note that installing "Kinetis SDK Mainline 1.2" is not a pre-requisite as these truly are 'standalone' releases and include all the standard KSDK features and code: KL33Z for the FRDM-KL43Z   These standalone releases can be found under the Downloads tab on the KSDK website. You may need to select "All Downloads" to see them.   How do I determine if my particular Kinetis device is supported by Kinetis SDK and which board it is associated with? Section 4, “Supported Development Systems”, of the Kinetis SDK release notes lists the specific Kinetis devices that are supported by that release of Kinetis SDK. The table can also be used to determine which evaluation board is associated with your particular Kinetis device. Each of the stand-alone releases will also have their own table like this in their release notes.   When will device XYZ be supported by KSDK? Most new Kinetis devices will launch with Kinetis SDK support. Support for some older Kinetis devices will be added over time in new releases. Those older devices selected for porting will be announced on the Community once a release date is confirmed. In the meantime, use the bare-metal sample code and MQX support already available for those legacy devices.   I don’t see my device in either the Kinetis SDK 1.2 release or the stand-alone releases. Can I just port Kinetis SDK to my device? There are several key components that would be missing to do a port to a different family, like header files and start up files, and thus it is discouraged and is not supported by Freescale. Support for some older Kinetis devices is being added in future releases, and most Kinetis devices released in the future will have Kinetis SDK support at launch.   What compilers are supported by Kinetis SDK? In Kinetis SDK 1.2 the following compilers are supported: Kinetis Design Studio 3.0 IAR Embedded Workbench for ARM 7.40.2 MDK-ARM Microcontroller Development Kit (Keil) 5.14 ARM GCC 4.8.3 Atollic TrueSTUDIO for ARM 5.3   Kinetis Design Studio and ARM GCC are code sized unlimited and will also run on Linux. If you do not already have a preferred compiler, we recommend starting with Kinetis Design Studio.   What exactly is the HAL? The Hardware Abstraction Layer (HAL) creates an abstraction layer for hardware accesses.  For example, instead of digging into a reference manual to figure out which bit in which register bit is used to enable the UART transmit feature, you can just call UART_HAL_EnableTransmitter(…). The HAL is stateless and is intended to cover the entire hardware functionality.   Where is the source code for the HAL? You can find the source for the HAL at <KSDK_PATH>\platform\hal.   For a good example of how the HAL is implemented, look at the <KSDK_PATH>\platform\hal\src\dspi\fsl_dspi_hal.c and <KSDK_PATH>\platform\hal\inc\fsl_dspi_hal.h files. Notice how most of the HAL API is just macros for accessing the SPI registers, or else simple functions for calculating the baud rate and other simple features like that.   Is there a library for the HAL that I can pull into my project? There is a device and compiler specific library available that you can pull into your own custom project at <KSDK_PATH>\lib\ksdk_hal_lib.   You will need to compile the library first as KSDK does not come with pre-compiled libraries.   What are the peripheral drivers? The peripheral drivers are built on top of the HAL to provide a set of easy-to-use interfaces to handle high-level data and stateful transactions. They cover the most common use-cases, but may need to be optimized for your particular application.   Where is the source code for the drivers? You can find the source for the KSDK drivers at <KSDK_PATH>\platform\drivers.   For a good example, take a look at <KSDK_PATH>\platform\drivers\src\dspi\fsl_dspi_master_driver.c. You can see how the driver API is implemented by making calls to the HAL API and using structures defined by the SPI driver.   Is there a library I can pull into my project to use the drivers? The KSDK Platform library contains both the drivers and the HAL. This is the library most of the KSDK demo projects pull in. Device and compiler specific project files for this library can be found at <KSDK_PATH>\lib\ksdk_platform_lib   You will need to compile the library first as KSDK does not come with pre-compiled libraries.   Where are the HAL and Driver APIs documented? The Kinetis SDK API Reference Manual describes all the HAL and Driver APIs, and it can be found in the <KSDK_PATH>/doc folder.   How do I create my own Kinetis SDK application? The easiest way is to copy an already existing project. However if you are using Kinetis Design Studio, you can also create one from scratch using the New Project Wizard.   To copy an already existing demo project, see this thread: Create new KSDK Projects   To create a totally new project with Kinetis Design Studio, see this thread: Writing my first KSDK Application in KDS - Hello World and GPIO Interrupt   To create a MQX project that works with Kinetis SDK, see this thread: How To: Create a New MQX RTOS for KSDK Project in KDS   A full featured KSDK project creation tool is under development and should be released in Q2 2015.   Where can I find information on the Kinetis SDK low power manager? See this thread: Low Power Application Using the SDK (Note: The demo was created for KSDK 1.0)   What changed between KSDK 1.0 and KSDK 1.1? See this thread: KSDK 1.1 Release   What changed between KSDK 1.1 and KSDK 1.2? See this thread: New KSDK 1.2. is available!   Can I install a new version, or standalone version, of KSDK without it affecting my already existing version? Yes. Each new release of KSDK, including standalone releases, will be installed into a unique directory. The only thing to be aware of is the (optional) update the global Windows KSDK_PATH variable used by Kinetis Design Studio. See Appendix B of this document: Writing my first KSDK Application in KDS - Hello World and GPIO Interrupt   Do I need to recompile the platform library every time I change my demo application? After the initial compilation, you will only need to recompile the platform library for your device if you change something in the HAL, Drivers, or other source code that makes up the platform library. The platform project is included as part of the workspace when opening up a demo as a convenience for that initial compile. If you only change the code for the demo application, you do not have to recompile the platform library every time.   Is there training available for Kinetis SDK? There are some presentations at the Designing with Freescale event webpage: http://www.freescale.com/webapp/Download?colCode=DWF14_AMF_SDS_T0127 http://www.freescale.com/webapp/Download?colCode=DWF14_AMF_SDS_T0805   Also make sure to read through the Kinetis SDK 1.2 Release Notes as there is a lot of very useful information in there as you get started using Kinetis SDK.   Many more app notes and community posts are being created to further showcase how to use Kinetis SDK.   RTOS:   Does Kinetis SDK supports RTOSs? Yes. Several different RTOS kernels can be ran on top of Kinetis SDK. This was done to solve the biggest trouble of porting a particular RTOS to a new device, in that new drivers and startup code needs to be developed. Kinetis SDK provides that solution, so that the RTOS kernel features can sit on top of Kinetis SDK.   What RTOS kernels are supported with Kinetis SDK? Freescale MQX FreeRTOS Micrium uCOSII Micrium uCOSIII   How do I get these RTOSs with Kinetis SDK? Starting with Kinetis SDK 1.2, all the RTOSs are included by default with the installation.   If using Kinetis SDK 1.1, during installation process, there will be a screen asking if you would like to install 'Kinetis SDK Basic', 'KSDK+MQX', or 'KSDK+RTOS Kernels'. If you are only interested in MQX, use the middle option. If you are interested in other RTOS kernels (including MQX) select the last option which will take you to a new screen to select which RTOSes you are interested in.   If using Kinetis SDK 1.0, you must select the "Custom" option during installation to select a RTOS kernel.   Why don’t I have an <KSDK_PATH>/rtos folder? Where are the RTOS kernels at? See the above answer. You will need to run the KSDK installer again, select to modify the installation, and this time select an RTOS install option.   What else do I get when selecting the MQX RTOS option? When selecting the MQX RTOS option, the MQX RTCS Ethernet stack and MQX MFS Filesystem stack will be installed as well. These are more fully featured stacks than the 'lwIP' and 'FatFS' stacks provided by default with Kinetis SDK. These RTCS and MFS stacks require MQX to run, and full source code is provided.   What is the difference between MQX for KSDK and 'classic' MQX 4.2? MQX for KSDK is the future of MQX, and it was developed to leverage Kinetis SDK features like startup code and drivers. The biggest difference is the drivers, as MQX for KSDK uses the KSDK drivers which are significantly different than the classic MQX drivers. The startup code is also different as MQX for KSDK relies on the KSDK startup files. However the kernel API and how to you start and manipulate tasks, semaphores, events, etc, are the same between the two versions.   A full porting guide between classic MQX and MQX for KSDK is now available.   How can I learn how to create a new MQX for KSDK project for Kinetis Design Studio? A tutorial can be found here   Where can I find more information on MQX for KSDK? http://freescale.com/mqx/ksdk Beta version of MQX RTOS for Kinetis SDK - Now Available MQX with KSDK and Processor Expert   What is the OSA? The Operating System Abstraction (OSA) layer is an optional feature that allows a user application to use the same API regardless of which RTOS is being used. This can be used to make code more portable. An example of this can be found in the <KSDK_PATH>/demos/i2c_rtos demo, which uses almost the exact same source code to do a demo using I2C communication when using baremetal, MQX, FreeRTOS,  uCOSII, or uCOSIII.   Do I have to use the OSA? No, it is optional. You can always call the particular RTOS API directly. For example, if you were using the MQX kernel, you have the option to call either the OSA API call for a time delay (OSA_TimeDelay) or the MQX API call (_time_delay).   You can see how the OSA layer implements the OSA_TimeDelay() function for MQX by opening the file <KSDK_PATH>\platform\osa\src\fsl_os_abstraction_mqx.c, and on line 662 you’ll see that all the OSA is doing is calling MQX’s own _time_delay() API.   Note that some drivers make use of the bare-metal OSA implementation for certain functionality (like delays or semaphores).   USB:   What USB stack is included with Kinetis SDK? The USB stack is developed by Freescale and is a continuation of the 5.0 Beta bare-metal stack. The stack in Kinetis SDK has more features, and Kinetis SDK is where USB development work will be focused in the future.   You may also see it referenced as the “Unified USB stack” since this same USB stack is used by both bare-metal KSDK and by MQX for KSDK. This makes it simpler to add RTOS support to an already existing USB application.   What classes does the Kinetis SDK USB stack support? It supports Audio, CDC, HID, MSD, and PHDC classes in both Host and Device modes. Some composite class support is also provided.   How do I compile a USB demo? There are two libraries that need to be compiled before a USB demo will compile properly. Host or Device USB Library at <KSDK_PATH>\usb\usb_core\<host or device>\build\<compiler>\<board>\ KSDK Platform library at <KSDK_PATH>\lib\ksdk_platform_lib\   Then one of the USB demos can be compiled at <KSDK_PATH>\usb\example\<host or device>\<class>\<example project>   Troubleshooting:   I’m seeing an error about missing a missing ksdk_platform_lib.a or libksdk_platform.a file when I try to compile a demo There are two common cases where this happens:   1) You must first compile the KSDK platform library for your device. The project files for the library are found in <KSDK_PATH>/lib/ksdk_platform_lib/<compiler>/<device>/   2) Make sure the KSDK platform library you compiled is for the same target (Debug or Release) as the demo you are trying to compile. The Debug target has no optimization. The Release target uses full optimization.   Why is the “Kinetis SDK” checkbox unavailable when creating a new project in Kinetis Design Studio using the ‘Kinetis Design Studio Project’ Wizard? This checkbox is only selectable if the device you selected on the previous screen is supported by Kinetis SDK.   Also make sure to follow the directions in Appendix A of this document to update Kinetis Design Studio to work with Kinetis SDK. You will need to update KDS with the KSDK 1.2 file to get the boards supported by KSDK 1.2 in the project wizard: Writing my first KSDK Application in KDS - Hello World and GPIO Interrupt   I’m trying to use a driver and keep falling into the default ISR in startup_<mcu>.s Make sure to include an interrupt handler for the peripheral you’re using inside your project. By default, all the peripheral IRQ handlers go into a default handler that does an infinite branch. The easiest way to fix this issue is to add the C:\Freescale\KSDK_1.2.0\platform\drivers\src\<drivername>\fsl_<drivername>_irq.c file inside your project.   How do I change the default interrupt priority for a driver? Use the CMSIS NVIC_SetPriority function.  As an example from the i2c_rtos demo: NVIC_SetPriority(I2C0_IRQn, 6U);   I’m using a FRDM-KL03 and none of the KDS projects work Due to the small RAM size of the KL03, the default toolchain in Kinetis Design Studio needs to be swapped out for the ARM GCC toolchain. Instructions are in the appendix of the “Kinetis SDK Freescale Freedom FRDM-KL03Z Platform User’s Guide.pdf” found in the KSDK KL03 installation inside the /doc folder.   I'm using IAR and I get the following error when I try to compile: Fatal Error[LMS001]: License Check failed. Use the IAR License Manager to resolve the problem. Found no license for ARM EW.MISRAC[LicenceCheck:2.13.4.627,RMS 8.5.0.0021, Feature ARM.EW.MISRAC, Version 1.05]. The specified license feature is needed to enable MISRA-C support. This error occurs because the IAR projects are setup by default to enable MISRA-C checking, as KSDK is MISRA compliant. However the evaluation version of IAR doesn't support MISRA checking. To work-around this issue, right click on the project name that is giving the error, and select "Options...". Then under the "General Options" category, scroll over to the the tab on the far right that says "MISRA-C 2004". Then uncheck the box that says "Enable MISRA_C"   I'm seeing errors when using the SPI driver. What is the difference between the DSPI and SPI drivers? See this thread   The I2C_RTOS demo isn't compiling properly. It says it is missing libksdk_platform_mqx.a (or some other library). What libraries do I need to compile for the I2C RTOS demo? See this thread   I don't see any terminal output when using the power_manager_demo demo. You need to adjust the baud rate of the terminal to 9600 due to some clock speed limitations necessary for this demo. See the \doc\Kinetis SDK v.1.2 Demo Applications User's Guide.pdf for more details.   I don't see any terminal output when using some of the FRDM-KL03 demos. The following KL03 demos use a baud rate of 9600 due to some clock speed limitations necessary for those particular demos: flash_demo lptmr_demo power_manager_demo rtc_func See the \doc\Kinetis SDK v.1.2 Demo Applications User's Guide.pdf for more details.   I’m seeing odd compile errors in Kinetis SDK, what could be going on? If using KSDK 1.0 or KSDK 1.1, double check that the KSDK_PATH environment variable in Windows is pointing to the current installation of Kinetis SDK you’re trying to use. KSDK 1.2 does not make use of this environmental variable anymore. For details see Appendix B of this document Writing my first KSDK Application in KDS - Hello World and GPIO Interrupt   Where can I find a document of known issues? Known issues can be found in the Kinetis SDK 1.2 Release Notes.   Additional issues found after the Kinetis SDK release can be found in the Kinetis SDK Software Errata document, if one is needed, on the “Documents” tab of the KSDK webpage.   Updated Jun-2015 for KSDK 1.2 Release.
View full article
Hello KSDK team!   I created helpful tutorial, how to install new version of KSDK.   1) Go to www.nxp.com/ksdk and click to Download button 2) Now choose the Kinetis SDK v2 & v1.3 click Download button 3) At the moment you are redirected to the Kinetis Expert Site, please go to Build an SDK 4) Please, sign in and click Sign in 5) Select MCU for the work and click Select Configuration 6) Selected MCU is supported by KSDK 2.0, you can download the package, choose the toolchain and Operation System. (Also you can add µC/OS-II and µC/OS-III to your package), click on Build SDK Package 7) Done, check Software Vault tab 😎 Please, go to Preferences 9) Please, fill the Preferences and don´t forget Save 10) After successful filling Preferences you are able to see the package in the window 11) Read the Software Terms and Conditions and agree with them 12) Save the package and you can start with KSDK 2.0   SDK API Documentation v.2.0 is located Kinetis SDK 2.0 API Reference Manual: Introduction Enjoy KSDK 2.0!   All feedbacks are very welcome!   Best Regards, Iva
View full article
This article is for beginners. It describes how to create an FreeRTOS project based on MCUXpresso IDE 10.2.1. Software and Tools In this article, I’m using the following: MCUXpresso IDE 10.2.1   www.nxp.com/mcuxpresso ,  MCUXpresso SDK 2.4.1 for  Frdm-k66f  board.  With Amazon FreeRTOS v10 .You can get it from https://mcuxpresso.nxp.com FRDM-K66 board www.nxp.com/frdm-k66f Before creating a FreeRTOS project, you have to install SDK first. Download the SDK package SDK_2.4.1_FRDM-K66F.zip,  drag and drop it into the “Installed SDKs” view. You will be prompted with a dialog asking you to confirm the import –click OK. The SDK will be automatically installed into MCUXpresso IDE part support repository. Quick Start Go to the ‘QuickStart’ Panel in the bottom left of the MCUXpresso IDE window, and click new project. On the “Board and/or device selection” page, select board frdmk66f. You will see some description relating to the your selection. Click ‘next’… You will see the basic project creation and setting page. Basic setting The project will be given a default name based on the MCU name. Name the project, select the right device package. Board files: This field allows the automatic selection of a default set of board support files, else empty board files will be created. Project type:  Selecting ‘C’ will automatically select Redlib libraries, selecting c++ will select NewllibNaro librarires. Project option: enable semihost will cause the semihost variant of the chosen library to be selected;  CMSIS-Core will cause a CMSIS folder containing a variety of support code to be created. OS: For a FreeRTOS project, make sure FreeRTOS is selected. Please select the drivers and utilities according to your requirements. Click ‘next’, you will go to advanced project settings page. Advanced Project setting This page will take certain default options based on settings from the first wizard project page. Set library type:    Please use Redlib for C projects, and NewlibNarno for SDK C++ projects. Next panel allows options to be set related to Input/Output. Hardware settings: set options such as the type of floating point support available/required. MCU C compiler:  Set various compiler options Click ‘finish’ will create a simple ‘hello world’ C project for Freedom K66f . Basically does the initialization of the pins, clocks, debug console and peripherals. int main(void) {          /* Init board hardware. */     BOARD_InitBootPins();     BOARD_InitBootClocks();     BOARD_InitBootPeripherals();        /* Init FSL debug console. */     BOARD_InitDebugConsole();       PRINTF("Hello World\n");       /* Force the counter to be placed into memory. */     volatile static int i = 0 ;     /* Enter an infinite loop, just incrementing a counter. */     while(1) {         i++ ;     }     return 0 ; } Click the project settings, we can see some basic information of this project, a right click on these nodes provides direct options to edit the associated setting. Add FreeRTOS task #include <stdio.h> #include "board.h" #include "peripherals.h" #include "pin_mux.h" #include "clock_config.h" #include "MK66F18.h" #include "fsl_debug_console.h" /* TODO: insert other include files here. */   /* FreeRTOS kernel includes. */ #include "FreeRTOS.h" #include "task.h"     /* TODO: insert other definitions and declarations here. */           /* Task priorities. */ #define my_task_PRIORITY (configMAX_PRIORITIES - 1) /*******************************************************************************  * Prototypes  ******************************************************************************/ static void my_task(void *pvParameters);     /*!  * @brief Task responsible for printing of "Hello world." message.  */ static void my_task(void *pvParameters) {     for (;;)     {         PRINTF("Hello World!\r\n");         vTaskSuspend(NULL);     } }       /*  * @brief   Application entry point.  */ int main(void) {          /* Init board hardware. */     BOARD_InitBootPins();     BOARD_InitBootClocks();     BOARD_InitBootPeripherals();        /* Init FSL debug console. */     BOARD_InitDebugConsole();       if (xTaskCreate(my_task, "my_task", configMINIMAL_STACK_SIZE + 10, NULL, my_task_PRIORITY, NULL) != pdPASS)     {         PRINTF("Task creation failed!.\r\n");         while (1)             ;     }     vTaskStartScheduler();       /* Enter an infinite loop, just incrementing a counter. */     while(1) {       }     return 0 ; } Run the application Build your application, go to menu Project > Build Project. Alternatively go to the quick start panel and click the hammer button. Go to menu Run> Debug configurations… Select the ‘Debug configuration’ that matches your connection type, in this example Segger Jlink is used. Then click ‘Apply’ and ‘Debug’ Open a terminal, select the appropriate port and set baudrate to 115200 Run the application, you will see “Hello world” in terminal   For information about configuring with MCUXpresso pins tool in an FreeRTOS project, please see the following document https://community.nxp.com/docs/DOC-341987   For information about configuring with MCUXpresso peripheral tool in an FreeRTOS project, please see the following document. https://community.nxp.com/docs/DOC-341986
View full article
Hello KSDK community:   The Kinetis Software Development Kit is intended to ease evaluation, prototyping and development with Kinetis MCUs. Apart from the Peripheral Drivers, HAL layer, System Services, RTOS abstraction and software stacks, KSDK implements a robust hardware interrupt mechanism.   The attached document is intended to explain the interrupt handling mechanism of KSDK platform and how to use it for baremetal KSDK or "MQX for KSDK" projects. Some of the topics covered are:   >> Interrupt manager >> Installing vector table in Flash or RAM >> Interrupt priorities >> Peripheral IRQ files (fsl_<peripheral>_irq.c) >> Installing, defining or registering ISRs >> Callbacks >> MQX hardware interrupts system >> Interrupts and callbacks with Processor Expert   The last chapter explains the considerations of interrupt handling when using Kinetis Design Studio in 4 different cases:   1) KSDK baremetal project 2) KSDK baremetal + Processor Expert project 3) MQX for KSDK project 4) MQX for KSDK + Processor Expert project   I hope this document is useful for all of you who have already adopted KSDK as development solution.     /*** UPDATE July 1, 2015 ***/   Document updated for KSDK v1.2 and KDS v3.0.0     Regards! Jorge Gonzalez
View full article
Kinetis SDK is a new complimentary software offering from Freescale for Kinetis microcontrollers. The Kinetis software development kit (SDK) provides an extensive suite of robust peripheral drivers, stacks, middleware and example applications designed to simplify and accelerate application development on Kinetis MCUs. The addition of Processor Expert technology for software and board support configuration provides unmatched ease of use and flexibility. The Kinetis SDK includes full source code under a permissive open-source license for all hardware abstraction and peripheral driver software.   Kinetis SDK can be downloaded from the following location: http://freescale.com/ksdk   This document goes over the basics of starting with Kinetis SDK and common troubleshooting tips.   Getting Started with Kinetis SDK and FRDM-K64F The FRDM-K64F is a fully featured Freescale Freedom board with a 120MHz Cortex M4 based Kinetis K64 MCU. The board also features Arduino hardware compatibility, an accelerometer and magnetometer (Freescale’s FXOS8700CQ), and push buttons/LEDs, plus an Ethernet port, microSD port, and OpenSDAv2 for debugging.   First download and install the latest release of Kinetis SDK from http://freescale.com/ksdk   Then select one of the five IDEs that Kinetis SDK supports: Kinetis Design Studio 2.0 IAR Embedded Workbench for ARM 7.20.2 MDK-ARM Microcontroller Development Kit (Keil) 5.11 ARM GCC 4.8.3 Atollic TrueSTUDIO for ARM 5.2 Note that Kinetis Design Studio and ARM GCC are code sized unlimited and will also run on Linux.   Then take a look at the documentation in the /doc folder, in particular the Release Notes and the Getting Started with Kinetis SDK (KSDK) documents. The Release Notes contain an overview of Kinetis SDK, supported devices, details on the directory structure, and known issues.   Also note the basic Kinetis SDK directory structure. More details can be found in the Release Notes: demos – SDK examples and demos boards –board specific files lib – where the compiled SDK libraries reside platform – SDK driver and HAL source code, linker files, and startup code     Since all the examples are in the demos folder, check out the “hello_world” project at \demos\hello_world\<ide>\frdmk64f\hello_world.eww of it for a simple hello world type app. Use the Getting Started with KSDK Guide for details on how to compile and run the demo for your particular IDE.   Also check out the Kinetis SDK FAQ for information on other boards supported by Kinetis SDK, MQX RTOS and other RTOS support, USB support with KSDK, and much much more.   Debugging Kinetis SDK on FRDM-K64F: Typically, debugging is done via the OpenSDAv2 circuit built onto the FRDM-K64F board. Make sure to use the USB connector to the left of the Ethernet port, J26. By default the FRDM-K64F uses the CMSIS-DAP/mbed interface as the debug protocol. However it is also possible to use the P&E Micro or Segger JLink debug interfaces with the board instead.   Debugging with CMSIS-DAP/mbed Interface: The FRDM-K64F board uses the CMSIS-DAP/mbed interface by default as it is using OpenSDAv2. The KSDK 1.1 demo projects should be setup to use the CMSIS-DAP debug interface by default for the FRDM-K64F projects.   Debugging with P&E Micro Interface: To debug using the P&E Micro interface, the P&E Micro OpenSDAv2 app needs to be loaded onto the OpenSDAv2 circuit. Instructions for loading and using this app are in Appendix C of the Getting Started with KSDK Guide. Use the DEBUG_K64F_MBED_PEMICRO_V108.BIN file that came inside the Kinetis SDK zip file. If you want to return to the original CMSIS-DAP/mbed interface, you can find a binary app to drag-and-drop onto the OpenSDAv2 bootloader on the FRDM-K64F mbed page. Firmware FRDM K64F - Handbook | mbed   Troubleshooting: I’m using the CMSIS-DAP/mbed debug interface with IAR, and I can’t connect to my board anymore with an error: “Fatal error: Probe not found. Session aborted!”: There’s an issue as described in the Kinets SDK release notes where the debugger can become non-responsive if the code is allowed to exit the main() function when using the CMSIS-DAP interface with OpenSDAv2.   To recover the board you have a few options: Load the P&E Micro interface app onto OpenSDAv2, and then flash a known good program The board should still enumerate as a mass storage device, and you can drag-and-drop a known good program onto the board. You may have to hit the reset button a few times to get it to properly enumerate though. A known good hello_world program has been attached to this post.   This will be fixed in future versions of the CMSIS-DAP/mbed interface app. In the meantime, make sure to put a while(1) loop in your code before exiting main(). Also check out the blog entry on this issue on MCU on Eclipse   The serial port is not enumerating: If using the default CMSIS-DAP/mbed interface, you must first install the mbed Windows serial port driver before it will enumerate on Windows properly. It should work in Mac OS and Linux without a driver.   When I start debugging, I get an error message that says “Undected. Disconnect/Connect USB cable. Click Refresh List”: The likely problem is that the FRDM-K64F has the default CMSIS-DAP/mbed firmware, and your project is trying to use the P&E Micro or JLink interface. Change the debug interface in your IDE to use CMSIS-DAP. Or else change the firmware in the OpenSDAv2 circuit to the proper firmware as described in Appendix C of the Getting Started with KSDK document.   When compiling the Kinetis SDK platform library in IAR 7.10.x, I the following error messages: Error[Pm056]: all if, else if constructs should contain a final else clause (MISRA C 2004 rule 14.10): This is caused by a MISRA C 2004 rule violation. The beta Kinetis SDK was built using IAR 6.70, but the MISRA C checks were changed when IAR moved to 7.10.x which is why this comes up in IAR 7.10.x.   This error can be fixed by disabling MISRA C checking in the project settings.   Right click on the platform_lib project, and under the General Options category, scroll over (using the arrow keys on the right) to the MISRA-C-2004 tab, and uncheck “Enable MISRA-C”.   When debugging with the P&E Micro OpenSDAv2 app, I get an error that says “Error reading data from OpenSDA hardware. E17925” This is being investigated and seems to affect IAR 7.10.x and CW10, but not earlier versions of IAR. In the meantime, use the CMSIS-DAP/mbed interface app instead.
View full article
Hi all Kinetis lovers,   Freescale has launched the Kinetis SDK and I believe this is a great opportunity for us to start our new applications using these drivers. The information contained on this post will show you how to use the SPI drivers based on simple master and slave examples.   The examples attached here were developed for KDS IDE using KSDK. To build and run the example you may need to consider the following: Install KSDK: You need to have  KSDK v1.1.0 installed on your machine. You can find it HERE. Build the KSDK library and import the examples: In the KSDK install folder go to the doc folder and look for the Getting Started with Kinetis SDK (KSDK) document. Follow the instructions of the section 5 Run a demo using Kinetis Design Studio IDE. To know how to build and import projects. If you have further question you may find useful information in this posts: OpenSDAv2 Complete information for the OpenSDA v2. Writing my first KSDK1.2 Application in KDS3.0 - Hello World and Toggle LED with GPIO Interrupt excellent post from colleague Carlos_Musich   I hope you can benefit from this post.   If you have questions please let me know   If this post was useful for you do not hesitate to click the Like button.   Best Regards, Adrian Sanchez Cano Technical Support Engineer  
View full article
LwIP is a small independent implementations of the TCP/IP protocol suite that has been initially developed by Adam Dunkels . The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM.  Currently LwIP 2.1.2 is ported to Kinetis and I.MX RT families in MCUXpresso SDK 2.6 . Features: LwIP comes with the following protocols: IPv4 and IPv6, including packet forwarding over multiple network interfaces. ICMP for network maintenance and debugging IGMP for multicast traffic management MLD (Multicast listener discovery for IPv6).  ND (Neighbor discovery and stateless address autoconfiguration for IPv6) DHCP and DHCPv6. UDP (User Datagram Protocol) TCP (Transmission Control Protocol) Raw/native API for enhanced performance Optional Berkeley -  like socket API. TLS: optional layered TCP for nearly transparent TLS for any TCP-based protocol PPPoS and PPPoE DNS (Domain name resolver incl. mDNS) 6LoWPAN Organization of the LwIP stack Let’s take SDK_2.6.1_EVKB-IMXRT1050 for example, LwIP code in under SDK_2.6.1_EVKB-IMXRT1050\middleware\lwip Port: This folder includes the adapter code which can make the LwIP stack run on the bare metal and FreeRTOS. Enet_ethernetif.c/h: Adapt the LwIP stack to the underlying MCUXpresso SDK ethernet driver, provides ethernet interfaces , like  phy init and  ethernetif_input. cc.c/h: provide typedefs, compiler hints for packing and platform specific diagnostic output. Perf.h: architecture specific performance measurement, current the definitions is NULL, reserve for future use. Src: This folder includes the latest stable LwIP 2.1.2 source code which can be downloaded from below link download.savannah.gnu.org/releases/lwip/ --api: netconn and socket API files --core: LwIP core files --include: LwIP include files --netif:  network interface files LwIP APIs overview LwIP provides three application programming interfaces (API) for programmers to use for communication with the TCP/IP code: Raw APIs:   Non thread-safe APIs, callback style for maximum performance and minimum memory footprint. Program execution is driven by callbacks functions, which are then invoked by the lwIP core when activity related to that application occurs. A particular application may register to be notified via a callback function for events such as incoming data available, outgoing data sent, error notifications, poll timer expiration, connection closed, etc. An application can provide a callback function to perform processing for any or all of these events. Sequential-style APIs:    blocking functions. More overhead, but can be called from any thread except TCPIP thread. The sequential API provides a way for ordinary, sequential, programs to use the lwIP stack. It is quite similar to the BSD socket API. The model of execution is based on the blocking open-read-write-close paradigm. Since the TCP/IP stack is event based by nature, the TCP/IP code and the application program must reside in different execution contexts (threads). Socket API: BSD-style socket API.  The socket API is a compatibility API for existing applications, currently it is built on top of the sequential API. It is meant to provide all functions needed to run socket API applications running on other platforms. TCP Raw API   API function Description TCP connection setup   tcp_new() Creates a new TCP PCB tcp_bind() Binds a TCP PCB to a local IP address and port tcp_listen() Starts the listening process on the TCP PCB. tcp_accept() Assigns a callback function that will be called when a new TCP connection arrives. tcp_connect() Used to connect to a remote TCP host. Sending TCP data tcp_write() Queues up data to be sent. tcp_output() Forces queued data to be sent tcp_sent() Assigns a callback function that will be called when sent data is acknowledged by the remote host. Receiving TCP data tcp_recv() Sets the callback function that will be called when new data arrives. tcp_recved() Must be called when the application has processed the incoming data packet (for TCP window management). Application polling tcp_poll() Assigns a callback functions that will be called periodically. It can be used by the application to check if there is remaining application data that needs to be sent or if there are connections that need to be closed. Closing and aborting connections tcp_close() Closes a TCP connection with a remote host. tcp_abort() Aborts a TCP connection. tcp_err() Assigns a callback function for handling connections aborted by the lwIP due to errors (such as memory shortage errors). UDP Raw API API Description udp_bind Binds a UDP PCB with a local IP address and port. udp_new Creates a new UDP PCB. udp_send Sends UDP data. udp_recv Specifies a callback function which is called when a datagram is received udp_remove Removes and de-allocates a UDP PCB. udp_connect Sets up a UDP PCB remote IP address and port udp_disconnect Removes a UDP PCB remote IP and port. Netconn API netconn_new Creates a new connection netconn_listen Sets a TCP connection into a listening mode netconn_write Sends data on a connected TCP netconn netconn_accept Accepts an incoming connection on a listening TCP connection netconn_close Closes a TCP connection without deleting it. netconn_send Sends data to the currently connected remote IP/port (not applicable for TCP connections). netconn_bind Binds a connection to a local IP address and port. netconn_recv Receives data from a netconn. netconn_connect Connects to a remote IP address and port. …   Socket API Macro API description accept lwip_accept Accepts a new connection on a socket bind  lwip_bind Binds a socket to an IP address and port shutdown  lwip_shutdown   getpeername  lwip_getpeername   getsockname lwip_getsockname   setsockopt lwip_setsockopt   closesocket  lwip_close   connect lwip_connect Connects a socket to a remote host IP address and port. listen  lwip_listen Listens for socket connections recv  lwip_recv   recvmsg lwip_recvmsg   recvfrom  lwip_recvfrom   send  lwip_send   sendmsg  lwip_sendmsg   sendto lwip_sendto   socket  lwip_socket Creates an new socket. poll lwip_poll   ioctlsocket lwip_ioctl   inet_ntop  lwip_inet_ntop   inet_pton  lwip_inet_pton   read  lwip_read Reads data from a socket readv lwip_readv   write lwip_write Writes data on a socket writev lwip_writev   close  lwip_close Closes a socket (socket is deleted). fcntl  lwip_fcntl   ioctl lwip_ioctl         LwIP Configure Configuration file is placed in application source folder: Lwipopts.h: Lwipopts.h is a user file that you can use to fully configure LwIP and all of it’s modules. You do not need to define every option that LwIP provides; if you do not define an option, a default value will be used. Therefore, your lwipopts.h provides a way to override much of the behavior of LwIP. LwIP Demos in MCUXpresso SDK MCUXpresso SDK comes with lots of demos that use different API sets. Name Description Lwip_tcpecho a TCP echo demo on the lwIP TCP/IP stack with bare metal KSDK or FreeRTOS. The demo uses the TCP protocol and acts as an echo server Lwip_udpecho a UDP echo demo on the lwIP TCP/IP stack with bare metal KSDK or FreeRTOS, which uses the UDP protocol and acts as an echo server. Lwip_ping a Ping Demo on the lwIP TCP/IP stack which using the ICMP protocol lwip_nghttp2cli_mbedTLS an NGHTTP2 client set up on lwIP TCP/IP and the MbedTLS stack with FreeRTOS lwip_mqtt MQTT client connecting to MQTT broker via unsecured socket lwip_iperf check your bandwidth using the network performance measurement IPerf application on a PC as a client or a server lwip_httpsrv an HTTPServer on the lwIP TCP/IP stack with bare metal SDK or FreeRTOS lwip_httpscli_mbedTLS an HTTPS client set up on lwIP TCP/IP and the MbedTLS stack with FreeRTOS lwip_dhcp_usb a DHCP and ping demo on the lwIP TCP/IP and USB stack lwip_dhcp a DHCP client and prints the status as it is progressing
View full article
What is it FreeMASTER?   FreeMASTER is a tool with variety GUIs in one offered free. FreeMASTER is a user-friendly real-time debug monitor and data visualization tool −GUI can be easily extend by multimedia content (charts) and user-modified content (possible mix user´s data with default values) − offers access to target variables, symbols and data types − access over UART, CAN or USB with target-side driver and over BDM − possibility to direct control via variable modifications − addresses parsed from ELF file or provided by target (TSA) − scope graphs with real-time data in [ms] resolution − recorder visualization transitions close to 10[us] resolution     FreeMASTER features Real Time Monitor -Displaying variable values in various formats (Text, Real-Time waveforms, High-speed recorded data) Control Panel - Direct variable value settings and variable stimulation, scribtable in JScript or VBScript Demonstration Platform - Demostration embedded app by HTML pages, display simultaneous real-time data monitoring Easy Project Deployment - Entire project saved to a single file   FreeMASTER communication There are two types of communication. It is possible to communicate via Direct RS232 or selected Plug-in Module. In short: SCI, UART USB – CDC – Kinetis, ColdFire V2 CAN JTAG (56F8xxx only) BDM – Kinetis, PowerPC, ColdFire, HCS with Segger, P&E Micro, CMSIS-DAP…     FreeMASTER usage Real-time debugging - FreeMASTER allows users to debug applications in true real-time through its ability to watch variables. Moreover, it allows debugging at the algorithm level, which helps to shorten the development phase Diagnostic tool - FreeMASTER remote control capability allows it to be used as a diagnostic tool for debugging customer applications remotely across a network Demonstrations - FreeMASTER is an outstanding tool for demonstrating algorithm or application execution and variable outputs. Education - FreeMASTER may be used for educational purposes. Its application control features allow students to play with the application in demonstration mode, learning how to control program execution.   FreeMASTER description of the environment   The FreeMASTER window is divided into 4 parts - Project Tree, Detail View Pane, Commands and Variable Watch Grid. Project Tree is the project, New Block is a root of the project, New Scope is similar to classical Oscilloscope. Scope periodically reads variable values and plots them in real-time. It is limited by the serial communication speed. The recorder is also monitoring and visualising variable values, but the change is much faster. The recorder is running on target board and variable values are sampled into memory buffer on the board and then these sampled data are downloaded from the board to FreeMASTER.   Detail View Area is dynamically changes depending on content which is selected in Project Tree. Detail View Tab can be control page, algorithm block description, scope, recorder or another HTML document whose URL is defined in the Scope or Recorder properties. Commands window is list of commands to send, Variable Stimulus - is the list of defined variables for the defined time. In Variable Watch Grid contains the list of watched variables.   Supported devices FreeMASTER download and support   The installation package you can download from the Official website:   FreeMASTER Official website www.nxp.com/freemaster   You can ask us on Community or you can create new SR according to https://community.freescale.com/docs/DOC-329745   More about FreeMASTER   FreeMASTER Official Website https://www.nxp.com/freemaster   Using FreeMASTER https://cache.freescale.com/files/microcontrollers/doc/reports_presentations/FREEMASTERPRESENT.pdf   FREEMASTER:  Remote Server Tutorial https://community.freescale.com/docs/DOC-103293   Tutorial: FreeMASTER Visualization and Run-Time Debugging https://mcuoneclipse.com/2013/08/24/tutorial-freemaster-visualization-and-run-time-debugging   Let´s continue with reading! Let´s start with KSDK!
View full article
Hello KSDK friends:   This time I want to share with the community a project using FatFs and the SDHC + I2C drivers provided with the Kinetis SDK platform. This is a baremetal project with no RTOS.   If you are a follower of colleague Erich Styger's MCU_on_Eclipse blog, then you might be familiar with the demo application, which consists of a data logger to store the accelerometer values of a FRDM-K64F on-board FXOS8700CQ (accelerometer/magnetometer) to a Micro SD Card.   The difference is that this demo project is implemented with KSDK v1.2 platform, using the next components:   - FatFs: Generic File System used in embedded systems. - SDHC peripheral driver: To handle the SD Card commands. - SD Card driver: Part of the KSDK composite drivers. - I2C peripheral driver: Used to communicate with the on-board FXOS8700CQ. - other peripheral drivers and systems: Clock System, GPIO driver, etc.   2 attachments are included with this post:   1) Demo project for KDS (created with KDS v3.0.0). 2) Document with a detailed description of how the project was created.   If when importing the project KDS asks you to add compiler search paths, just select "No". Paths are already configured.   IMPORTANT: The project can be placed in any location, but the next conditions must be met before building the project:   - Build the K64F KSDK platform library KDS project. The "Debug" build configuration is used. If not familiar with this, please refer to "Getting Started with Kinetis SDK (KSDK) v.1.2.pdf" in KSDK doc folder: C:\Freescale\KSDK_1.2.0\doc.   - Check that the build variable {KSDK_PATH} is pointing to your KSDK v1.2 installation (Project -> Properties -> C/C++ Build -> Build Variables):       RUNNING THE DEMO   1- Load the application to the FRDM-K64F. 2- Connect the PC to the FRDM-K64F OpenSDA micro USB port. 3- Open a terminal software and connect to the OpenSDA Virtual COM port. Configure the terminal for a baud of 115200. 4- Reset the board. You will see this message:     5- Insert micro SD Card. Now terminal should look like this:     6-  Accelerometer values will start to be printed to terminal and logged to SD Card each second.   A safe remove mechanism is implemented. Press SW3 in FRDM-K64F until you see the message shown below:     Keep SW3 pressed until SD Card is removed.   7- Now with a PC you can open the file LOG_DATA.txt:     The file can also be opened by a software such as Excel to graph the results:     I hope you like this demo!   Regards. Jorge Gonzalez
View full article
Hello Kinetis world! Kinetis SDK is here to stay and with it there are good opportunities ahead, such as coding flexibility, portability, RTOS enablement, projects scalability and more. Right now this is a brand new solution introduced by Freescale, so a lot of tutorials, How-To's and demo codes are coming, in addition to those already in the KSDK installation. I wanted to share an example project developed with KSDK v1.0.0 and KDS v1.1.1, which uses a simple driver to communicate to an I2C EEPROM memory using a FRDM-K64F board. The driver is focused and was tested with a 256 Kbit memory (24xx256), but it should be compatible with the 64Kbit, 128 Kbit, 256 Kbit and 512 Kbit versions. This demo project demonstrates how to use the APIs of the KSDK I2C Master Driver. The connections are as next: Please notice this is not intended to be a robust driver for I2C EEPROMs. Instead consider it a basic demo code, but with time we could improve it. The attached pdf is an overview/explanation of the example, while the zip folder contains the project for Kinetis Design Studio v1.1.1. :smileyalert: Before the project can be successfully compiled, you need to have installed KSDK v1.0.0 (www.freescale.com/ksdk) and have the FRDM-K64F platform library already built. For instructions on how to build the platform library you can refer to Appendix A of the next document in KSDK installation folder: C:\Freescale\KSDK_1.0.0\doc\Kinetis SDK K64 User's Guide.pdf :smileyinfo: NOTE: Disregard IAR and Keil instructions and refer to KDS part. Importing and compiling the example project with KDS      1) Unzip the package. It is recommended to place it into your KDS workspace, but it can be located at any place.      2) From KDS go to File -> Import -> General -> Existing Projects into Workspace.      3) Check "Select root directory" and click on "Browse" to search for the location of the unzipped folder. Then click OK.      4) Mark the check box for "I2C_EEPROM_K64" and click on "Finish".      5) Go to Project -> Build Project or simply click on the hammer icon. Build process should finish with no errors. The project provides a default Debug Configuration to use with the Segger J-Link emulator firmware v2.0 installed in the FRDM-K64F. If you wish to use a different connection please refer to the next link: https://community.freescale.com/docs/DOC-101845 I hope you like this demo. Many thanks and credits to abigailinzunza, for her valuable help developing this project. Regards! Jorge Gonzalez
View full article
Hello KSDK fans:   As you may know, KSDK provides comprehensive software support for Kinetis MCUs to accelerate application development. Besides providing Hardware abstraccion layer and peripherals drivers it can be Processor Expert capable.   Here is an example on how to create a new project with KSDK and Processor Expert support.   It shows a simple USB HID example that is ready to add your application code by using either KSDK drivers or Processor Expert support.   I hope this can help you.   Regards,   Isaac Avila
View full article
This document provides the guidelines to create a toggle LED application in the FRDM-K64F by using the KDS 1.1.0 + KSDK 1.0.0 and Non Processor Expert usage. This is helpful to understand how to create a project for KDS that uses the KSDK.   This document is assuming that KDS 1.1.0 and KSDK 1.0.0 are installed under a Windows OS system.   After the installation of KDS the environment variable “KSDK_PATH” must be defined. Under “System Properties” go to “Environment Variables…” located in the “Advance” tab. Add the new variable under “User variables…”. The name should be “KSDK_PATH”. The path is the same where by default the KSDK is installed. In this case the path is “C:\Freescale\KSDK_1.0.0”. The KSDK patch must be installed before to proceed with any project creation. To do this click in “Help” menu and then “Install New Software…“ option. Click in the “Add…” button and then “Archive” button. Look for the file “C:\Freescale\KSDK_1.0.0\tools\eclipse_update\SDK_1.0.0-GA_Update_for_Eclipse.zip” and click “Ok” button. Select the “Eclipse Update for KSDK 1.0.0-GA” option from the options and then press the “Next” button. Next step is to create a new KDS project. Go to “File>New>Kinetis Design Studio Project” option Then give a name; easy one, to remember what it does. Then press “Next” Chose the board to be used. In this case we are using the FRDM-K64F. Now press “Next”. Check the "Kinetis SDK" check box. Make sure that "Processor Expert" is not checked. Project is now created and it is ready to include the source code.   All the KSDK examples include the "board" folder. It is necessary to do the same for this new project. To add it just right click in the project just created and chose "Import". Select "File System". Look for the board folder in the following path: C:\Freescale\KSDK_1.0.0\boards\   Chose the C and H files only from the "frdmk64f120m" folder. Just like this: Then the folder "frdmk64f120m" is added to the project structure. Following is to add the KSDK library in the compiler. To add it you need to give a right click in the project and click in "Properties". Under "C/C++ Build" menu go to "Settings". Then click in "Miscellaneous" under "Cross ARM C++ Linker". If you did it correctly then you will see this:      Click in add object button   and add the library here. The default path is "C:\Freescale\KSDK_1.0.0\lib\ksdk_platform_lib\kds\K64F12\Debug\ksdk_platform_lib.a". Now, let’s toggle an LED. It is necessary to include the boards.h file: #include "board.h"    A GPIO pins enum needs to be created. We are using the RGB connected to the PORTE, specifically the pin 26 (PTE26). The enum then should look like this: enum _gpio_pins { kGpioLED4  = GPIO_MAKE_PIN(HW_PORTE, 0x1A),//PTE26 }; Make sure you are giving the pin 26 as hexadecimal value. In this case the 26 is 0x1A and that is the value we give as second parameter to the GPIO_MAKE_PIN macro. Add the calling to the function hardware_init()a just after the variable definition in the main() function. After this, now call the function that is necessary to configure the pin direction: GPIO_DRV_SetPinDir(kGpioLED4, kGpioDigitalOutput);    Finally, to write the desired value to the LED use this function: GPIO_DRV_WritePinOutput(kGpioLED4, value);    The entire should code looks like this: #include "fsl_device_registers.h" #include "board.h"   enum _gpio_pins { kGpioLED4  = GPIO_MAKE_PIN(HW_PORTE, 0x1A),//PTE26 };   static int i = 0;   int main(void) { short value = 1;    /* Write your code here */ hardware_init();   GPIO_DRV_SetPinDir(kGpioLED4, kGpioDigitalOutput);   /* This for loop should be replaced. By default this loop allows a single stepping. */ for (;;) {   for (i = 0; i<0xFFFFFF; i++) { }   value = value^1; GPIO_DRV_WritePinOutput(kGpioLED4, value);   } /* Never leave main */ return 0; }   Compile and ready to test. See the green LED blinking in the FRDM-K64F board.
View full article
Examples for current KSDK 1.3 are located under C:\Freescale\KSDK_1.3.0\examples examples for middleware (tcpip, filesystem) under C:\Freescale\KSDK_1.3.0\middleware   There are more examples, which were created:   KSDK 1.3 Rainbow color using FTM PWM with KSDK 1.3 How to use printf() to print string to UART in KDS3.0 + KSDK1.3 Driving 16x2 LCD using KSDK drivers Integrating NFC Controller library with KSDK KL43Z support for sLCD and Touch sense using KDS3.0 +KSDK1.3.0 + Processor expert   KSDK 1.2 Using DMA to Emulate ADC Flexible Scan Mode with KSDK Writing my first KSDK1.2 Application in KDS3.0 - Hello World and Toggle LED with GPIO Interrupt Controlling speed in DC motors and position in servomotors with KSDK [FTM + GPIO] Line scan camera with KSDK [ADC + PIT + GPIO] A simple way to detect the track's center for the Freescale Cup Smart Race FatFs + SDHC data logger with KSDK in Kinetis Design Studio Segment LCD Example for KSDK KSDK GPIO driver with Processor Expert DAC Sinus Demo (using PEx + KSDK 1.2 + KDS 3.0) How to start customized KSDK project based on KSDK demo code   KSDK 1.1 An example project for FIR function implement on KV31 with SDK and CMSIS How to toggle LED in KDS 2.0 with KSDK 1.1.0 and Processor Expert KSDK SPI Master-Slave with FRDM-K64F Configuring Kinetis Software Development Kit (KSDK) to measure distance with ultrasonic transducers A demo project of USB HID bi-directional generic device for Kinetis SDK 1.1.0 Configuring Kinetis Software Development Kit (SDK) to measure distance with infrared (IR) sensor Writing my first KSDK Application in KDS - Hello World and GPIO Interrupt   KSDK 1.0 Writing your first toggle LED application with FRMD-K64F + KDS 1.1.0 + KSDK 1.0.0 Non-Processor Expert Low Power Application Using the SDK KSDK I2C EEPROM Example
View full article
This community post describes how to combine the ADC and DMA using KSDK to simulate a flexible peripheral storing the ADC results into a buffer stored in memory.   In this configuration the MCU uses less resources, only using one ADC and the hardware (DMA) chainging the ADC channel and filling up the memory buffer with the results of the ADC. This way the MCU does not need to read the ADC result register being everything done automatically.                        KSDK The Kinetis Software Development Kit (SDK) is an extensive suite of robust peripheral drivers, stacks, middleware and example applications designed to simplify and accelerate application development on any Kinetis MCU. The addition of Processor Expert technology for software and board support configuration provides unmatched ease of use and flexibility. The Kinetis SDK is complimentary and includes full source code under a permissive open-source license for all hardware abstraction and peripheral driver software.   KINETIS_SDK   FRDM-K64M The FRDM-K64F is an ultra-low-cost development platform for Kinetis K64, K63, and K24 MCUs. The FRDM-K64F hardware is form-factor compatible with the Arduino™ R3 pin layout, providing a broad range of expansion board options. Features: MK64FN1M0VLL12 MCU (120 MHz, 1 MB flash memory, 256 KB RAM) for more information see FRDM-K64F   DMA to Emulate ADC Flexible Scan To emulate flexible scan it is necessary to configure the DMA to change the input ADC channel. The channel numbers are defined in the ADC_mux array. The conversion results are stored in the ADC0_resultBuffer array with the following order:   ADC0_CH12. ADC0_CH13. ADC0_CH23.   The Kinetis K series of microcontrollers also offers a powerfulDMA peripheral with up to 16 channels that can be combined with the ADC to allow the scanning of more than two channels.   System overview ADC Flexible Scan mode requires two DMA channels for one ADC converter. DMA channel 1 with a higher priority transfers the resultant ADC data from the ADC0_RA register to a memory buffer. DMA channel 0 with a lower priority transfers the next ADC channel setting (input multiplexer channel) from the constant buffer. The following figure depicts the application Figure 1. Depicts the application Flow diagram: The example code that accompanies this application note demonstrates a continuous scan conversion from three ADC channels. Each channel is measured four times, so the result buffer size is 3 × 4 = 12 (the real buffer size is 16, to demonstrate that only 12 data field parts are written). The ADC works in hardware trigger mode, with the LPTMR timer serving as the trigger source. Scanning is executed in continuous mode; thus, after a major loop has finished, the result buffer pointer address_0 is reloaded and the conversion begins again from the start buffer address. To calculate and change the frequency, check the macro INPUT_SIGNAL_FREQ to change the frequency value in Hz. The DMA1 is triggered by the ADC, and the DMA0 is triggered by the eLINK of minor   loop of DMA1. In this example the frequency is set to10 Hz, and is the number of samples is 10.   Figure 2. Flow diagram Configuration with SDK Configure the ADC (functions and structures):   The ADC initialization in the application is shown on the following code snippet.   The ADC is in interruption mode. Trigger by LPTMR (HW trigger)                                     Trigger for eDMA enable                                     Fist channel input is 0x0C.  Channel ADC_SE12                                     Select the channel in chnNum                             /*      * Initialization ADC for      * 12bit resolution, interrrupt mode, hw trigger enabled.      * normal convert speed, VREFH/L as reference,      * disable continuouse convert mode.      */ ADC_DRV_StructInitUserConfigForIntMode(&adcUserConfig);     adcUserConfig.hwTriggerEnable = true;     adcUserConfig.continuousConvEnable = false;     adcUserConfig.dmaEnable = true;      ADC_DRV_Init(instance, &adcUserConfig, &gAdcState);      /* Install Callback function into ISR. */    ADC_DRV_InstallCallback(instance, 0U, adc_chn0_isr_callback);      adcChnConfig.chnNum = ADC_INPUT_CHAN;     adcChnConfig.diffEnable = false;     adcChnConfig.intEnable = true;     adcChnConfig.chnMux = kAdcChnMuxOfA;      /* Configure channel0. */     ADC_DRV_ConfigConvChn(instance, 0U, &adcChnConfig);     /* Configure channel1, which is used in PDB trigger case. */      return 0;           To use the DMA driver, follow these steps:   1.  Initialize the DMA module: EDMA_DRV_Init();   2.  Request a DMA channel: DMA_DRV_RequestChannel(); 3.  Configure the TCD:  EDMA_DRV_PrepareDescriptorTransfer(); and EDMA_DRV_PushDescriptorToReg(); 4.  Register callback function: EDMA_DRV_InstallCallback(); 5.  Start the DMA channel: EDMA_DRV_StartChannel(); NOTE: the next two functions are optional for stop and free DMA channel 6.  Stop the DMA channel: EDMA_DRV_StopChannel(); 7.  Free the DMA channel: dma_free_channel().   Initialize the DMA module: EDMA_DRV_Init();   In this function you can select the eDMA channel to use and this function initializes the run-time state structure to provide the eDMA channel allocation release, protect, and track the state for channels. This function also opens the clock to the eDMA modules, resets the eDMA modules and initializes the module to user-defined settings and default settings.   chnDMA1.channel= kEDMAChannel1; chnDMA0.channel=kEDMAChannel0;   userConfig.chnArbitration = kEDMAChnArbitrationFixedPriority; userConfig2.chnArbitration= kEDMAChnArbitrationRoundrobin; userConfig.notHaltOnError = false; userConfig2.notHaltOnError = false;     EDMA_DRV_Init(&state, &userConfig); EDMA_DRV_Init(&state2, &userConfig2);          Request a DMA channel: DMA_DRV_RequestChannel();   This function allocates eDMA channel according to the required channel allocation andcorresponding to the eDMA hardware request, initializes the channel state memory provided by user and fills out the members.   This function provides two ways to allocate an eDMA channel: statically and dynamically. In a static allocation, the user provides the required channel number and eDMA driver tries to allocate the required channel to the user. If the channel is not occupied, the eDMA driver is successfully assigned to the user. If the channel is already occupied, the user gets the return value kEDMAInvalidChn, this is request a channel in a static way, In a dynamic allocation, any of the free eDMA channels are available for use. eDMA driver assigns the first free channel to the user.   //request ADC1// uint8_t requestDMA1 = EDMA_DRV_RequestChannel(kEDMAChannel1, kDmaRequestMux0ADC0, &chnDMA1); if(kEDMAInvalidChannel==requestDMA1)                      {                      printf("EDMAInvalidChannel 1 .  the request is failed.");                      } //request DMA0// uint8_t requestDMA0 = EDMA_DRV_RequestChannel(kEDMAChannel0, kDmaRequestMux0AlwaysOn63, &chnDMA0); if(kEDMAInvalidChannel==requestDMA0)                      {                      printf("EDMAInvalidChannel 0.  the request is failed.");                      }       DMA configurations: is shown on the following code snippet. (edma_transfer_config_t) TCD is a configuration structure, inside has a parameters to change for different types to transfers data.  srcAddr: memory address  pointing to the source data destAddr: memory address pointing to the destination address srcTransferSize: Source data transfer size. destTransferSize: Destination data transfer size. srcOffset: Sign-extended offset applied to the current source address form the next-state value as each source read/write is completed. destOffset: Sign-extended offset applied to the current destination address form the next-state value as each source read/write is completed. srcLastAddrAdjust: Last source address adjustment. destLastAddrAdjust: Last destination address adjustment. Note here it is only valid when scatter/gather feature is not enabled. srcModulo: Source address modulo. destModulo: Destination address modulo.                             minorLoopCount: Minor bytes transfer count. Number of bytes to be transferred in each service request of the channel. majorLoopCount: Major iteration count.   //////////configuration and ELINK DMA channel 1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////        config[kEDMAChannel1].srcAddr = (uint32_t)(&ADC0_RA);  /*!< Memory address pointing to the source data. */        config[kEDMAChannel1].destAddr = (uint32_t)(&ADC0_resultBuffer[0]);/*!< Memory address pointing to the destination data. */        config[kEDMAChannel1].srcTransferSize = kEDMATransferSize_2Bytes;   /*!< Source data transfer size. */        config[kEDMAChannel1].destTransferSize = kEDMATransferSize_2Bytes;  /*!< Destination data transfer size. */        config[kEDMAChannel1].srcOffset = 0;         /*!< Sign-extended offset applied to the current source address to                                            form the next-state value as each source read/write is completed. */        config[kEDMAChannel1].destOffset = 2;        config[kEDMAChannel1].srcLastAddrAdjust = 0;    /*!< Last source address adjustment. */        config[kEDMAChannel1].destLastAddrAdjust = -24;   /*!< Last destination address adjustment. Note here it is only valid when scatter/gather feature is not enabled. */        config[kEDMAChannel1].srcModulo = kEDMAModuloDisable;       /*!< Source address modulo. */        config[kEDMAChannel1].destModulo = kEDMAModuloDisable;       /*!< Destination address modulo. */        config[kEDMAChannel1].minorLoopCount = 2;    /*!< Minor bytes transfer count. Number of bytes to be transferred                                             in each service request of the channel. */        config[kEDMAChannel1].majorLoopCount = 12;    /*!< Major iteration count. */   stcdDmaChn1.NBYTES.MLNO=0x02; /////////////////////////////Elink on/////////////////LINKCH/////major loop chn1// stcdDmaChn1.BITER.ELINKNO= (DMA_BITER_ELINKNO_ELINK_MASK|0x0000|0x0C); stcdDmaChn1.CITER.ELINKNO= (DMA_CITER_ELINKNO_ELINK_MASK|0x0C); stcdDmaChn1.ATTR= (DMA_ATTR_SSIZE(1)|DMA_ATTR_DSIZE(1)); stcdDmaChn1.CSR=(DMA_CSR_MAJORLINKCH(0)|DMA_CSR_MAJORLINKCH_MASK | DMA_CSR_INTMAJOR_MASK);   uint16_t statusChnn1 = EDMA_DRV_PrepareDescriptorTransfer(&chnDMA1, &stcdDmaChn1, &config[kEDMAChannel1], true, false);   if(kStatus_EDMA_Success == statusChnn1)        {          statusChnn1 = EDMA_DRV_PushDescriptorToReg(&chnDMA1, &stcdDmaChn1);        }         EDMA_DRV_PrepareDescriptorTransfer(); This function sets up the basic transfer for the descriptor.   EDMA_DRV_PushDescriptorToReg(); This function copies the software TCD configuration at for the hardware TCD. You needs fill up the structure stcd, and this function do transfer  all structure data in  DMA registers, is use a especial configuration In this case, the structure is filling up to configuration ELINK mode. The ELINK mode is a configuration of eDMA for triggers other DMA channel in each minion loop transfer is complete.   This is a registers of structure,  the mask to enable put on ElINKON mode  and for select channel to link and for put on the major loop to finishing trigger channel. stcd.BITER.ELINKNO= (DMA_BITER_ELINKNO_ELINK_MASK|0x0000|0x0C); stcd.CITER.ELINKNO= (DMA_CITER_ELINKNO_ELINK_MASK|0x0C);         DMA_BITER_ELINKNO_ELINK_MASK it’s a mask to active the channel-to-channel linking on minor-loop complete. As the channel completes the minor loop, this flag enables linking to another channel, defined by theLINKCH field. The link target channel initiates a channel service request via an internal mechanism You can see more information in Reference manual. ///////configuration DMA channel0 ///////////////////////////////////////////////////////////////////////////////////////     config[kEDMAChannel0].srcAddr = (uint32_t)(&ADC_mux[0]);     /*!< Memory address pointing to the source data. */        config[kEDMAChannel0].destAddr = (uint32_t)(&ADC0_SC1A);   /*!< Memory address pointing to the destination data. */        config[kEDMAChannel0].srcTransferSize = kEDMATransferSize_1Bytes;   /*!< Source data transfer size. */        config[kEDMAChannel0].destTransferSize = kEDMATransferSize_1Bytes;  /*!< Destination data transfer size. */        config[kEDMAChannel0].srcOffset = 1;         /*!< Sign-extended offset applied to the current source address to                                            form the next-state value as each source read/write is completed. */        config[kEDMAChannel0].destOffset = 0;        config[kEDMAChannel0].srcLastAddrAdjust = -3;    /*!< Last source address adjustment. */        config[kEDMAChannel0].destLastAddrAdjust = 0;   /*!< Last destination address adjustment. Note here it is only valid when scatter/gather feature is not enabled. */        config[kEDMAChannel0].srcModulo = kEDMAModuloDisable;       /*!< Source address modulo. */        config[kEDMAChannel0].destModulo = kEDMAModuloDisable;       /*!< Destination address modulo. */        config[kEDMAChannel0].minorLoopCount = 1;    /*!< Minor bytes transfer count. Number of bytes to be transferred                                             in each service request of the channel. */        config[kEDMAChannel0].majorLoopCount = 3;    /*!< Major iteration count. */         uint16_t statusChnn0 = EDMA_DRV_PrepareDescriptorTransfer(&chnDMA0, &stcdDmaChn0, &config[kEDMAChannel0], true, true);        if(kStatus_EDMA_Success == statusChnn0)        {               statusChnn0 = EDMA_DRV_PushDescriptorToReg(&chnDMA0, &stcdDmaChn0);        }         The function drivers in main file:          hardware_init();        dbg_uart_init();        OSA_Init();        init_adc(ADC_INST); init_trigger_source(ADC_INST);        config_DMA();   Open your terminal (baud rate 115200)    The results will appear on the terminal software.   Figure 3. Screen serial You can also see the results in the debugger window. Figure 4.  result buffer Steps to include ADC Flexible Scan software to KSDK   In order to include this demo in the KSDK structure, the files need to be copied into the correct place. The adc_dma_demo folder should be copied into the <KSDK_install_dir>/demos folder. If the folder is copied to a wrong location, paths in the project and makefiles will be broken. When the copy is complete you should have the following locations as paths in your system: <KSDK_install_dir>/demos/ adc_dma_demo /iar <KSDK_install_dir>/demos/ adc_dma_demo /kds <KSDK_install_dir>/demos/ adc_dma_demo /src In addition, to build and run the demo, it is necessary to download one of the supported Integrated Development Enviroment (IDE) by the demo: Freescale Kinetis Design Studio (KDS) IAR Embedded Workbench   Once the project is opened in one of the supported IDEs, remember to build the KSDK library before building the project, if it was located at the right place no errors should appear, start a debug session and run the demo.
View full article
Sharing notes taken during creation a USB stack composite demo: CDC + Generic HID, this demo is based on FrdmK22f bare mental and MCUXpresso SDK2.2. Creating the CDC + Generic HID composite demo requires combining the CDC example code and HID Generic example code into a single example. 1   Find an existing example as a template A new composite device application should use the existing examples as a template. MCUXpresso SDK2.2 USB stack provides three composite device demos, HID+AUDO, MSC+CDC, and mouse+keyboard, so I select usb_device_composite_cdc_msc as a starting point. 2   Prepare the descriptor-related data structure to ensure that the correct information about the customized composite device is relayed to the USB device stack 2.1 usb_device_class_config_list_struct_t This structure is required for the composite device and relays device callback, class callback, interface numbers, and endpoint numbers of each interface to the class driver. The structure should be placed in the “composite.c” file /* USB device class information */ usb_device_class_config_struct_t g_compositeDevice[2] = {     {         USB_DeviceCdcVcomCallback, (class_handle_t)NULL, &g_UsbDeviceCdcVcomConfig,     },     {                 USB_DeviceHidGenericCallback, (class_handle_t)NULL, &g_UsbDeviceHidGenericConfig,     }};   /* USB device class configuration information */ usb_device_class_config_list_struct_t g_compositeDeviceConfigList = { g_compositeDevice, USB_DeviceCallback, 2, }; 2.2  usb_device_class_config_struct_t This structure is required for the composite device and provides information about each class. The structure should be placed in the “composite.c” file /* USB device class information */ usb_device_class_config_struct_t g_compositeDevice[2] = {     {         USB_DeviceCdcVcomCallback, (class_handle_t)NULL, &g_UsbDeviceCdcVcomConfig,     },     {                 USB_DeviceHidGenericCallback, (class_handle_t)NULL, &g_UsbDeviceHidGenericConfig, } }; 2.3  usb_device_class_struct_t This structure is required for each class including the class type, supported configuration count and interface list for each configuration. /* Define class information for virtual com */ usb_device_class_struct_t g_UsbDeviceCdcVcomConfig = { g_UsbDeviceCdcVcomInterfaceList, kUSB_DeviceClassTypeCdc,  USB_DEVICE_CONFIGURATION_COUNT, };   usb_device_class_struct_t g_UsbDeviceHidGenericConfig = {     g_UsbDeviceHidGenericInterfaceList, /* The interface list of the HID generic */     kUSB_DeviceClassTypeHid,            /* The HID class type */     USB_DEVICE_CONFIGURATION_COUNT,     /* The configuration count */ };   2.4   usb_device_interface_list_t This structure is required for the composite device and provides information about each class. usb_device_interface_list_t g_UsbDeviceHidGenericInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = {     {         USB_HID_GENERIC_INTERFACE_COUNT, /* The interface count of the HID generic */         g_UsbDeviceHidGenericInterfaces, /* The interfaces handle */     }, };   /* Define configurations for virtual com */ usb_device_interface_list_t g_UsbDeviceCdcVcomInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = {     {         USB_CDC_VCOM_INTERFACE_COUNT, g_cdcVcomInterfaces,     }, };   2.5  usb_device_interfaces_struct_t This structure provides alternate setting interface information about each interface. usb_device_interfaces_struct_t g_UsbDeviceHidGenericInterfaces[USB_HID_GENERIC_INTERFACE_COUNT] = {     USB_HID_GENERIC_CLASS,           /* HID generic class code */     USB_HID_GENERIC_SUBCLASS,        /* HID generic subclass code */     USB_HID_GENERIC_PROTOCOL,        /* HID generic protocol code */     USB_HID_GENERIC_INTERFACE_INDEX, /* The interface number of the HID generic */     g_UsbDeviceHidGenericInterface,  /* Interfaces handle */     sizeof(g_UsbDeviceHidGenericInterface) / sizeof(usb_device_interfaces_struct_t), }; /* Define interfaces for virtual com */ usb_device_interfaces_struct_t g_cdcVcomInterfaces[USB_CDC_VCOM_INTERFACE_COUNT] = {     {USB_CDC_VCOM_CIC_CLASS, USB_CDC_VCOM_CIC_SUBCLASS, USB_CDC_VCOM_CIC_PROTOCOL, USB_CDC_VCOM_CIC_INTERFACE_INDEX,      g_cdcVcomCicInterface, sizeof(g_cdcVcomCicInterface) / sizeof(usb_device_interfaces_struct_t)},     {USB_CDC_VCOM_DIC_CLASS, USB_CDC_VCOM_DIC_SUBCLASS, USB_CDC_VCOM_DIC_PROTOCOL, USB_CDC_VCOM_DIC_INTERFACE_INDEX,      g_cdcVcomDicInterface, sizeof(g_cdcVcomDicInterface) / sizeof(usb_device_interfaces_struct_t)}, };   2.6 usb_device_interface_struct_t This structure provides information about each alternate setting interface for the current interface. /* Define interface for communication class */ usb_device_interface_struct_t g_cdcVcomCicInterface[] = {{0,                                                           {                                                               USB_CDC_VCOM_CIC_ENDPOINT_COUNT, g_cdcVcomCicEndpoints,                                                           },                                                           NULL}};   /* Define interface for data class */ usb_device_interface_struct_t g_cdcVcomDicInterface[] = {{0,                                                           {                                                               USB_CDC_VCOM_DIC_ENDPOINT_COUNT, g_cdcVcomDicEndpoints,                                                           },                                                           NULL}};   /* HID generic interface information */ usb_device_interface_struct_t g_UsbDeviceHidGenericInterface[] = {{     0U, /* The alternate setting of the interface */     {         USB_HID_GENERIC_ENDPOINT_COUNT, /* Endpoint count */         g_UsbDeviceHidGenericEndpoints, /* Endpoints handle */     }, }};     2.7 usb_device_endpoint_struct_t This structure is required for the composite device and provides ep information /* hid generic endpoint information */ usb_device_endpoint_struct_t g_UsbDeviceHidGenericEndpoints[USB_HID_GENERIC_ENDPOINT_COUNT] = {     /* HID generic interrupt IN pipe */     {         USB_HID_GENERIC_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),         USB_ENDPOINT_INTERRUPT, FS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE,     },     /* HID generic interrupt OUT pipe */     {         USB_HID_GENERIC_ENDPOINT_OUT | (USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),         USB_ENDPOINT_INTERRUPT, FS_HID_GENERIC_INTERRUPT_OUT_PACKET_SIZE,     }, };   /* cdc virtual com information */ /* Define endpoint for communication class */ usb_device_endpoint_struct_t g_cdcVcomCicEndpoints[USB_CDC_VCOM_CIC_ENDPOINT_COUNT] = {     {         USB_CDC_VCOM_CIC_INTERRUPT_IN_ENDPOINT | (USB_IN << 7U), USB_ENDPOINT_INTERRUPT,         HS_CDC_VCOM_BULK_IN_PACKET_SIZE,     }, };   /* Define endpoint for data class */ usb_device_endpoint_struct_t g_cdcVcomDicEndpoints[USB_CDC_VCOM_DIC_ENDPOINT_COUNT] = {     {         USB_CDC_VCOM_DIC_BULK_IN_ENDPOINT | (USB_IN << 7U), USB_ENDPOINT_BULK, FS_CDC_VCOM_BULK_IN_PACKET_SIZE,     },     {         USB_CDC_VCOM_DIC_BULK_OUT_ENDPOINT | (USB_OUT << 7U), USB_ENDPOINT_BULK, FS_CDC_VCOM_BULK_OUT_PACKET_SIZE,     }, };   3   Prepare the descriptors array and ensure that the descriptors are consistent with the descriptor-related data structure.  The descriptors for each class can be obtained from the class-related examples and class specification. For the composite device, combine multiple class descriptors.   /* Define configuration descriptor */ uint8_t g_UsbDeviceConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = {     /* Configuration Descriptor Size*/     USB_DESCRIPTOR_LENGTH_CONFIGURE,     /* CONFIGURATION Descriptor Type */     USB_DESCRIPTOR_TYPE_CONFIGURE,     /* Total length of data returned for this configuration. */     USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL),     USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL),     /* Number of interfaces supported by this configuration */     USB_INTERFACE_COUNT,     /* Value to use as an argument to the SetConfiguration() request to select this configuration */     USB_COMPOSITE_CONFIGURE_INDEX,     /* Index of string descriptor describing this configuration */     0,     /* Configuration characteristics D7: Reserved (set to one) D6: Self-powered D5: Remote Wakeup D4...0: Reserved        (reset to zero) */     (USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_D7_MASK) |         (USB_DEVICE_CONFIG_SELF_POWER << USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_SELF_POWERED_SHIFT) |         (USB_DEVICE_CONFIG_REMOTE_WAKEUP << USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_REMOTE_WAKEUP_SHIFT),     /* Maximum power consumption of the USB * device from the bus in this specific * configuration when the device is        fully * operational. Expressed in 2 mA units *  (i.e., 50 = 100 mA).  */     USB_DEVICE_MAX_POWER,       /* Interface Association Descriptor */     /* Size of this descriptor in bytes */     USB_IAD_DESC_SIZE,     /* INTERFACE_ASSOCIATION Descriptor Type  */     USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION,     /* The first interface number associated with this function */     0x00,     /* The number of contiguous interfaces associated with this function */     0x02,     /* The function belongs to the Communication Device/Interface Class  */     USB_CDC_VCOM_CIC_CLASS, 0x03,     /* The function uses the No class specific protocol required Protocol  */     0x00,     /* The Function string descriptor index */     0x02,       /* Interface Descriptor */     USB_DESCRIPTOR_LENGTH_INTERFACE, USB_DESCRIPTOR_TYPE_INTERFACE, USB_CDC_VCOM_CIC_INTERFACE_INDEX, 0x00,     USB_CDC_VCOM_CIC_ENDPOINT_COUNT, USB_CDC_VCOM_CIC_CLASS, USB_CDC_VCOM_CIC_SUBCLASS, USB_CDC_VCOM_CIC_PROTOCOL, 0x00,       /* CDC Class-Specific descriptor */     USB_DESCRIPTOR_LENGTH_CDC_HEADER_FUNC, /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE,  /* CS_INTERFACE Descriptor Type */     USB_CDC_HEADER_FUNC_DESC, 0x10,     0x01, /* USB Class Definitions for Communications the Communication specification version 1.10 */       USB_DESCRIPTOR_LENGTH_CDC_CALL_MANAG, /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */     USB_CDC_CALL_MANAGEMENT_FUNC_DESC,     0x01, /*Bit 0: Whether device handle call management itself 1, Bit 1: Whether device can send/receive call              management information over a Data Class Interface 0 */     0x01, /* Indicates multiplexed commands are handled via data interface */       USB_DESCRIPTOR_LENGTH_CDC_ABSTRACT,   /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */     USB_CDC_ABSTRACT_CONTROL_FUNC_DESC,     0x06, /* Bit 0: Whether device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and              Get_Comm_Feature 0, Bit 1: Whether device supports the request combination of Set_Line_Coding,              Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State 1, Bit ...  */       USB_DESCRIPTOR_LENGTH_CDC_UNION_FUNC, /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */     USB_CDC_UNION_FUNC_DESC, 0x00,        /* The interface number of the Communications or Data Class interface  */     0x01,                                 /* Interface number of subordinate interface in the Union  */       /*Notification Endpoint descriptor */     USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT,     USB_CDC_VCOM_CIC_INTERRUPT_IN_ENDPOINT | (USB_IN << 7U), USB_ENDPOINT_INTERRUPT,     USB_SHORT_GET_LOW(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE), USB_SHORT_GET_HIGH(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE),     FS_CDC_VCOM_INTERRUPT_IN_INTERVAL,       /* Data Interface Descriptor */     USB_DESCRIPTOR_LENGTH_INTERFACE, USB_DESCRIPTOR_TYPE_INTERFACE, USB_CDC_VCOM_DIC_INTERFACE_INDEX, 0x00,     USB_CDC_VCOM_DIC_ENDPOINT_COUNT, USB_CDC_VCOM_DIC_CLASS, USB_CDC_VCOM_DIC_SUBCLASS, USB_CDC_VCOM_DIC_PROTOCOL,     0x00, /* Interface Description String Index*/       /*Bulk IN Endpoint descriptor */     USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, USB_CDC_VCOM_DIC_BULK_IN_ENDPOINT | (USB_IN << 7U),     USB_ENDPOINT_BULK, USB_SHORT_GET_LOW(FS_CDC_VCOM_BULK_IN_PACKET_SIZE),     USB_SHORT_GET_HIGH(FS_CDC_VCOM_BULK_IN_PACKET_SIZE), 0x00, /* The polling interval value is every 0 Frames */       /*Bulk OUT Endpoint descriptor */     USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, USB_CDC_VCOM_DIC_BULK_OUT_ENDPOINT | (USB_OUT << 7U),     USB_ENDPOINT_BULK, USB_SHORT_GET_LOW(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE),     USB_SHORT_GET_HIGH(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE), 0x00, /* The polling interval value is every 0 Frames */       USB_DESCRIPTOR_LENGTH_INTERFACE, /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_INTERFACE,   /* INTERFACE Descriptor Type */     USB_HID_GENERIC_INTERFACE_INDEX, /* Number of this interface. */     0x00U,                           /* Value used to select this alternate setting                                        for the interface identified in the prior field */     USB_HID_GENERIC_ENDPOINT_COUNT,  /* Number of endpoints used by this                                        interface (excluding endpoint zero). */     USB_HID_GENERIC_CLASS,           /* Class code (assigned by the USB-IF). */     USB_HID_GENERIC_SUBCLASS,        /* Subclass code (assigned by the USB-IF). */     USB_HID_GENERIC_PROTOCOL,        /* Protocol code (assigned by the USB). */     0x02U,                           /* Index of string descriptor describing this interface */       USB_DESCRIPTOR_LENGTH_HID,      /* Numeric expression that is the total size of the                                       HID descriptor. */     USB_DESCRIPTOR_TYPE_HID,        /* Constant name specifying type of HID                                       descriptor. */     0x00U, 0x01U,                   /* Numeric expression identifying the HID Class                                        Specification release. */     0x00U,                          /* Numeric expression identifying country code of                                        the localized hardware */     0x01U,                          /* Numeric expression specifying the number of                                       class descriptors(at least one report descriptor) */     USB_DESCRIPTOR_TYPE_HID_REPORT, /* Constant name identifying type of class descriptor. */     USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_HID_GENERIC_REPORT),     USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_HID_GENERIC_REPORT),       /* Numeric expression that is the total size of the        Report descriptor. */     USB_DESCRIPTOR_LENGTH_ENDPOINT, /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_ENDPOINT,   /* ENDPOINT Descriptor Type */     USB_HID_GENERIC_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),     /* The address of the endpoint on the USB device        described by this descriptor. */     USB_ENDPOINT_INTERRUPT, /* This field describes the endpoint's attributes */     USB_SHORT_GET_LOW(FS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE),     USB_SHORT_GET_HIGH(FS_HID_GENERIC_INTERRUPT_IN_PACKET_SIZE),     /* Maximum packet size this endpoint is capable of        sending or receiving when this configuration is        selected. */     FS_HID_GENERIC_INTERRUPT_IN_INTERVAL, /* Interval for polling endpoint for data transfers. */       USB_DESCRIPTOR_LENGTH_ENDPOINT,       /* Size of this descriptor in bytes */     USB_DESCRIPTOR_TYPE_ENDPOINT,         /* ENDPOINT Descriptor Type */     USB_HID_GENERIC_ENDPOINT_OUT | (USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),     /* The address of the endpoint on the USB device        described by this descriptor. */     USB_ENDPOINT_INTERRUPT, /* This field describes the endpoint's attributes */     USB_SHORT_GET_LOW(FS_HID_GENERIC_INTERRUPT_OUT_PACKET_SIZE),     USB_SHORT_GET_HIGH(FS_HID_GENERIC_INTERRUPT_OUT_PACKET_SIZE),     /* Maximum packet size this endpoint is capable of        sending or receiving when this configuration is        selected. */     FS_HID_GENERIC_INTERRUPT_OUT_INTERVAL, /* Interval for polling endpoint for data transfers. */ };   4 Implement the specific descriptor-related callback function, which the USB Device stack calls to get the descriptor.    Please refer to the attached source code for more details
View full article
Hi everybody,   You can find the new version of this document using KDS2.0 and KSDK1.1.0 is in the following link: Writing my first KSDK1.2 Application in KDS3.0 - Hello World and Toggle LED with GPIO Interrupt   Best regards, Carlos Technical Support Engineer
View full article
For downloading this tool please go to Software Development Kit for Kinetis MCUs|Freescale   Features mentioned in Release Note:   The following features are available with the KSDK Project Generator 1.0 GA tool: Cross platform Operates on Windows, Linux, and Mac OSX Developed in 32-bit Python 2.7 on Windows 7, Ubuntu 14.10, OSX 10.10 & 10.11 Supports KSDK 2.0, KSDK 1.3.0 and 1.2.0 (and is needed to install KSDK 1.2/KSDK 1.3) Quick Generate of development board based KSDK projects Advanced Generate of New KSDK based projects Device or development board based Linked to KSDK installation or standalone RTOS support HAL or Platform library level projects Libraries in standalone projects tailored to device package KDS, IAR EWARM, Keil MDK, and/or Atollic TrueSTUDIO IDE projects Advanced Generate of KSDK ‘demo_apps’ Clones Clone projects located in ‘demo_apps’ folders for each development board Linked to KSDK installation or standalone clones   Known issue for cloning example as standalone project: Please see my workaround here KSDK Project Generator - BUG workaround   Enjoy this tool ! Any feedback is welcome!   Best Regards, Iva
View full article
I created easy tutorial for UART KSDK blocking demo which works as echo. The demo works with KSDK 1.1. and is created for KDS 2.0.   Because it could be problem if was used this pin by this reason was chosen UART 3, which is available to use and is routed to PTC16,PTC17 connection on Arduino header for this case is use ALT3 function (PTC16, PTC17)   Final output from terminal Physical connection between FRDM-K64F and USB to Serial Converter The unzipped folder must be located in example folder at C:\Freescale\KSDK_1.1.0\demos\
View full article