Kinetis软件开发套件知识库

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Kinetis Software Development Kit Knowledge Base

标签

讨论

排序依据:
When you need to create copy/clone of i.g. web_hvac example for FreeRTOS as standalone project, you can face this issue. It is impossible to work with the copy. Why? There is missing folder for RTOS and LIB.   ISSUE: You start to clone example There is missing folder for RTOS Also missing library ksdk_freertos_lib which is needed for the example Impossible to compile the project, because folder mentioned above are missing in the project WORKAROUND: Just add the folder rtos from C:\Freescale\KSDK_1.3.0 The same for the library, you add to the folder from C:\Freescale\KSDK_1.3.0\lib Import .wsd file Wsd file was successfully imported, library is included Build successful finished   I hope this helps you. Iva
查看全文
Because I receive feedback from customers, that it is sometimes complicated to execute this demo, I created short tutorial how to set it and execute it in KDS 3.0.0.   1. Physical connection In case of TWR-K64F, is needed TWR-SER and correctly set jumpers. and for TWR-K64F is needed to set jumper J6 to pins 1 and 2.   Be sure, that the TWR-SER and TWR-K64F is correctly connected (by white line) 2. Network configuration For changing IP address, please go to Network and Sharing Center, choose Change adapter settings Right click on Properties and change the IP address (TCP/IPv4) to 192.168.2.100   3.  Downloading the demo to TWR-K64F Go to KDS, File - Import and browse the demo, which is located at C:\Freescale\KSDK_1.2.0\examples\twrk64f120m\demo_apps\web_hvac\web_hvac_mqx\kds Import all libraries and the demo project and see imported sets in Project Explorer Debug the libraries first and then the project. Be sure, what debugger is used on the board and set the debugger. And now go to Resume!   4. Test the connection Go to cmd and ping to 192.168.2.102 (address of HVAC Server)   5. HVAC Web Server.Go to browser and type the address 192.168.2.102, you will see page for HVAC Web Server. Go to HVAC Demo - HVAC Status and now you can observe the temperatures by pressing button. There are set combinations which means see below. LED1: Simulate the Fan’s state LED2: System in the Heat mode LED3: System in the Cool mode LED4: Simulate the heart beat, increase real temperature (i.e., by hair dryer) to see the LED4 go faster and decrease temperature to see it slow down. So, if is needed increased temperature, push the first button (SW1) and Fan and Heat mode run. LED1 and LED2 will be light on and the temperature will increase.   Enjoy! Iva
查看全文
This solution is just for you, who does not enjoy finding documentation for KSDK does not enjoy many opened windows (all in one) often ask where is the documentation for KSDK like an overview will appreciate embedded help   For detailed information please see KSDK 1.3.0 Documents Plugin for KDS 3.0.0   I hope you will really invite this tool. Iva
查看全文
Hi folks,   I would like to share my experience using lwIP with KSDK1.2, I hope this will be useful for people who is getting started with this TCP/IP stack.   I must admit that I really dislike working over an example application (please do not misunderstand my message, these examples are really nice but just as examples, not to develop new applications over them), the problem is that these project are not stand alone and if they are moved from their original locations it becomes a mess. This is why I always create a standalone projects. For instance I will describe how to run ‘lwip_tcpecho_demo’ and after this, how to reproduce this example as a standalone project.   Running ‘lwip_tcpecho_demo’ Creating a new project with lwIP support using FreeRTOS       I hope you find it useful.   Regards, Carlos
查看全文
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.
查看全文
Hardware and software configuration: FRDM-K22F, SCH-28164 REV D OpenSDA: J-Link firmware KDS 3.0 with SDK 1.2.0 Eclipse update installed KSDK 1.2 provides an Eclipse update for those who want to use the Kinetis SDK with Eclipse and Processor Expert. and with this update , users may find MSD Class component has been supported, and there is a simple USB mass storage demo available directly in this PEx USB component, so that customers may easily build this demo and develop their own application based on that. Here I will start to illustrate how to implement this demo step by step. As FRDM-K22F is used in this test, so I directly choose this board and make the following configuration: After above steps, we have a PEx project with some pre-installed components as shown below: clockMan1 components has 6 configurations , and one of it is for USB application, you may set it as the init configuration right now, or it would be set automatically when you add the USB MSD components. Now I find the MSD component from KSDK 1.2 and add it to my project: This component will add 4 more reference components into this project, and we only have to configure the component "fsl_debug_console" to get rid of the error mark. For FRDM-K22 board, UART1 is used as the debug console, and PTE0 and PTE1 are used as the TXD and RXD, so I set up this components as below: The simple MSD demo is a RAM disk demo, and it is disabled by default, so we have to enable it in the fsl_usb_device_msd_class component, and the demo code will be automatically added into the project afterwards: and then set the correct PID and VID information in the component of fsl_usb_descriptors. so far looks like all components are configured correctly , but if we directly download this application, we will have an enumeration issue like below: This is due to USB descriptors are placed to Flash memory area by default . You know , USB descriptors contain constant values so storing them in flash would leave more RAM for user application. The highlighted option in the following figure determines this . but USB module in Kinetis doesn't have the permission for flash out of reset, so we still have something to do before going ahead. There are several solutions for it, the most easiest way is setting the above option to "no", but we may do it in a PEx-like way by using the "Init_FMC" component. Please note USB is the M4 of K22's crossbar-lite. so we give it the "read only" permission. Init_FMC() is placed in Peripherals_Init() which is called right before  Components_Init() where USB_Class_MSC_Init () is in, so it guarantees USB have the flash access permission before it starts up. Now the demo can work well with the PC host, just as shown below: So far only HID and MSD Class components are supported, and if you go through a similar process as above, you may easily implement a HID demo by yourself. Here I attach both the MSD and HID mouse demo for your reference. Hope that helps,
查看全文
Hello All,   Here is a document for creating an USB Host Project (MSC + fatfs) with KSDK 1.3 and Processor Expert support in KDS. It uses FRDM-K64F board as example and lists some specific considerations that needs to be accomplished when creating an USB Host project by using fsl_usb_framework component (Processor Expert) in Kinetis Software Development Kit (KSDK) version 1.3.   I hope you can find it useful!   Regards, Isaac Avila
查看全文
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
查看全文
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
查看全文
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
查看全文
There was a macro definition issue in the flexcan driver of ksdk 2.0, the macros of RX_FIFO_STD_MASK_TYPE_B/C were defined based on maco FLEXCAN_ID_STD(id), for example: #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_HIGH(id, rtr, ide) \ (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ (FLEXCAN_ID_STD(id) << 16)) /**< Standard Rx FIFO Mask helper macro Type B upper part helper macro. */ but FLEXCAN_ID_STD(id) is defined for flexCAN Message Buffer structure, so FLEXCAN_ID_STD(id)  is a value of "id" left-shifted by 18,  according to the spec. while for RX FIFO ID table structure, the spec of Type B/C is different. so we should use the value of id directly to define the type B and type C Rx Frame Identifier. For example, #define FLEXCAN_RX_FIFO_STD_MASK_TYPE_B_HIGH(id, rtr, ide) \ (((uint32_t)((uint32_t)(rtr) << 31) | (uint32_t)((uint32_t)(ide) << 30)) | \ ((id & 0x7FF) << 19)) /**< Standard Rx FIFO Mask helper macro Type B upper part helper macro. */   This patch doesn't affect FlexCAN operation related with message buffers , neither with RX FIFO A type ID table.   Please kindly refer to the attachment for details.   Sorry for the inconvenience that has caused.   -Kan
查看全文
For installation standalone KSDK packages please follow these instructions:   Go to www.freescale.com/ksdk and click to download Is needed to be signed in After that is seen standalone package for FRDM-KL43Z and KL33Z Agree with Software Terms and Conditions Choose installation package according to platform Save file and install it After installation, final folder appears at C:\Freescale\KSDK1.2.0_KL33Z_1.0.0 and Eclipse update - import package to KDS from C:\Freescale\KSDK1.2.0_KL33Z_1.0.0\tools\eclipse_update   Eclipse Update In KDS choose Install New Software Click Add Choose Archive Choose the Eclipse Update zip file located at C:\Freescale\KSDK1.2.0_KL33Z_1.0.0\tools\eclipse_update Select update for KL33Z and KL43Z Accept terms of the license agreement   🙂 Enjoy!
查看全文
What is needed: SW: KDS 3.2 KSDK 2.0 Hercules (Visual Studio 2015)   HW: FRDM-K64F Ethernet Cable   Install KSDK 2.0 Be sure, that you have downloaded correct package KSDK 2.0 for FRDM-K64F, for all procedure please follow instructions mentioned at How to: install KSDK 2.0   Install KDS 3.2 Be sure, that you will work with the newest Kinetis Design Studio v.3.2, please see New Kinetis Design Studio v3.2.0 available for more details.   Import demo example For start with this example we will build on existing demo project, located under C:\Freescale\<ksdk2.0_package>\boards\frdmk64f\demo_apps\lwip\lwip_tcpecho\freertos\kds Please, import this example according to the procedure described at How to: import example in KSDK   Start with programming Let´s start with programming example for LED RGB controlling via ethernet   Checking and parsing incoming packets This packet is divided into header and data. The header represents first two bytes and the remaining three bytes are occupied by data. The zero byte is 0xFF and the first byte must be 0x00. The second byte represents red color, the third byte green color and the last fourth byte presents blue color. lwip_tcpecho_freertos.c Server is listening on port 7 and waiting for a connection from the client. If the client sends 5B, it find out according to header whether it is correct 5B. If so, each RGB parts will be parsed individually and set the LED accordingly.       while (1)     {         /* Grab new connection. */         err = netconn_accept(conn, &newconn);         /* Process the new connection. */         if (err == ERR_OK)         {             struct netbuf *buf;             u8_t *data;             u16_t len;               while ((err = netconn_recv(newconn, &buf)) == ERR_OK)             {                 do                 {                     netbuf_data(buf, &data, &len);                     if(len==5){                         if(data[0]==0xFF && data[1]==0x00){                             if(data[2]>0){                                 LED_RED_ON();                             }else {                                 LED_RED_OFF();                             }                             if(data[3]>0){                                 LED_GREEN_ON();                             }else {                                 LED_GREEN_OFF();                             }                             if(data[4]>0){                                 LED_BLUE_ON();                             }else {                                 LED_BLUE_OFF();                             }                             //err = netconn_write(newconn, "ok", 2, NETCONN_COPY);                         }                     }                 } while (netbuf_next(buf) >= 0);                 netbuf_delete(buf);             }             /* Close connection and discard connection identifier. */             netconn_close(newconn);             netconn_delete(newconn);         }     }   Initializing LEDs   It is needed to set all LEDs in pin_mux.c in BOARD_InitPins() function and initialize in lwip_tcpecho_freertos.c in main() function.   pin_mux.c Go to BOARD_InitPins() and at the end of the function add these lines: Copy and paste to your project     CLOCK_EnableClock(kCLOCK_PortB);     CLOCK_EnableClock(kCLOCK_PortE);     PORT_SetPinMux(PORTB, 21U, kPORT_MuxAsGpio);     PORT_SetPinMux(PORTB, 22U, kPORT_MuxAsGpio);     PORT_SetPinMux(PORTE, 26U, kPORT_MuxAsGpio);   lwip_tcpecho_freertos.c Go to main() and initialize LEDs Copy and paste to your project LED_RED_INIT(LOGIC_LED_OFF); LED_GREEN_INIT(LOGIC_LED_OFF); LED_BLUE_INIT(LOGIC_LED_OFF); Set up connection on PC site Set PC on 192.168.1.100   Controlling the application Hercules For test connection you can use Hercules. After testing don´t forget disconnect Hercules, server can handle only one TCP connection. IP Address of the board is set on 192.168.1.102 It works - the board is green lighting:   Visualization in Visual Studio 2015 For better controlling we will create application in Visual Studio 2015. Start with new project and create new form according this:   And set functionality for all items. Client connects to the IP Address on port 7 and sends our packet according selected colour. For red color are data set on { 0xFF, 0x00, 1, 0, 0 };, for yellow { 0xFF, 0x00, 1, 1, 0 }; etc.   Form1.cs public partial class Form1 : Form     {         Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);          public Form1()         {             InitializeComponent();                      }          private void button1_Click(object sender, EventArgs e)         {             try              {                 s.Connect(IPAddress.Parse(textBox1.Text), 7);                 byte[] data = { 0xFF, 0x00, 0, 0, 0 };                 groupBox1.Enabled = true;                 button1.Enabled = false;                 s.Send(data);                  textBox1.Enabled = false;             }             catch              {                 MessageBox.Show("Connection failed");             }         }          private void button_red_Click(object sender, EventArgs e)         {             if (s.Connected) {                 byte[] data = { 0xFF, 0x00, 1, 0, 0 };                 s.Send(data);             }         }          private void button_green_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 0, 1, 0 };                 s.Send(data);             }         }          private void button_blue_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 0, 0, 1 };                 s.Send(data);             }         }          private void button_black_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 0, 0, 0 };                 s.Send(data);             }         }          private void button_white_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 1, 1, 1 };                 s.Send(data);             }         }          private void button_cyan_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 0, 1, 1 };                 s.Send(data);             }         }          private void button_magenta_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 1, 0, 1 };                 s.Send(data);             }         }          private void button_yellow_Click(object sender, EventArgs e)         {             if (s.Connected)             {                 byte[] data = { 0xFF, 0x00, 1, 1, 0 };                 s.Send(data);             }         }     }     Enjoy! 🙂   Iva
查看全文
For this demo, Kinetis SDK was configured to implement a distance meter using a FRDM-K64F and the GP2D12 IR Sensor. The operating principle of this sensor consists in sending IR pulses and according to the existing distance between it and the reflective object, it generates different output voltages. Its analog output varies from 0.4 to 2.6 V approximately; the higher output voltage values are reached when the reflective object is closer to the sensor and the lower ones when it’s farther. The range of distance measured goes from 15 to 100 cm, if the distance from the sensor to the reflective object isn’t between this range, the demo’s results will not be reliable. The following figure depicts the application’s block diagram Figure 1. Block Diagram The signal received from the sensor goes through the Channel_1 at the instance 0 of the ADC module (ADC0_CH1), which is periodically triggered by the low power timer (every 125 µs). After getting every ADC’s sample an average is calculated from a total of 32 samples in order to make the ADC’s value reliable before using it to calculate the current distance. The application’s schematic diagram is shown in the following figure Figure 2. Schematic Diagram The required electrical connections to implement the application are explained below Table 1. Electrical connections   The following figure shows the application’s flow diagram    Figure 3. Flow Diagram   The required configuration for the ADC initialization in the application is shown on the following code snippet static int32_t init_adc(uint32_t uiInstance) {     /*      * Initialization ADC for      * 10bit resolution, interrrupt mode, hw trigger enabled.      * normal convert speed, VREFH/L as reference,      * disable continuous convert mode.      */     ADC16_DRV_StructInitUserConfigDefault(&adcUserConfig);     adcUserConfig.intEnable = true;     adcUserConfig.resolutionMode = kAdcResolutionBitOf10or11;     adcUserConfig.hwTriggerEnable = true;     adcUserConfig.continuousConvEnable = false;     adcUserConfig.clkSrcMode = kAdcClkSrcOfAsynClk;     ADC16_DRV_Init(uiInstance, &adcUserConfig);      /* Install Callback function into ISR. */     ADC_TEST_InstallCallback(uiInstance, CHANNEL_0, MyADCIRQHandler);      adcChnConfig.chnNum = IR_SENSOR_ADC_CHANNEL;     adcChnConfig.diffEnable = false;     adcChnConfig.intEnable = true;     adcChnConfig.chnMux = kAdcChnMuxOfA;     /* Configure channel0. */     ADC16_DRV_ConfigConvChn(uiInstance, CHANNEL_0, &adcChnConfig);      return 0; }             Here is the initialization of the ADC, the interrupt mode is enabled assigning the ‘true’ value to the variable adcUserConfig.intEnable, 10bit resolution is selected by kAdcResolutionBitOf10or11, the hardware trigger is enabled and the continuous conversion disabled with adcUserConfig.hwTriggerEnable and adcUserConfig.continuousConvEnable, respectively. Moreover, the selected clock source is asynchronous, kAdcClkSrcOfAsynClk. After these comes the call to the function ADC16_DRV_Init that receives as parameters the ADC uiInstance being used and a pointer to the structure adcUserConfig that contains the configuration selected by the user. The function ADC_TEST_InstallCallback installs the callback for the interrupt, its parameters are the uiInstance, the CHANNEL_0 from which will be received the interruption trigger and the name of the interruption handler function, MyADC1IRQHandler. The configurations for the ADC reading channel are the selection of the channel number adcChnConfig.chnNum (in this case it is being used the CHANNEL_1), the differential mode is disabled with the variable adcChnConfig.diffEnable, the trigger interrupt is enable at adcChnConfig.intEnable and with adcChnConfig.chnMux the channel multiplexer for a/b channel is selected by kAdcChnMuxOfA. Finally, the call to the function ADC16_DRV_ConfigConvChn receives the uiInstance number, the CHANNEL_0 for receiving the interrupt trigger and a pointer to the structure adcChnConfig that configures the ADC channel. The ADC trigger source initialization is presented below void init_trigger_source(uint32_t uiAdcInstance) {     lptmr_user_config_t lptmrUserConfig =     {         .timerMode = kLptmrTimerModeTimeCounter,         .freeRunningEnable = false,         .prescalerEnable = false, /* bypass prescaler */         .prescalerClockSource = kClockLptmrSrcMcgIrClk, /* use MCGIRCCLK */         .isInterruptEnabled = false     };      /* Init LPTimer driver */     LPTMR_DRV_Init(0, &lptmrUserConfig, &gLPTMRState);      /* Set the LPTimer period */     LPTMR_DRV_SetTimerPeriodUs(0, LPTMR_COMPARE_VALUE);      /* Start the LPTimer */     LPTMR_DRV_Start(0);      /* Configure SIM for ADC hw trigger source selection */     SIM_HAL_SetAdcAlternativeTriggerCmd(gSimBaseAddr[0], uiAdcInstance, true);     SIM_HAL_SetAdcPreTriggerMode(gSimBaseAddr[0], uiAdcInstance, kSimAdcPretrgselA);     SIM_HAL_SetAdcTriggerMode(gSimBaseAddr[0], uiAdcInstance, kSimAdcTrgSelLptimer); }            The user configuration for the LPTMR is located at the structure lptmrUserConfig, here the LPTMR Time Count mode is selected by kLptmrTimerModeTimeCounter, the free running mode, the prescaler and the timer interrupt are disabled with freeRunningEnable, prescalerEnable and isInterruptEnbled, respectively. Furthermore, the LPTMR clock source is selected as the Internal Reference Clock with kClockLptmrSrcMcgIrClk. The function LPTMR_DRV_Init receives as parameter the instance number, a pointer to the structure lptmrUserConfig that contains the user configurations and a pointer to the structure gLPTMRState with internal information of the LPTMR driver. The function LPTMR_DRV_SetTimerPeriodUs set the corresponding timer period for the LPTMR, its parameters are the ADC instance and LPTMR_COMPARE_VALUE that saves the period value in us. The LPTMR_COMPARE_VALUE macro is located and can be set at the lptmr_trigger.c file. Moreover, the user will be able to change this period during the execution time at the Variable Watch section in the FreeMASTER project, modifying the value of LPTMR Interrupt Time (us) and setting the LPTMR Time Flag on 1. LPTMR_DRV_Start starts the LPTMR and its only parameter is the ADC instance.                                           Finally, there are three functions that configure the SIM for the ADC hardware trigger source selection; they receive as parameters the array initializer of SIM peripheral base addresses, gSimBaseAddr[0], and uiAdcInstance. The function SIM_HAL_SetAdcAlternativeTriggerCmd enables/disables the alternative conversion triggers; in this case it receives a true value, so it is enabled. Moreover, SIM_HAL_SetAdcPreTriggerMode selects the pre-trigger source; its third parameter is kSimAdcPretrgselA that corresponds to Pre-trigger A. The last one, SIM_HAL_SetAdcTriggerMode, selects the trigger source, so it’s receiving kSimAdcTrgSelLptimer. The following code snippet shows the implemented algorithm to calculate the distance void GetCurrentDistanceValue(uint32_t uiAvgAdc) {     static uint32_t sdwCurrentDistance = 0;      uint32_t dwm = 0;     uint32_t dwb = 0;      if((520 <= uiAvgAdc) && (uiAvgAdc < 840))     {       dwm = 641;       dwb = 683970;     }     else if((260 <= uiAvgAdc) && (uiAvgAdc < 519))     {       dwm = 1337;       dwb = 1011000;     }     else if((130 <= uiAvgAdc) && (uiAvgAdc < 259))     {       dwm = 2941;       dwb = 1423500;     }     sdwCurrentDistance = (dwb-(dwm*uiAvgAdc));     g_dwDistanceIntegers = (sdwCurrentDistance/10000);     g_dwDistanceTenths = ((sdwCurrentDistance - (g_dwDistanceIntegers*10000))/1000); }            The implemented algorithm to calculate the distance is based on the division of the characteristic curve of the IR Sensor’s behavior in three different sections in order to approximate it to a linear behavior. Each line was generated from two different points. The first line is used when the uiAvgAdc value is between 520 and 840 (15 - 35 cm). The second one, for an uiAvgAdc value higher than 260 and lower than 519 (40 - 65 cm). And the last one, for uiAvgAdc values between 130 and 259 (70 - 100 cm). Depending on the calculated uiAvgAdc value, the slope (dwm) and the intersection with the y axis (dwb) change for each line.   In order to make the demo compatible with different microcontrollers and IDEs, it was necessary to avoid the use of float variables to calculate the distance, so that the result could be printed on a console without problems. The real values of the slopes and intersections with the y-axis for each line were multiplied by 10000. After getting sdwCurrentDistance value it is divided into integers and tenths; to get the integers at g_dwDistanceIntegers, the current distance is divided by 10000 and the corresponding fraction for tenths is stored in g_dwDistanceTenths. As a result, the current distance value is printed combining the integers and tenths variables, avoiding the use of a float variable.        The following graphic shows the characteristic curve and the three lines in which it was divided Figure 4. Characteristic curve’s graphic The application test’s results are shown in the following table 1 The error for the Distance Measured values is approximately ± 0.5 cm 2 The ADC Average values have an error of approximately ± 5 units Table 2. Test’s Results Steps to include IR sensor software to KSDK In order to include this demo in the KSDK structure, the files need to be copied into the correct place. The distance_measure_IRsensor 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/distance_measure_IRsensor/iar <KSDK_install_dir>/demos/distance_measure_IRsensor/kds <KSDK_install_dir>/demos/distance_measure_IRsensor/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. The results of the distance measurement will be shown by UART on a console (use 115 200 as Baud rate) and at FreeMASTER, just as in the following example where the reflective object was located at 35 cm from the IR sensor: Figure 5. Example of the distance measured being shown in a console Figure 6. Example of the ADC Values obtained from the IR sensor monitored with FreeMASTER Figure 7. Example of the distance measured results at FreeMASTER FreeMASTER configuration For visualizing the application’s result on FreeMASTER it is necessary to configure the corresponding type of connection for the FRDM-K64F: 1. Open FreeMaster. 2. Go to File/Open Project. 3. Open the Distance Measurement IR Sensor project from <KSDK_install_dir>/demos/distance_measure_IRsensor/ FreeMaster. 4. Go to Project/Options. 5. On the Comm tab, make sure the option ‘Plug-in Module’ is marked and select the corresponding type of connection.    Figure 8. Corresponding configurations FRDM-K64F’s connection at FreeMASTER It is also necessary to select the corresponding MAP file for the IDE in which will be tested the demo, so: 6.  Go to the MAP Files tab. 7.  Select the MAP File for the IAR or the KDS project. *Make sure that the default path matches with the one where is located the MAP file of the demo at your PC. If not, you can modify the path by clicking on the ‘…’ button (see Figure 9) and selecting the correct path to the MAP file: <KSDK_install_dir>/demos/distance_measure_IRsensor/iar/frdmk64f/debug/distance_measure_IRsensor_frdmk64f.out <KSDK_install_dir>/demos/distance_measure_IRsensor/kds/frdmk64f/Debug/distance_measure_IRsensor_frdmk64f.elf 8.  Click on ‘OK’ to save the changes. Figure 9. Selection of the MAP File for each IDE supported by the demo I hope this demo to be useful for your applications, enjoy!
查看全文
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.
查看全文
Sharing a porting guide for the USB CCID demo from using EMVSIM module on K8x/KL8x to more general UART-ISO7816 module on Kinetis K devices. The demo has been tested with K64 tower board and one internal tower card named as TWR-ISO7816, MK64 is connected directly with smart card connector without using external PHY.   Attached the porting guide and associated demo code based on KSDK2.0.   When running the demo code, you will see console log similar as in attached log file. After installing driver according to the readme file with the USB CCID demo, you will see something as follows in device manager for smart card. Then you can use the PC test tool "Snooper" to talk to smart card.     Hao Original Attachment has been moved to: USB_CCID_MK64.zip Original Attachment has been moved to: USB-CCID-log.txt.zip
查看全文
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.
查看全文
At the moment the best way to create a new KSDK example project is copying one of the existing projects in the /demos folder and renaming all the files and text to the new name. I've created a simple script that does all the work for you.   To run, just place the .exe or Perl script in the C:\Freescale\KSDK_1.0.0\demos folder and run. By default it'll copy the "hello_world" project to a new directory, and change all the "hello_world" text and files names to your new project name. Pretty straight forward, but much easier and less prone to error than doing it by hand. I've attached both the Perl source and a .exe created from that perl script. There is a command line option to specify the project to be copied, but by default it uses the hello_world one.   Hope you find it useful!
查看全文
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
查看全文
Hello Kinetis users!   I thought this would be the best place to share this code.  Attached is an example of how to use the power manager in the 1.0.0 release of the Kinetis SDK.  It is essentially the legacy low power demo ported to the SDK.  Now, the SDK doesn't provide functions to de-initialize the pins so some of it is a little messy, but it should still help to show you how to use the power manager and how to get in and out of low power modes.    The supported platforms are:   FRDM-K22F FRDM-K64F TWR-K22F120M TWR-K64F120M TWR-KV31F120M   To install the demo, simply unzip the file to the "demos" folder of your SDK installation.  All of the links in the demo are relative so you shouldn't have any trouble.  However, if you do experience any issues, please let me know so that I can correct the issues.    To run the demo, simply build and download the application (a guide of how to do this is provided in the device specific User's Guide in your SDK installation).  Then perform a power-on reset (you always want to do that when working with low power applications) and connect a terminal utility with the following settings:   - 19200 baud rate - 8 data bits - No parity - 1 stop bit - No flow control   Then follow the on-screen instructions.    As a reminder to those wishing to understand low power operations and the Kinetis devices a little more, we do have an Application Note out there to help explain low power operations:  AN4503 Power Management for Kinetis and ColdFire+ MCUs.  This Application Note is in the process of being updated with Kinetis SDK information and is scheduled to be re-published sometime this year.    Enjoy! Chris
查看全文