Kinetis Microcontrollers Knowledge Base

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

Kinetis Microcontrollers Knowledge Base

Discussions

Sort by:
This application demonstrates the use of the FRDM-KL25 as a HID HOST. In this project the HID Device is a Numeric Keyboard and the HOST Device (FRDM-KL25) is handling the data and printing them in a 16x2 LCD used in 8 bits mode .
View full article
Hello Kinetis fans, This time I bring to you a document which explains what is and how to configure channel linking feature which is present in the Enhanced Direct Memory Access (eDMA). If you are interested in the scatter/gather feature, please take a look into the document What is and how to configure the eDMA scatter/gather feature. I hope you find this document useful. Best regards, Earl Orlando Ramírez-Sánchez Technical Support Engineer NXP Semiconductors
View full article
This is a copy of the currently posted KL26 reference manual to be used to enter community comments.  Please feel free to add inline comments in this reference manual. You can point out where more information is needed or where existing information is incorrect.  You can also enter information in your comment that expands on existing information in the document, based on your experience with the device.  If you are pointing out that more information is needed in a paragraph or a section, please be very specific, not “needs more information”.  Your comments in this manual may help other members and will drive improvements in this and future documentation. Note: The doc viewer does not support going directly to a specified page.  Instead of manually paging through one page at a time, you can do a search on a string on a page such as "types of resets", or you can go to chapter links listed in the inline comments.  To do this, page down to the comments below the doc view, select "Inline Comments", sort the comments by "page", and then select the chapter you want to view.
View full article
En México, el 5.1% de la población vive con algún tipo de discapacidad, de los cuales 23% poseen discapacidades del tipo motriz en extremidades inferiores y superiores (INEGI, 2011). Los métodos que actualmente se utilizan en el proceso de rehabilitación no poseen características integrales en las que el usuario pueda aprovechar la terapia para ejecutar diferentes acciones. El objetivo de este proyecto es el de diseñar y construir una herramienta que permita al usuario no solo hacer ejercicios de rehabilitación, sino que también le ayude a realizar tareas cognitivas o a interactuar con algún medio electrónico (i. e. navegar por internet, realizar trabajos a través de una computadora con Rehab Glove como mouse y/o teclado). Rehab Glove es una herramienta en forma de guante que posee sensores de flexión en las articulaciones de los dedos y de fuerza en las yemas, ubicados estratégicamente con el fin de obtener diferentes valores arrojados mientras el usuario realiza ejercicios de rehabilitación como cerrar el puño o tocar las yemas de los dedos con el pulgar. Estos valores serán convertidos en instrucciones diversas que van desde mover un  carro a control remoto, pasando por el control de videojuegos educativos, hasta llegar a tareas más complejas como escribir o controlar el cursor de una computadora sin la necesidad de un mouse o un teclado. La terapia comenzará con el usuario portando RehabGlove frente al elemento que desea controlar, pidiéndole que realice movimientos específicos con la mano para que pueda lograr el objetivo final. Se espera que el nivel de complejidad vaya aumentando en cuanto al tipo de movimientos, rapidez, precisión y fuerza aplicada en cada acción. Con el uso de RehabGlove se espera que las terapias de rehabilitación posean niveles de cognición mayores y que tengan un avance progresivo aumentando el nivel de complejidad en cada ejercicio.   Video de prototipo<<<<< Rehab Glove Kinetis - YouTube Original Attachment has been moved to: Codigo-Fuente-Rehab-Glove.txt.zip
View full article
Agenda Mastering Kinetis-M Microcontrollers Schedule Module Description Duration Presenter 8:00 Registration 0:30 8:30 Introduction & Welcome 0:15 MM 8:45 MKM34Z256 core and peripherals architecture 1:00 Cano 9:45 DSP fractional, Filter, and FFT-based libraries for general signal processing and metering applications 1:00 LV 10:45 Break 0:15 11:00 Power meter & PLC reference design overview (1ph, 2ph (MKM34Z128), 3ph, 3ph shunt based + sensor node) 1:00 RK 12:00 Introduction to TWR-MKM34Z75, bare-metal drivers, SDK 2.0, FreeRTOS and FreeMaster 1:00 Cano+ID 13:00 Launch in the office 1:00 14:00 Workshop - TWR LCD example (preprogrammed, debugging, SW re-flashing) 0:45 Cano 14:45 Workshop - Using serial bootloader example (learn the way of bootloder integration into application) 0:45 PK 15:30 Workshop - LPTMR and GPIO example (LPTIM & GPIO API, programming interrupt, debugging) 0:45 MM 16:15 Break 0:15 16:30 Workshop - FreeRTOS preemptive multitasking example (basics of FreeRTOS programming) 0:30 MM 17:00 Workshop - High-precision waveform measurement example (SD ADC & FreeMaster programming) 0:45 MM 17:45 Workshop - 64-bit math coprocessor example (mastering DSP instruction set the MMAU) 0:45 MM 18:30 Q&A 0:30 19:00 Dinner @ Brasserie restaurant 2:00 21:00
View full article
Recently I did a porting based on AN4370SW for a customer to support TWR-K20D72M, and with some modification in source code, header file and link file as well, it works well as expected. The following simple describes what I have done: 1.Copy the project file folder for K20D50M "AN4370SW\Source\Device\app\dfu_bootloader\iar_ew\kinetis_k20" and rename is as "kinetis_k20d70m" 2.Change the target settings as well as the flash loader. 3. Replace the header file for K20D50M and include it in derivative.h. The header file for K20D72M can be found from KINETIS_72MHz_SRC(http://cache.freescale.com/files/32bit/software/KINETIS_72MHz_SRC.zip?fpsp=1&WT_TYPE=Lab%20and%20Test%20Software&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=zip&WT_ASSET=Downloads&sr=9) 4.Modify the interrupt table in cstartup_M.s, which is more likely a K60's vertor table. 5.Search the code related with the macro "MCU_MK20D5", and add similar code snippet for K20D72M , You may easily find them by search the keyword "MCU_MK20D7". That code parts include initialization for MCG, and PIT0 and USB interrupt enablements, some definition in bootloader.h . 6. Copy the link file from K20D50M, and modify the PFLASH size,SRAM size and DFLASH size as shown below: Perform MassErase before programming . and then you may press the SW1 on TWR-K20D72M to select which mode to enter after download the application firmware: pressing SW1 to enter bootloader mode and releasing it to enter application mode. 7. Build image for this DFU bootloader. Actually the bareboard projects in KINETIS_72MHz_SRC can be used for that purpose, and only link file needs some modification to put the image starting from 0xA000, since exception table redirection has already been done in these projects. after that, user needs change some settings in the CW projects to use the new link file: and generate S19 file as the output as well as the map file: after compiling , you will have a xxx.afx.s19 file, but that is not the final format, we still need to transform it to bin format, and it can be done by a small tool in "C:\Program Files\Freescale\CW MCU v10.3\MCU\prog" There are some settings for this tool to transform the S19 file, by clicking Burner->Burner Dialog, you will see some option views, please set them as below: Referring to the above figure, maybe you would wonder how to set up the Origin and Length field, actually Origin is the value where the image starts from just as the link file specified , and Length is calculated by the results from the map file. Please refer to the following figure for details. 0x3550 = 0x1c90 + 0x18c0. I also attached the burner's configuration file and image link file as well as the image for reference. Please copy the link file in "KINETIS_72MHz_SRC\build\cw\linker_files". Please kindly refer to the attachment for more details. Hope that helps, B.R Kan
View full article
The installation file containing MKM34Z256 training examples programmed using Kinetis-M bare metal drivers and compiled using IAR EWARM 7.40.1. These examples explain programming steps for GPIO, Low Power Timer, Sigma Delta ADC, Memory Math Arithmetic Unit, and LCD on-chip peripherals. In addition, you will learn how to create simple FreeRTOS and 1-phase power meter applications. All examples including their handouts will be installed on your PC in c:\Freescale\KM34Z75_EXAMPLES subfolder. For more information about each example, please refer to its handout.
View full article
1. Overview BLE beacon is a common use of low power Bluetooth and it broadcasts advertisement at some interval. Freescale BLE beacon demo use Freescale Kinetis KL16 low power MCU and EMC EM9301 Bluetooth controller to implement a beacon reference design. Freescale BLE beacon features low power consumption of an average cost of 50uA with 600ms interval. Freescale Kinetis KL16 coordinates with EM9301 through SPI interface. View attachment to learn more
View full article
Here you will find both the code and project files for the ADC project. This project configures the ADC to perform single conversions, by default this is performed using a 16 bit configuration. The code uses ADC0, channel 12, once the conversion is finished it is displayed at the serial terminal. Code: #include "mbed.h" AnalogIn AnIn(A0); DigitalOut led(LED1); Serial pc(USBTX,USBRX); float x; int main() {     pc.printf(" ADC demo code\r\n");     while (1)     {     x=AnIn.read();     pc.printf("ADC0_Ch12=(%d)\r\n", x);     wait(.2);     } }
View full article
The following file contains example code for usage of ADC, UART, DAC, GPIO, I2C, interrupts, MCG and timers for the k53 platform. Regards.
View full article
This was a super fun project to work on and is popular around the office and on the road.  Now I have two of these for a truely amazing barrage of Nerf darts!  It's also always a lot of fun to tear things down and the Nerf gun had some cool plastic work and the shooting mechanism is more simple than what I originally guess.  But I digress, this post is about how you can build one of these yourself.  Please leave any questions or comments in the section below and I will try to answer and make refinements to this guide as we go. Say hello to my little friend. The shopping list (aka Bill of Materials or BOM) If you shop around you might be able to find better prices or substitute parts. Type Part Qty Price URL UBEC HKU5 1 $             5.33 http://www.hobbyking.com/hobbyking/store/__16663__HobbyKing_HKU5_5V_5A_UBEC.html LiPo TURNIGY 2200mAh 3S 20C 1 $             7.89 http://www.hobbyking.com/hobbyking/store/__8932__Turnigy_2200mAh_3S_20C_Lipo_Pack.html Servo S5030DX 1 $           28.63 http://www.hobbyking.com/hobbyking/store/__18862__Hobbyking_S5030DX_Digital_MG_Servo_X_Large_HV_164g_0_20s_30kg.html Servo HK15138 1 $             3.12 http://www.hobbyking.com/hobbyking/store/__16269__HK15138_Standard_Analog_Servo_38g_4_3kg_0_17s.html Relay PCB COM-11041 1 $             3.95 https://www.sparkfun.com/products/11041 Relay Components Various 1 $             3.00 https://www.sparkfun.com/wish_lists/36307 Nerf Gun Nerf Dart Tag Swarmfire Blaster 1 $           44.99 http://www.toysrus.com/product/index.jsp?productId=11267568 Controller FRDM-KL64F 1 $           12.95 http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-K64F Radio Module NRF24L01 2 $             3.00 http://www.dx.com/p/2-4ghz-nrf24l01-wireless-module-black-142224#.U8VIcpRdU1I Servo Arm Double Servo Arm X-Long 1 $             3.20 http://www.hobbyking.com/hobbyking/store/__19468__CNC_Alloy_Double_Servo_Arm_X_Long_Futaba_.html Servo Arm Heavy Duty Alloy Arm 1 $             5.63 http://www.hobbyking.com/hobbyking/store/__18350__Heavy_Duty_Alloy_1in_Servo_Arm_Futaba_Red_.html Servo Linkage Alloy Pushrod with Ball-Link 65mm 1 $             2.10 http://www.hobbyking.com/hobbyking/store/__25834__Alloy_Pushrod_with_Ball_Link_65mm.html Lazy Susan Shepherd 6 in. Lazy-Susan Turntable 1 $             4.49 http://www.homedepot.com/p/Shepherd-6-in-Lazy-Susan-Turntable-9548/100180572#.UYk5UqLql8E Metal Rod 3/8 in. x 36 in. Zinc Threaded Rod 1 $             2.87 http://www.homedepot.com/p/3-8-in-x-36-in-Zinc-Threaded-Rod-17340/202183465#.UYk5pqLql8E Frame 1/2 MDF 2ftx4ft 1 $           10.45 http://www.homedepot.com/p/1-2-in-x-2-ft-x-4-ft-Medium-Density-Fiberboard-Handy-Panel-1508108/202089097?N=btn1#.UYk6CqLql8E The build Two main pieces to construct in this phase.  The base turret and the actual hacking of the Nerf gun. All your base.. The base of the turret is pretty rudimentary, lot's of room for improvement here.  I used 1/2 MDF and some carpentry skills.  Here is an instructable on how to build a MDF box.  Atop the box is a lazy susan (ball bearing ring) so that the top-plate can rotate smoothly.  We considered leaving this element out, but worried that it would put to much strain on the servo. On the subject of servos, a few tidbits of wisdom for you as you build this thing.  First, the left/right servo needs to be dead center of the lazy susan, if your off too much things will start to bind which is not good for your servo.  Second, I used large higher torque servos which cost a bit more, they might be overkill, but it certainly performs well. I did a quick dimensionally accurate rendering of the design in Sketchup. Files are here. Hacking the Nerf Now for the fun stuff. There is no shortage of screws with this Nerf Gun.  So get out your Phillips screwdriver and go to town. There are two electrical systems in the Nerf that we are going to tap into.  One is the power switch and the other is the electrical trigger. This is the electrical trigger.  The trigger goes to our relay, which is either on or off.  We did try at first to use a 7.2V R/C car battery, but the Nerf draws too much power and didn't fire.  Going up to a 11.1V LiPo fixed that right up. This is the power switch. In Nerfinator 1.0 everything was hardwired together, which prevented us from completely pulling the Nerf from the base and made repairs difficult to say the least.  Nerfinator 2.0 we put this handy connector which allowed us to completely and easily remove the Nerf from the base.  Shipping this thing around the country will take a toll on it!  On that subject, Nerf 1.0, stopped cycling to the next position for us at the Austin Mini Maker Faire.  After a through inspection of the operational mechanics inside the Nerf (really cool BTW) it was a little bitty spring that was causing the piston not to fully retract.  We replaced the spring with 1/2 a ballpoint pin spring and to our surprise it all worked again.  Cue the MacGyver theme song... Electrical Connection Diagram [PDF] Code Mbed was the programming tool of choice for this build. Receive Side (RX) - The receiver is the base side.  This one takes input from the remote and controls the servo movement. NerfGun_nRF24L01P_RX - a mercurial repository | mbed Transmit Side (TX) - The transmitter is the remote side.  This one senses the users movement (accelerometer) and sends that data to the base station. NerfGun_nRF24L01P_TX - a mercurial repository | mbed Finishing Touches In the first passes of this build we just used a bare development board as the remote control.  We found that when given the remote they would not orientate it properly.  Angus and Iain CAD'ed up this really sweet controller for us to 3D print. Custom cutouts for the FRDM board and nRF module and powering through USB. Freedom- 3D Printed Controller files on Thingiverse Development Team Deactivated user - Amplification/Motivation CJarvis - Software/Hardware iafg and angusgalloway-b45797 - Design and print of controller Community Developed Improvements Nerf Gun Web Socket Compatibility - Controlling via Web Socket
View full article
Overview      This document describes how to use ezport module on TWR-K22F120M,  and the usage of ezport on other platforms  is similar.      The EzPort module is a serial flash programming interface that enables In-System Programming (ISP) of flash memory contents in a 32-bit general-purpose microcontroller.      The block diagram of EzPort module is as follows: Hardware environments TWR-K60D100M TWR-K22F120M TWR-SER Primary and Secondary Tower boards      Because the EzPort module is a serial flash programming interface that is compatible with a subset of the SPI format. TWR-K60D100M is used as a SPI master and TWR-K22F120M is used as a slave. The flash memory contents of TWR-K22F120M can be read/erased/programmed from TWR-K60D100M.      Connect the TWR-K60D100M and TWR-SER by two tower boards, the execution result will be outputed by uart. Step 1:TWR-K22F120M enters into EzPort mode Hardware setup:       If the TWR-K22F120M wants to enter EzPort mode, the EZP_CS pin should be asserted and then reset pin is asserted. TWR-K60D100M                         TWR-K22F120M PTC6(J11 A71)                           EZP_CS(J31 Pin9) Software setup: Open the project “ezport_test_kinetis”; Define the MACRO “ENTER_EZPORT_MODULE” in hal_config.h; Build and download the program into TWR-K60D100M, run it, then EZP_CS pin of TWR-K22F120M will be asserted. Then power-on the TWR-K22F120M. The TWR-K22F120M will enter into EzPort mode. Step 2: Use EzPort to read/erase/program the flash Hardware setup: TWR-K60D100M                         TWR-K22F120M PTD0(J11 B63)                            EZP_CS(J31 Pin9) PTD1(J11 B64)                            EZP_CLK(J31 Pin4) PTD2(J11 A76)                            EZP_DI(J31 Pin8) PTD3(J11 A77)                            EZP_DO(J31 Pin6) GND(J11 B65)                             GND(J31 Pin5) Note: TWR-K60D100M and TWR-K22F120M should have common ground. Software setup: Open the project “ezport_test_kinetis”; Undefine the MACRO “ENTER_EZPORT_MODULE” in hal_config.h, then EzPort test codes will be enabled; Build and download the program into TWR-K60D100M, run it, then the flash memory contents of TWR-K22F120M can be read/erased/programmed from TWR-K60D100M, the execution result will output to the console by uart.
View full article
中文版:     想到过使用飞思卡尔的Freedom平台当做昂贵的J-Link调试器吗,好吧,这次给你机会了,呵呵。昨天在去SEGGER官网查资料的时候看到了一个suprise,Segger刚刚为OpenSDA平台release了一个可以兼容Jlink功能的firmware。说白了,就是借用OpenSDA当做J-Link用,当然有部分功能是有所限制的,不过瑕不掩瑜,Jlink的高速、稳定及一些特有的功能一直让接触过它的开发者印象深刻,所以能用low-cost的OpenSDA实现高性能的Jlink实在是让人兴奋,包括在下,哈哈,所以还等什么,赶紧露胳膊抹袖子整整吧,呵呵~     其实这次SEGGER提供的firmware就是OpenSDA的一个Application(我已经上传到本博客最后的附件中了),类似MSD-APP和DBUG-APP等其他的OpenSDA应用,所以它的使用方法类似,具体可以参考我之前的一篇博客《尝鲜OpenSDA方式调试仿真Freedom平台》http://blog.chinaaet.com/detail/31795.html。     (1)将firmware更新到OpenSDA的平台之后,再回到normal mode,这样就可以把OpenSDA当J-Link用了。将硬件连接好之后,打开J-Link Commander,弹出的窗口如下图所示,看吧,有点如假包换的J-Link味道了吧,呵呵,而且还有正版的S/N序列号哦。     (2)当然在IAR环境下使用它还需要简单的设置几步,如下图所示,建议不使用flash loader而是使用jlink自带的调试下载引擎,更稳定且速度杠杠的,呵呵:     (3)一切都准备好之后,就可以按照J-Link的调试方法调试Kinetis了,呵呵。当然有个最大的好处是,借用J-Link的特性,使用OpenSDA也可以支持Live watch了,可以实时更新观察变量,这点灰常灰常给力,如下图: Limitations:     当然我们也会猜到SEGGER不会那么蠢到自断财路(OpenSDA平台可是非常low-cost的),不然谁还会用那么昂贵的正版J-Link啊,呵呵。所以使用SEGGER提供的这个firmware有以下几点限制: 1)只能用在飞思卡尔平台基于ARM的产品上; 2)只可以调试飞思卡尔的评估板,所以貌似如果用在自己画的板子上可能有问题; 3)还有一个比较遗憾的,那就是不支持使用J-Flash软件(我一直觉着J-Flash很好用); 4)SEGGER不提供技术支持(这个我觉着无所谓)。     总体来说,还是利好的消息的,我还是灰常灰常看好OpenSDA的应用前景的,连SEGGER都低头兼容了,看来飞思卡尔以后调试器短板有望得到弥补,加油吧,呵呵。     不聊了,附件为更新的固件,未完待续~ /*****************************************************************************************************************************************/ English Version:    It feels realy good to see that SEGGER has offered a firmware running on the FRDM OpenSDA platform which makes OpenSDA compatible to J-Link lite, allowing users to take advantage of most J-Link features. It means we can do the same things with high-performance by using the low-cost OpenSDA platform. 1) How to do?    The J-Link firmware SEGGER offered is just an OpenSDA Application, so put the FRDM board into Bootloader mode and update the firmware, which is enclosed in the attached, just like other OpenSDA applications. Then put it into normal mode and the J-Link driver will be installed. Open the J-Link Commander, and we will see the diagram below. In IAR IDE, some setup steps need to follow: 2) Why to do?     Most inland customers get used to J-Link to debug ARM based products since ARM7 time and the J-Link is realy good debugger by my experience, althougn the legal J-Link is expensive. So we can help the customer to develop and evaluata products with low-cost OpenSDA platform.    In addition, live watch in IAR, which can update the varibles in time, is only supported with J-Link engine, which is very important to customer.   3) Limitations     May be used with ARM based Freescale devices only;     Only debugging on evaluation boards is allowed. Debugging on custom hardware is not supported and not allowed;     No production flash programming support;     Unlimited breakpoints in flash available for evaluation only;     No support is given. 4) Suggestions     OpenSDA is a very potential platform. USBDM has also released a firmware which is compatible to OpenSDA recently. So an open source OpenSDA  release from P&E is expected and to help customer to custom their own debugger hardware, which can help us to extend our Kinetis products more convenient. Voila, just give a try!
View full article
Share some information on how to use micro-trace buffer.
View full article
Hello everyone, I have attached the audio recordings of the seminar. Each of them fits the presentations uploaded in the previous post.
View full article
Welcome to the FRDM-K64 mbed workshop, in this page you will find all the code examples we will review on this session. The program covers the following modules: GPIO Serial communication Interrupts PWM ADC I2C (Accelerometer) USB Ethernet Depending on how fast we advance during the session some of the modules might be skipped; however here you can find both the source code and binary files ready to be flashed into the FRDM-K64 development board. FRDM-K64Z120M The FRDM-K64 is fully compatible with the Arduino rapid prototyping system, the following image depicts the board's pinout, the green labels can be used directly into your mbed proyects, they have already been defined in the headers and libraries in order to make development easier. Sign up at mbed.org In order to create the projects covered on this session it is necessary to create an mbed user account, open the website and create a user account, if you have already signed up please log in. Mbed debugging application To enable the FRDM-K64 development board using the binary files generated by mbed it is necessary to update the board's firmware, follow the steps mentioned below in order to enable the board to be programmed: Press the board's reset button While pressing the reset button connect the board to your computer using the USB cable, it must be connected to the J26 USB connector. Once the unit has enumerated as "Bootloader", copy the 20140530_k20dx128_k64f_if_mbed.bin file into the unit Disconnect and reconnect the USB cable, the board must enumerate as "MBED" Serial communication driver To implement serial communication you need to install the serial driver in your computer, download the driver, once your board has enumerated as MBED execute the driver and wait for it to be finished, this might take a couple of minutes. Serial terminal In order to communicate with the board via serial port it is necessary to use a serial terminal, by default WIndows 7 and 8 do not have this application, XP does. If your OS does not feature a serial terminal, you can download the one at the bottom (Teraterm). ! Your board is now ready to be programmed using mbed!
View full article
On behalf of EarlOrlando​ Hello community, This document is intended to be a basic guide to get started with the eGUI. If you need a closer view about what this driver is, it is recommended to take a look into the eGUI Introduction document. Before starting, it is needed to download the library from the NXP eGUI website and it is recommended to take a look into the eGUI Reference Manual. For this document, a demo included in the eGUI drivers will be run and then modified to toggle a LED in the TWR-K70F120M board from the eGUI interface displayed in the TWR-LCD-RGB board. Contents. Introduction. 1. About this document. 2. Running the K70 demo on IAR. a. Compiling the TWR-K70F120M MQX libraries. b. Adding the SD card content. c. Download the application to the MCU. 3. Modifying the eGUI demo. a. Creating a new screen. i. Adding a new source file for the new screen. ii. Adding the screen header files. iii. Adding some macro definitions. iv. Defining screen attributes. v. Declaring the screen. vi. Defining a new string. vii. Adding the screen interfaces b. Opening the new screen. c. Creating a new button. d. Toggling the LED. 4. Conclusion. I hope you find this guide useful. Enjoy this guide, any feedback is welcome!
View full article
BSDL file for the MK20DN512VLL10.
View full article
I have definitely experienced some of the growing pains of using the Kinetis tools as they have underdone some changes.  I started tinkering with KDS last year when KSDK and MQX were separate packages.  I didn't mess around with it much, other than to prove that I could toggle some GPIO.  I then got more serious with KDS 2.0 and KSDK 1.1 when MQX was integrated into the installer.  I started with simple projects, and eventually got a pretty good demo put together that incorporated ethernet (using lwIP), RS485, Modbus TCP/RTU, motion control, and barcode reading.  Unfortunately, at that time there were some small issues with the KSDK 1.1 which prevented us from being able to easily write applications in C++.  I definitely think better in C++ than in C, so this was a bummer. I was quite excited when the C++ issues were fixed in KSDK 1.2.  So now I need to port my application from C to C++.  At this point, I am faced with two hurdles: Directly porting my currently-working application (written for KDS 2 / KSDK 1.1) doesn't work.  I have written some posts here about it and could use some help solving those problems. lwIP project that was working in KDS 2.0 with MQX and PEx no longer works in KDS 3.0 How do you force PEx to be totally C++ compatible? Adding HardFault handlers in KDS3/KSDK1.2? Figuring out how to call into C++ wrappers This post is about #2, where I believe I have a usable solution.  It's basically covered in Re: How to call C functions that use "restrict" keyword from C ?  but with a small twist or two.  I am currently using KDS 3, KSDK 1.2, and my project requires MQX Standard as well as Processor Expert.When you create a project like mine, you will likely go through the following basic steps: Create new project Enable KSDK and Processor Expert Change osa from BareMetal to MQX Change MQX from Lite to Standard Disable DbgCs1 Enable new fsl_uart in MQX settings and disable its pins Add OS_Task components and other PEx components Specify your CPU type in the C++ compiler settings, as shown below Generate code In addition to main.c, after you generate code, you'll also end up with os_tasks.c.  Your PEx components will have C code added to the Generated Code folder.  At this point, it should be possible to wrap components in C++ classes.  Tonight, I ran a simple test where I wanted one of my MQX tasks to blink an LED.  The LED blink code was wrapped in a simple C++ class, and in order to be able to create the C++ object to call into, you have to call it from C++ code! The solution ends up being pretty simple.  Rename main.c to main.cpp, and rename os_tasks.c to os_tasks.cpp.  Then generate code again.  Click on your Sources folder and hit F5.  You will see that main.c and os_tasks.cpp reappear, because they get re-created.  Right click on each of them and click Resource Configuration -> Exclude from Build. Click Select All, then Close.  This will prevent those files from being compiled.  Note that if you add more OS_Task components, you will need to manually update os_tasks.cpp accordingly. At this point, it's very simple to create a wrapper class and call it.  I wrote one called DebugLed.cpp: #include <DebugLed.h> #include "Cpu.h" #include "gpio_comp.h" namespace Peripherals { DebugLed::DebugLed() {   // TODO Auto-generated constructor stub } DebugLed::~DebugLed() {   // TODO Auto-generated destructor stub } void DebugLed::BlinkGreen() {   GPIO_DRV_SetPinOutput( LEDRGB_GREEN);   OSA_TimeDelay(150);                 /* Example code (for task release) */   GPIO_DRV_ClearPinOutput( LEDRGB_GREEN);   OSA_TimeDelay(150);                 /* Example code (for task release) */ } } /* namespace Peripherals */ (hopefully all of the code shows up when I post this!  I don't see all of it in the preview) Then you can instantiate the DebugLed object before the while(1) in your OS_Task: void Blink_task(os_task_param_t task_init_data) {   /* Write your local variable definition here */   Peripherals::DebugLed led; #ifdef PEX_USE_RTOS   while (1) { #endif     /* Write your code here ... */    led.BlinkGreen(); #ifdef PEX_USE_RTOS     } #endif    } /* END os_tasks */ #ifdef __cplusplus }  /* extern "C" */ #endif Build, debug, and set a breakpoint on your call into your C++ object, and it should hit it! It's a lot easier than I thought it would be.  I figured there would be more manual labor involved with the code generation aspect of it, but it seems to basically boil down to two files, and you don't even need to disable code generation for any of the PEx components, which means you can still use the GUI to change settings if necessary (even though manually changing the header is just as simple). When I get to the office tomorrow, I'll probably start wrapping more complex peripherals, but I really need to figure out the HardFault problem with my lwIP project.  If you have any suggestions, please visit my post: Adding HardFault handlers in KDS3/KSDK1.2? and comment if you can.  I hope my first document here on the Freescale Community was helpful to someone here!
View full article
最近搞了一个基于TWR-K20D50M的的USB MSD device bootloader, 可以打开文件夹CW中的K20D5下的.project来查看。 在原始的MSD的基础上移植了FAT过来。 其他IAR和Kinetis的其他chip没有测试,如果需要使用,一个是新增相关头文件,二是在bootloader.h中修改相应的MCU_K20D50M定义下的flash及ram配置
View full article